babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065
  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 shader path used to define the shader code
  19699. * It can be modified to trigger a new compilation
  19700. */
  19701. /**
  19702. * Sets the shader path used to define the shader code
  19703. * It can be modified to trigger a new compilation
  19704. */
  19705. shaderPath: any;
  19706. /**
  19707. * Gets the options used to compile the shader.
  19708. * They can be modified to trigger a new compilation
  19709. */
  19710. readonly options: IShaderMaterialOptions;
  19711. /**
  19712. * Gets the current class name of the material e.g. "ShaderMaterial"
  19713. * Mainly use in serialization.
  19714. * @returns the class name
  19715. */
  19716. getClassName(): string;
  19717. /**
  19718. * Specifies if the material will require alpha blending
  19719. * @returns a boolean specifying if alpha blending is needed
  19720. */
  19721. needAlphaBlending(): boolean;
  19722. /**
  19723. * Specifies if this material should be rendered in alpha test mode
  19724. * @returns a boolean specifying if an alpha test is needed.
  19725. */
  19726. needAlphaTesting(): boolean;
  19727. private _checkUniform;
  19728. /**
  19729. * Set a texture in the shader.
  19730. * @param name Define the name of the uniform samplers as defined in the shader
  19731. * @param texture Define the texture to bind to this sampler
  19732. * @return the material itself allowing "fluent" like uniform updates
  19733. */
  19734. setTexture(name: string, texture: Texture): ShaderMaterial;
  19735. /**
  19736. * Set a texture array in the shader.
  19737. * @param name Define the name of the uniform sampler array as defined in the shader
  19738. * @param textures Define the list of textures to bind to this sampler
  19739. * @return the material itself allowing "fluent" like uniform updates
  19740. */
  19741. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19742. /**
  19743. * Set a float in the shader.
  19744. * @param name Define the name of the uniform as defined in the shader
  19745. * @param value Define the value to give to the uniform
  19746. * @return the material itself allowing "fluent" like uniform updates
  19747. */
  19748. setFloat(name: string, value: number): ShaderMaterial;
  19749. /**
  19750. * Set a int in the shader.
  19751. * @param name Define the name of the uniform as defined in the shader
  19752. * @param value Define the value to give to the uniform
  19753. * @return the material itself allowing "fluent" like uniform updates
  19754. */
  19755. setInt(name: string, value: number): ShaderMaterial;
  19756. /**
  19757. * Set an array of floats in the shader.
  19758. * @param name Define the name of the uniform as defined in the shader
  19759. * @param value Define the value to give to the uniform
  19760. * @return the material itself allowing "fluent" like uniform updates
  19761. */
  19762. setFloats(name: string, value: number[]): ShaderMaterial;
  19763. /**
  19764. * Set a vec3 in the shader from a Color3.
  19765. * @param name Define the name of the uniform as defined in the shader
  19766. * @param value Define the value to give to the uniform
  19767. * @return the material itself allowing "fluent" like uniform updates
  19768. */
  19769. setColor3(name: string, value: Color3): ShaderMaterial;
  19770. /**
  19771. * Set a vec3 array in the shader from a Color3 array.
  19772. * @param name Define the name of the uniform as defined in the shader
  19773. * @param value Define the value to give to the uniform
  19774. * @return the material itself allowing "fluent" like uniform updates
  19775. */
  19776. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19777. /**
  19778. * Set a vec4 in the shader from a Color4.
  19779. * @param name Define the name of the uniform as defined in the shader
  19780. * @param value Define the value to give to the uniform
  19781. * @return the material itself allowing "fluent" like uniform updates
  19782. */
  19783. setColor4(name: string, value: Color4): ShaderMaterial;
  19784. /**
  19785. * Set a vec4 array in the shader from a Color4 array.
  19786. * @param name Define the name of the uniform as defined in the shader
  19787. * @param value Define the value to give to the uniform
  19788. * @return the material itself allowing "fluent" like uniform updates
  19789. */
  19790. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19791. /**
  19792. * Set a vec2 in the shader from a Vector2.
  19793. * @param name Define the name of the uniform as defined in the shader
  19794. * @param value Define the value to give to the uniform
  19795. * @return the material itself allowing "fluent" like uniform updates
  19796. */
  19797. setVector2(name: string, value: Vector2): ShaderMaterial;
  19798. /**
  19799. * Set a vec3 in the shader from a Vector3.
  19800. * @param name Define the name of the uniform as defined in the shader
  19801. * @param value Define the value to give to the uniform
  19802. * @return the material itself allowing "fluent" like uniform updates
  19803. */
  19804. setVector3(name: string, value: Vector3): ShaderMaterial;
  19805. /**
  19806. * Set a vec4 in the shader from a Vector4.
  19807. * @param name Define the name of the uniform as defined in the shader
  19808. * @param value Define the value to give to the uniform
  19809. * @return the material itself allowing "fluent" like uniform updates
  19810. */
  19811. setVector4(name: string, value: Vector4): ShaderMaterial;
  19812. /**
  19813. * Set a mat4 in the shader from a Matrix.
  19814. * @param name Define the name of the uniform as defined in the shader
  19815. * @param value Define the value to give to the uniform
  19816. * @return the material itself allowing "fluent" like uniform updates
  19817. */
  19818. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19819. /**
  19820. * Set a float32Array in the shader from a matrix array.
  19821. * @param name Define the name of the uniform as defined in the shader
  19822. * @param value Define the value to give to the uniform
  19823. * @return the material itself allowing "fluent" like uniform updates
  19824. */
  19825. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19826. /**
  19827. * Set a mat3 in the shader from a Float32Array.
  19828. * @param name Define the name of the uniform as defined in the shader
  19829. * @param value Define the value to give to the uniform
  19830. * @return the material itself allowing "fluent" like uniform updates
  19831. */
  19832. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19833. /**
  19834. * Set a mat2 in the shader from a Float32Array.
  19835. * @param name Define the name of the uniform as defined in the shader
  19836. * @param value Define the value to give to the uniform
  19837. * @return the material itself allowing "fluent" like uniform updates
  19838. */
  19839. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19840. /**
  19841. * Set a vec2 array in the shader from a number array.
  19842. * @param name Define the name of the uniform as defined in the shader
  19843. * @param value Define the value to give to the uniform
  19844. * @return the material itself allowing "fluent" like uniform updates
  19845. */
  19846. setArray2(name: string, value: number[]): ShaderMaterial;
  19847. /**
  19848. * Set a vec3 array in the shader from a number array.
  19849. * @param name Define the name of the uniform as defined in the shader
  19850. * @param value Define the value to give to the uniform
  19851. * @return the material itself allowing "fluent" like uniform updates
  19852. */
  19853. setArray3(name: string, value: number[]): ShaderMaterial;
  19854. /**
  19855. * Set a vec4 array in the shader from a number array.
  19856. * @param name Define the name of the uniform as defined in the shader
  19857. * @param value Define the value to give to the uniform
  19858. * @return the material itself allowing "fluent" like uniform updates
  19859. */
  19860. setArray4(name: string, value: number[]): ShaderMaterial;
  19861. private _checkCache;
  19862. /**
  19863. * Specifies that the submesh is ready to be used
  19864. * @param mesh defines the mesh to check
  19865. * @param subMesh defines which submesh to check
  19866. * @param useInstances specifies that instances should be used
  19867. * @returns a boolean indicating that the submesh is ready or not
  19868. */
  19869. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19870. /**
  19871. * Checks if the material is ready to render the requested mesh
  19872. * @param mesh Define the mesh to render
  19873. * @param useInstances Define whether or not the material is used with instances
  19874. * @returns true if ready, otherwise false
  19875. */
  19876. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19877. /**
  19878. * Binds the world matrix to the material
  19879. * @param world defines the world transformation matrix
  19880. */
  19881. bindOnlyWorldMatrix(world: Matrix): void;
  19882. /**
  19883. * Binds the material to the mesh
  19884. * @param world defines the world transformation matrix
  19885. * @param mesh defines the mesh to bind the material to
  19886. */
  19887. bind(world: Matrix, mesh?: Mesh): void;
  19888. /**
  19889. * Gets the active textures from the material
  19890. * @returns an array of textures
  19891. */
  19892. getActiveTextures(): BaseTexture[];
  19893. /**
  19894. * Specifies if the material uses a texture
  19895. * @param texture defines the texture to check against the material
  19896. * @returns a boolean specifying if the material uses the texture
  19897. */
  19898. hasTexture(texture: BaseTexture): boolean;
  19899. /**
  19900. * Makes a duplicate of the material, and gives it a new name
  19901. * @param name defines the new name for the duplicated material
  19902. * @returns the cloned material
  19903. */
  19904. clone(name: string): ShaderMaterial;
  19905. /**
  19906. * Disposes the material
  19907. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19908. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19909. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19910. */
  19911. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19912. /**
  19913. * Serializes this material in a JSON representation
  19914. * @returns the serialized material object
  19915. */
  19916. serialize(): any;
  19917. /**
  19918. * Creates a shader material from parsed shader material data
  19919. * @param source defines the JSON represnetation of the material
  19920. * @param scene defines the hosting scene
  19921. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19922. * @returns a new material
  19923. */
  19924. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19925. }
  19926. }
  19927. declare module "babylonjs/Shaders/color.fragment" {
  19928. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19929. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19930. /** @hidden */
  19931. export var colorPixelShader: {
  19932. name: string;
  19933. shader: string;
  19934. };
  19935. }
  19936. declare module "babylonjs/Shaders/color.vertex" {
  19937. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19938. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19939. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19940. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19941. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19942. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19943. /** @hidden */
  19944. export var colorVertexShader: {
  19945. name: string;
  19946. shader: string;
  19947. };
  19948. }
  19949. declare module "babylonjs/Meshes/linesMesh" {
  19950. import { Nullable } from "babylonjs/types";
  19951. import { Scene } from "babylonjs/scene";
  19952. import { Color3 } from "babylonjs/Maths/math.color";
  19953. import { Node } from "babylonjs/node";
  19954. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19955. import { Mesh } from "babylonjs/Meshes/mesh";
  19956. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19957. import { Effect } from "babylonjs/Materials/effect";
  19958. import { Material } from "babylonjs/Materials/material";
  19959. import "babylonjs/Shaders/color.fragment";
  19960. import "babylonjs/Shaders/color.vertex";
  19961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19962. /**
  19963. * Line mesh
  19964. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19965. */
  19966. export class LinesMesh extends Mesh {
  19967. /**
  19968. * If vertex color should be applied to the mesh
  19969. */
  19970. readonly useVertexColor?: boolean | undefined;
  19971. /**
  19972. * If vertex alpha should be applied to the mesh
  19973. */
  19974. readonly useVertexAlpha?: boolean | undefined;
  19975. /**
  19976. * Color of the line (Default: White)
  19977. */
  19978. color: Color3;
  19979. /**
  19980. * Alpha of the line (Default: 1)
  19981. */
  19982. alpha: number;
  19983. /**
  19984. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19985. * This margin is expressed in world space coordinates, so its value may vary.
  19986. * Default value is 0.1
  19987. */
  19988. intersectionThreshold: number;
  19989. private _colorShader;
  19990. private color4;
  19991. /**
  19992. * Creates a new LinesMesh
  19993. * @param name defines the name
  19994. * @param scene defines the hosting scene
  19995. * @param parent defines the parent mesh if any
  19996. * @param source defines the optional source LinesMesh used to clone data from
  19997. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19998. * When false, achieved by calling a clone(), also passing False.
  19999. * This will make creation of children, recursive.
  20000. * @param useVertexColor defines if this LinesMesh supports vertex color
  20001. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20002. */
  20003. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20004. /**
  20005. * If vertex color should be applied to the mesh
  20006. */
  20007. useVertexColor?: boolean | undefined,
  20008. /**
  20009. * If vertex alpha should be applied to the mesh
  20010. */
  20011. useVertexAlpha?: boolean | undefined);
  20012. private _addClipPlaneDefine;
  20013. private _removeClipPlaneDefine;
  20014. isReady(): boolean;
  20015. /**
  20016. * Returns the string "LineMesh"
  20017. */
  20018. getClassName(): string;
  20019. /**
  20020. * @hidden
  20021. */
  20022. /**
  20023. * @hidden
  20024. */
  20025. material: Material;
  20026. /**
  20027. * @hidden
  20028. */
  20029. readonly checkCollisions: boolean;
  20030. /** @hidden */
  20031. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20032. /** @hidden */
  20033. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20034. /**
  20035. * Disposes of the line mesh
  20036. * @param doNotRecurse If children should be disposed
  20037. */
  20038. dispose(doNotRecurse?: boolean): void;
  20039. /**
  20040. * Returns a new LineMesh object cloned from the current one.
  20041. */
  20042. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20043. /**
  20044. * Creates a new InstancedLinesMesh object from the mesh model.
  20045. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20046. * @param name defines the name of the new instance
  20047. * @returns a new InstancedLinesMesh
  20048. */
  20049. createInstance(name: string): InstancedLinesMesh;
  20050. }
  20051. /**
  20052. * Creates an instance based on a source LinesMesh
  20053. */
  20054. export class InstancedLinesMesh extends InstancedMesh {
  20055. /**
  20056. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20057. * This margin is expressed in world space coordinates, so its value may vary.
  20058. * Initilized with the intersectionThreshold value of the source LinesMesh
  20059. */
  20060. intersectionThreshold: number;
  20061. constructor(name: string, source: LinesMesh);
  20062. /**
  20063. * Returns the string "InstancedLinesMesh".
  20064. */
  20065. getClassName(): string;
  20066. }
  20067. }
  20068. declare module "babylonjs/Shaders/line.fragment" {
  20069. /** @hidden */
  20070. export var linePixelShader: {
  20071. name: string;
  20072. shader: string;
  20073. };
  20074. }
  20075. declare module "babylonjs/Shaders/line.vertex" {
  20076. /** @hidden */
  20077. export var lineVertexShader: {
  20078. name: string;
  20079. shader: string;
  20080. };
  20081. }
  20082. declare module "babylonjs/Rendering/edgesRenderer" {
  20083. import { Nullable } from "babylonjs/types";
  20084. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20086. import { Vector3 } from "babylonjs/Maths/math.vector";
  20087. import { IDisposable } from "babylonjs/scene";
  20088. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20089. import "babylonjs/Shaders/line.fragment";
  20090. import "babylonjs/Shaders/line.vertex";
  20091. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20092. module "babylonjs/Meshes/abstractMesh" {
  20093. interface AbstractMesh {
  20094. /**
  20095. * Gets the edgesRenderer associated with the mesh
  20096. */
  20097. edgesRenderer: Nullable<EdgesRenderer>;
  20098. }
  20099. }
  20100. module "babylonjs/Meshes/linesMesh" {
  20101. interface LinesMesh {
  20102. /**
  20103. * Enables the edge rendering mode on the mesh.
  20104. * This mode makes the mesh edges visible
  20105. * @param epsilon defines the maximal distance between two angles to detect a face
  20106. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20107. * @returns the currentAbstractMesh
  20108. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20109. */
  20110. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20111. }
  20112. }
  20113. module "babylonjs/Meshes/linesMesh" {
  20114. interface InstancedLinesMesh {
  20115. /**
  20116. * Enables the edge rendering mode on the mesh.
  20117. * This mode makes the mesh edges visible
  20118. * @param epsilon defines the maximal distance between two angles to detect a face
  20119. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20120. * @returns the current InstancedLinesMesh
  20121. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20122. */
  20123. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20124. }
  20125. }
  20126. /**
  20127. * Defines the minimum contract an Edges renderer should follow.
  20128. */
  20129. export interface IEdgesRenderer extends IDisposable {
  20130. /**
  20131. * Gets or sets a boolean indicating if the edgesRenderer is active
  20132. */
  20133. isEnabled: boolean;
  20134. /**
  20135. * Renders the edges of the attached mesh,
  20136. */
  20137. render(): void;
  20138. /**
  20139. * Checks wether or not the edges renderer is ready to render.
  20140. * @return true if ready, otherwise false.
  20141. */
  20142. isReady(): boolean;
  20143. }
  20144. /**
  20145. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20146. */
  20147. export class EdgesRenderer implements IEdgesRenderer {
  20148. /**
  20149. * Define the size of the edges with an orthographic camera
  20150. */
  20151. edgesWidthScalerForOrthographic: number;
  20152. /**
  20153. * Define the size of the edges with a perspective camera
  20154. */
  20155. edgesWidthScalerForPerspective: number;
  20156. protected _source: AbstractMesh;
  20157. protected _linesPositions: number[];
  20158. protected _linesNormals: number[];
  20159. protected _linesIndices: number[];
  20160. protected _epsilon: number;
  20161. protected _indicesCount: number;
  20162. protected _lineShader: ShaderMaterial;
  20163. protected _ib: DataBuffer;
  20164. protected _buffers: {
  20165. [key: string]: Nullable<VertexBuffer>;
  20166. };
  20167. protected _checkVerticesInsteadOfIndices: boolean;
  20168. private _meshRebuildObserver;
  20169. private _meshDisposeObserver;
  20170. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20171. isEnabled: boolean;
  20172. /**
  20173. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20174. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20175. * @param source Mesh used to create edges
  20176. * @param epsilon sum of angles in adjacency to check for edge
  20177. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20178. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20179. */
  20180. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20181. protected _prepareRessources(): void;
  20182. /** @hidden */
  20183. _rebuild(): void;
  20184. /**
  20185. * Releases the required resources for the edges renderer
  20186. */
  20187. dispose(): void;
  20188. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20189. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20190. /**
  20191. * Checks if the pair of p0 and p1 is en edge
  20192. * @param faceIndex
  20193. * @param edge
  20194. * @param faceNormals
  20195. * @param p0
  20196. * @param p1
  20197. * @private
  20198. */
  20199. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20200. /**
  20201. * push line into the position, normal and index buffer
  20202. * @protected
  20203. */
  20204. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20205. /**
  20206. * Generates lines edges from adjacencjes
  20207. * @private
  20208. */
  20209. _generateEdgesLines(): void;
  20210. /**
  20211. * Checks wether or not the edges renderer is ready to render.
  20212. * @return true if ready, otherwise false.
  20213. */
  20214. isReady(): boolean;
  20215. /**
  20216. * Renders the edges of the attached mesh,
  20217. */
  20218. render(): void;
  20219. }
  20220. /**
  20221. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20222. */
  20223. export class LineEdgesRenderer extends EdgesRenderer {
  20224. /**
  20225. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20226. * @param source LineMesh used to generate edges
  20227. * @param epsilon not important (specified angle for edge detection)
  20228. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20229. */
  20230. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20231. /**
  20232. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20233. */
  20234. _generateEdgesLines(): void;
  20235. }
  20236. }
  20237. declare module "babylonjs/Rendering/renderingGroup" {
  20238. import { SmartArray } from "babylonjs/Misc/smartArray";
  20239. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20241. import { Nullable } from "babylonjs/types";
  20242. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20243. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20244. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20245. import { Material } from "babylonjs/Materials/material";
  20246. import { Scene } from "babylonjs/scene";
  20247. /**
  20248. * This represents the object necessary to create a rendering group.
  20249. * This is exclusively used and created by the rendering manager.
  20250. * To modify the behavior, you use the available helpers in your scene or meshes.
  20251. * @hidden
  20252. */
  20253. export class RenderingGroup {
  20254. index: number;
  20255. private static _zeroVector;
  20256. private _scene;
  20257. private _opaqueSubMeshes;
  20258. private _transparentSubMeshes;
  20259. private _alphaTestSubMeshes;
  20260. private _depthOnlySubMeshes;
  20261. private _particleSystems;
  20262. private _spriteManagers;
  20263. private _opaqueSortCompareFn;
  20264. private _alphaTestSortCompareFn;
  20265. private _transparentSortCompareFn;
  20266. private _renderOpaque;
  20267. private _renderAlphaTest;
  20268. private _renderTransparent;
  20269. /** @hidden */
  20270. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20271. onBeforeTransparentRendering: () => void;
  20272. /**
  20273. * Set the opaque sort comparison function.
  20274. * If null the sub meshes will be render in the order they were created
  20275. */
  20276. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20277. /**
  20278. * Set the alpha test sort comparison function.
  20279. * If null the sub meshes will be render in the order they were created
  20280. */
  20281. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20282. /**
  20283. * Set the transparent sort comparison function.
  20284. * If null the sub meshes will be render in the order they were created
  20285. */
  20286. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20287. /**
  20288. * Creates a new rendering group.
  20289. * @param index The rendering group index
  20290. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20291. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20292. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20293. */
  20294. 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>);
  20295. /**
  20296. * Render all the sub meshes contained in the group.
  20297. * @param customRenderFunction Used to override the default render behaviour of the group.
  20298. * @returns true if rendered some submeshes.
  20299. */
  20300. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20301. /**
  20302. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20303. * @param subMeshes The submeshes to render
  20304. */
  20305. private renderOpaqueSorted;
  20306. /**
  20307. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20308. * @param subMeshes The submeshes to render
  20309. */
  20310. private renderAlphaTestSorted;
  20311. /**
  20312. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20313. * @param subMeshes The submeshes to render
  20314. */
  20315. private renderTransparentSorted;
  20316. /**
  20317. * Renders the submeshes in a specified order.
  20318. * @param subMeshes The submeshes to sort before render
  20319. * @param sortCompareFn The comparison function use to sort
  20320. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20321. * @param transparent Specifies to activate blending if true
  20322. */
  20323. private static renderSorted;
  20324. /**
  20325. * Renders the submeshes in the order they were dispatched (no sort applied).
  20326. * @param subMeshes The submeshes to render
  20327. */
  20328. private static renderUnsorted;
  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 if in the same alpha index.
  20332. *
  20333. * @param a The first submesh
  20334. * @param b The second submesh
  20335. * @returns The result of the comparison
  20336. */
  20337. static defaultTransparentSortCompare(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 back to front.
  20341. *
  20342. * @param a The first submesh
  20343. * @param b The second submesh
  20344. * @returns The result of the comparison
  20345. */
  20346. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20347. /**
  20348. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20349. * are rendered front to back (prevent overdraw).
  20350. *
  20351. * @param a The first submesh
  20352. * @param b The second submesh
  20353. * @returns The result of the comparison
  20354. */
  20355. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20356. /**
  20357. * Resets the different lists of submeshes to prepare a new frame.
  20358. */
  20359. prepare(): void;
  20360. dispose(): void;
  20361. /**
  20362. * Inserts the submesh in its correct queue depending on its material.
  20363. * @param subMesh The submesh to dispatch
  20364. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20365. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20366. */
  20367. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20368. dispatchSprites(spriteManager: ISpriteManager): void;
  20369. dispatchParticles(particleSystem: IParticleSystem): void;
  20370. private _renderParticles;
  20371. private _renderSprites;
  20372. }
  20373. }
  20374. declare module "babylonjs/Rendering/renderingManager" {
  20375. import { Nullable } from "babylonjs/types";
  20376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20377. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20378. import { SmartArray } from "babylonjs/Misc/smartArray";
  20379. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20380. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20381. import { Material } from "babylonjs/Materials/material";
  20382. import { Scene } from "babylonjs/scene";
  20383. import { Camera } from "babylonjs/Cameras/camera";
  20384. /**
  20385. * Interface describing the different options available in the rendering manager
  20386. * regarding Auto Clear between groups.
  20387. */
  20388. export interface IRenderingManagerAutoClearSetup {
  20389. /**
  20390. * Defines whether or not autoclear is enable.
  20391. */
  20392. autoClear: boolean;
  20393. /**
  20394. * Defines whether or not to autoclear the depth buffer.
  20395. */
  20396. depth: boolean;
  20397. /**
  20398. * Defines whether or not to autoclear the stencil buffer.
  20399. */
  20400. stencil: boolean;
  20401. }
  20402. /**
  20403. * This class is used by the onRenderingGroupObservable
  20404. */
  20405. export class RenderingGroupInfo {
  20406. /**
  20407. * The Scene that being rendered
  20408. */
  20409. scene: Scene;
  20410. /**
  20411. * The camera currently used for the rendering pass
  20412. */
  20413. camera: Nullable<Camera>;
  20414. /**
  20415. * The ID of the renderingGroup being processed
  20416. */
  20417. renderingGroupId: number;
  20418. }
  20419. /**
  20420. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20421. * It is enable to manage the different groups as well as the different necessary sort functions.
  20422. * This should not be used directly aside of the few static configurations
  20423. */
  20424. export class RenderingManager {
  20425. /**
  20426. * The max id used for rendering groups (not included)
  20427. */
  20428. static MAX_RENDERINGGROUPS: number;
  20429. /**
  20430. * The min id used for rendering groups (included)
  20431. */
  20432. static MIN_RENDERINGGROUPS: number;
  20433. /**
  20434. * Used to globally prevent autoclearing scenes.
  20435. */
  20436. static AUTOCLEAR: boolean;
  20437. /**
  20438. * @hidden
  20439. */
  20440. _useSceneAutoClearSetup: boolean;
  20441. private _scene;
  20442. private _renderingGroups;
  20443. private _depthStencilBufferAlreadyCleaned;
  20444. private _autoClearDepthStencil;
  20445. private _customOpaqueSortCompareFn;
  20446. private _customAlphaTestSortCompareFn;
  20447. private _customTransparentSortCompareFn;
  20448. private _renderingGroupInfo;
  20449. /**
  20450. * Instantiates a new rendering group for a particular scene
  20451. * @param scene Defines the scene the groups belongs to
  20452. */
  20453. constructor(scene: Scene);
  20454. private _clearDepthStencilBuffer;
  20455. /**
  20456. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20457. * @hidden
  20458. */
  20459. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20460. /**
  20461. * Resets the different information of the group to prepare a new frame
  20462. * @hidden
  20463. */
  20464. reset(): void;
  20465. /**
  20466. * Dispose and release the group and its associated resources.
  20467. * @hidden
  20468. */
  20469. dispose(): void;
  20470. /**
  20471. * Clear the info related to rendering groups preventing retention points during dispose.
  20472. */
  20473. freeRenderingGroups(): void;
  20474. private _prepareRenderingGroup;
  20475. /**
  20476. * Add a sprite manager to the rendering manager in order to render it this frame.
  20477. * @param spriteManager Define the sprite manager to render
  20478. */
  20479. dispatchSprites(spriteManager: ISpriteManager): void;
  20480. /**
  20481. * Add a particle system to the rendering manager in order to render it this frame.
  20482. * @param particleSystem Define the particle system to render
  20483. */
  20484. dispatchParticles(particleSystem: IParticleSystem): void;
  20485. /**
  20486. * Add a submesh to the manager in order to render it this frame
  20487. * @param subMesh The submesh to dispatch
  20488. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20489. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20490. */
  20491. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20492. /**
  20493. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20494. * This allowed control for front to back rendering or reversly depending of the special needs.
  20495. *
  20496. * @param renderingGroupId The rendering group id corresponding to its index
  20497. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20498. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20499. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20500. */
  20501. 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;
  20502. /**
  20503. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20504. *
  20505. * @param renderingGroupId The rendering group id corresponding to its index
  20506. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20507. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20508. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20509. */
  20510. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20511. /**
  20512. * Gets the current auto clear configuration for one rendering group of the rendering
  20513. * manager.
  20514. * @param index the rendering group index to get the information for
  20515. * @returns The auto clear setup for the requested rendering group
  20516. */
  20517. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20518. }
  20519. }
  20520. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20521. import { Observable } from "babylonjs/Misc/observable";
  20522. import { SmartArray } from "babylonjs/Misc/smartArray";
  20523. import { Nullable } from "babylonjs/types";
  20524. import { Camera } from "babylonjs/Cameras/camera";
  20525. import { Scene } from "babylonjs/scene";
  20526. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20527. import { Color4 } from "babylonjs/Maths/math.color";
  20528. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20530. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20532. import { Texture } from "babylonjs/Materials/Textures/texture";
  20533. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20534. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20535. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20536. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20537. import { Engine } from "babylonjs/Engines/engine";
  20538. /**
  20539. * This Helps creating a texture that will be created from a camera in your scene.
  20540. * It is basically a dynamic texture that could be used to create special effects for instance.
  20541. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20542. */
  20543. export class RenderTargetTexture extends Texture {
  20544. isCube: boolean;
  20545. /**
  20546. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20547. */
  20548. static readonly REFRESHRATE_RENDER_ONCE: number;
  20549. /**
  20550. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20551. */
  20552. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20553. /**
  20554. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20555. * the central point of your effect and can save a lot of performances.
  20556. */
  20557. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20558. /**
  20559. * Use this predicate to dynamically define the list of mesh you want to render.
  20560. * If set, the renderList property will be overwritten.
  20561. */
  20562. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20563. private _renderList;
  20564. /**
  20565. * Use this list to define the list of mesh you want to render.
  20566. */
  20567. renderList: Nullable<Array<AbstractMesh>>;
  20568. private _hookArray;
  20569. /**
  20570. * Define if particles should be rendered in your texture.
  20571. */
  20572. renderParticles: boolean;
  20573. /**
  20574. * Define if sprites should be rendered in your texture.
  20575. */
  20576. renderSprites: boolean;
  20577. /**
  20578. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20579. */
  20580. coordinatesMode: number;
  20581. /**
  20582. * Define the camera used to render the texture.
  20583. */
  20584. activeCamera: Nullable<Camera>;
  20585. /**
  20586. * Override the render function of the texture with your own one.
  20587. */
  20588. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20589. /**
  20590. * Define if camera post processes should be use while rendering the texture.
  20591. */
  20592. useCameraPostProcesses: boolean;
  20593. /**
  20594. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20595. */
  20596. ignoreCameraViewport: boolean;
  20597. private _postProcessManager;
  20598. private _postProcesses;
  20599. private _resizeObserver;
  20600. /**
  20601. * An event triggered when the texture is unbind.
  20602. */
  20603. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20604. /**
  20605. * An event triggered when the texture is unbind.
  20606. */
  20607. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20608. private _onAfterUnbindObserver;
  20609. /**
  20610. * Set a after unbind callback in the texture.
  20611. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20612. */
  20613. onAfterUnbind: () => void;
  20614. /**
  20615. * An event triggered before rendering the texture
  20616. */
  20617. onBeforeRenderObservable: Observable<number>;
  20618. private _onBeforeRenderObserver;
  20619. /**
  20620. * Set a before render callback in the texture.
  20621. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20622. */
  20623. onBeforeRender: (faceIndex: number) => void;
  20624. /**
  20625. * An event triggered after rendering the texture
  20626. */
  20627. onAfterRenderObservable: Observable<number>;
  20628. private _onAfterRenderObserver;
  20629. /**
  20630. * Set a after render callback in the texture.
  20631. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20632. */
  20633. onAfterRender: (faceIndex: number) => void;
  20634. /**
  20635. * An event triggered after the texture clear
  20636. */
  20637. onClearObservable: Observable<Engine>;
  20638. private _onClearObserver;
  20639. /**
  20640. * Set a clear callback in the texture.
  20641. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20642. */
  20643. onClear: (Engine: Engine) => void;
  20644. /**
  20645. * An event triggered when the texture is resized.
  20646. */
  20647. onResizeObservable: Observable<RenderTargetTexture>;
  20648. /**
  20649. * Define the clear color of the Render Target if it should be different from the scene.
  20650. */
  20651. clearColor: Color4;
  20652. protected _size: number | {
  20653. width: number;
  20654. height: number;
  20655. };
  20656. protected _initialSizeParameter: number | {
  20657. width: number;
  20658. height: number;
  20659. } | {
  20660. ratio: number;
  20661. };
  20662. protected _sizeRatio: Nullable<number>;
  20663. /** @hidden */
  20664. _generateMipMaps: boolean;
  20665. protected _renderingManager: RenderingManager;
  20666. /** @hidden */
  20667. _waitingRenderList: string[];
  20668. protected _doNotChangeAspectRatio: boolean;
  20669. protected _currentRefreshId: number;
  20670. protected _refreshRate: number;
  20671. protected _textureMatrix: Matrix;
  20672. protected _samples: number;
  20673. protected _renderTargetOptions: RenderTargetCreationOptions;
  20674. /**
  20675. * Gets render target creation options that were used.
  20676. */
  20677. readonly renderTargetOptions: RenderTargetCreationOptions;
  20678. protected _engine: Engine;
  20679. protected _onRatioRescale(): void;
  20680. /**
  20681. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20682. * It must define where the camera used to render the texture is set
  20683. */
  20684. boundingBoxPosition: Vector3;
  20685. private _boundingBoxSize;
  20686. /**
  20687. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20688. * When defined, the cubemap will switch to local mode
  20689. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20690. * @example https://www.babylonjs-playground.com/#RNASML
  20691. */
  20692. boundingBoxSize: Vector3;
  20693. /**
  20694. * In case the RTT has been created with a depth texture, get the associated
  20695. * depth texture.
  20696. * Otherwise, return null.
  20697. */
  20698. depthStencilTexture: Nullable<InternalTexture>;
  20699. /**
  20700. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20701. * or used a shadow, depth texture...
  20702. * @param name The friendly name of the texture
  20703. * @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)
  20704. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20705. * @param generateMipMaps True if mip maps need to be generated after render.
  20706. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20707. * @param type The type of the buffer in the RTT (int, half float, float...)
  20708. * @param isCube True if a cube texture needs to be created
  20709. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20710. * @param generateDepthBuffer True to generate a depth buffer
  20711. * @param generateStencilBuffer True to generate a stencil buffer
  20712. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20713. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20714. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20715. */
  20716. constructor(name: string, size: number | {
  20717. width: number;
  20718. height: number;
  20719. } | {
  20720. ratio: number;
  20721. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20722. /**
  20723. * Creates a depth stencil texture.
  20724. * This is only available in WebGL 2 or with the depth texture extension available.
  20725. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20726. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20727. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20728. */
  20729. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20730. private _processSizeParameter;
  20731. /**
  20732. * Define the number of samples to use in case of MSAA.
  20733. * It defaults to one meaning no MSAA has been enabled.
  20734. */
  20735. samples: number;
  20736. /**
  20737. * Resets the refresh counter of the texture and start bak from scratch.
  20738. * Could be useful to regenerate the texture if it is setup to render only once.
  20739. */
  20740. resetRefreshCounter(): void;
  20741. /**
  20742. * Define the refresh rate of the texture or the rendering frequency.
  20743. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20744. */
  20745. refreshRate: number;
  20746. /**
  20747. * Adds a post process to the render target rendering passes.
  20748. * @param postProcess define the post process to add
  20749. */
  20750. addPostProcess(postProcess: PostProcess): void;
  20751. /**
  20752. * Clear all the post processes attached to the render target
  20753. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20754. */
  20755. clearPostProcesses(dispose?: boolean): void;
  20756. /**
  20757. * Remove one of the post process from the list of attached post processes to the texture
  20758. * @param postProcess define the post process to remove from the list
  20759. */
  20760. removePostProcess(postProcess: PostProcess): void;
  20761. /** @hidden */
  20762. _shouldRender(): boolean;
  20763. /**
  20764. * Gets the actual render size of the texture.
  20765. * @returns the width of the render size
  20766. */
  20767. getRenderSize(): number;
  20768. /**
  20769. * Gets the actual render width of the texture.
  20770. * @returns the width of the render size
  20771. */
  20772. getRenderWidth(): number;
  20773. /**
  20774. * Gets the actual render height of the texture.
  20775. * @returns the height of the render size
  20776. */
  20777. getRenderHeight(): number;
  20778. /**
  20779. * Get if the texture can be rescaled or not.
  20780. */
  20781. readonly canRescale: boolean;
  20782. /**
  20783. * Resize the texture using a ratio.
  20784. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20785. */
  20786. scale(ratio: number): void;
  20787. /**
  20788. * Get the texture reflection matrix used to rotate/transform the reflection.
  20789. * @returns the reflection matrix
  20790. */
  20791. getReflectionTextureMatrix(): Matrix;
  20792. /**
  20793. * Resize the texture to a new desired size.
  20794. * Be carrefull as it will recreate all the data in the new texture.
  20795. * @param size Define the new size. It can be:
  20796. * - a number for squared texture,
  20797. * - an object containing { width: number, height: number }
  20798. * - or an object containing a ratio { ratio: number }
  20799. */
  20800. resize(size: number | {
  20801. width: number;
  20802. height: number;
  20803. } | {
  20804. ratio: number;
  20805. }): void;
  20806. /**
  20807. * Renders all the objects from the render list into the texture.
  20808. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20809. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20810. */
  20811. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20812. private _bestReflectionRenderTargetDimension;
  20813. /**
  20814. * @hidden
  20815. * @param faceIndex face index to bind to if this is a cubetexture
  20816. */
  20817. _bindFrameBuffer(faceIndex?: number): void;
  20818. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20819. private renderToTarget;
  20820. /**
  20821. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20822. * This allowed control for front to back rendering or reversly depending of the special needs.
  20823. *
  20824. * @param renderingGroupId The rendering group id corresponding to its index
  20825. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20826. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20827. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20828. */
  20829. 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;
  20830. /**
  20831. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20832. *
  20833. * @param renderingGroupId The rendering group id corresponding to its index
  20834. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20835. */
  20836. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20837. /**
  20838. * Clones the texture.
  20839. * @returns the cloned texture
  20840. */
  20841. clone(): RenderTargetTexture;
  20842. /**
  20843. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20844. * @returns The JSON representation of the texture
  20845. */
  20846. serialize(): any;
  20847. /**
  20848. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20849. */
  20850. disposeFramebufferObjects(): void;
  20851. /**
  20852. * Dispose the texture and release its associated resources.
  20853. */
  20854. dispose(): void;
  20855. /** @hidden */
  20856. _rebuild(): void;
  20857. /**
  20858. * Clear the info related to rendering groups preventing retention point in material dispose.
  20859. */
  20860. freeRenderingGroups(): void;
  20861. /**
  20862. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20863. * @returns the view count
  20864. */
  20865. getViewCount(): number;
  20866. }
  20867. }
  20868. declare module "babylonjs/Materials/material" {
  20869. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20870. import { SmartArray } from "babylonjs/Misc/smartArray";
  20871. import { Observable } from "babylonjs/Misc/observable";
  20872. import { Nullable } from "babylonjs/types";
  20873. import { Scene } from "babylonjs/scene";
  20874. import { Matrix } from "babylonjs/Maths/math.vector";
  20875. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20877. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20878. import { Effect } from "babylonjs/Materials/effect";
  20879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20880. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20881. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20882. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20883. import { Mesh } from "babylonjs/Meshes/mesh";
  20884. import { Animation } from "babylonjs/Animations/animation";
  20885. /**
  20886. * Options for compiling materials.
  20887. */
  20888. export interface IMaterialCompilationOptions {
  20889. /**
  20890. * Defines whether clip planes are enabled.
  20891. */
  20892. clipPlane: boolean;
  20893. /**
  20894. * Defines whether instances are enabled.
  20895. */
  20896. useInstances: boolean;
  20897. }
  20898. /**
  20899. * Base class for the main features of a material in Babylon.js
  20900. */
  20901. export class Material implements IAnimatable {
  20902. /**
  20903. * Returns the triangle fill mode
  20904. */
  20905. static readonly TriangleFillMode: number;
  20906. /**
  20907. * Returns the wireframe mode
  20908. */
  20909. static readonly WireFrameFillMode: number;
  20910. /**
  20911. * Returns the point fill mode
  20912. */
  20913. static readonly PointFillMode: number;
  20914. /**
  20915. * Returns the point list draw mode
  20916. */
  20917. static readonly PointListDrawMode: number;
  20918. /**
  20919. * Returns the line list draw mode
  20920. */
  20921. static readonly LineListDrawMode: number;
  20922. /**
  20923. * Returns the line loop draw mode
  20924. */
  20925. static readonly LineLoopDrawMode: number;
  20926. /**
  20927. * Returns the line strip draw mode
  20928. */
  20929. static readonly LineStripDrawMode: number;
  20930. /**
  20931. * Returns the triangle strip draw mode
  20932. */
  20933. static readonly TriangleStripDrawMode: number;
  20934. /**
  20935. * Returns the triangle fan draw mode
  20936. */
  20937. static readonly TriangleFanDrawMode: number;
  20938. /**
  20939. * Stores the clock-wise side orientation
  20940. */
  20941. static readonly ClockWiseSideOrientation: number;
  20942. /**
  20943. * Stores the counter clock-wise side orientation
  20944. */
  20945. static readonly CounterClockWiseSideOrientation: number;
  20946. /**
  20947. * The dirty texture flag value
  20948. */
  20949. static readonly TextureDirtyFlag: number;
  20950. /**
  20951. * The dirty light flag value
  20952. */
  20953. static readonly LightDirtyFlag: number;
  20954. /**
  20955. * The dirty fresnel flag value
  20956. */
  20957. static readonly FresnelDirtyFlag: number;
  20958. /**
  20959. * The dirty attribute flag value
  20960. */
  20961. static readonly AttributesDirtyFlag: number;
  20962. /**
  20963. * The dirty misc flag value
  20964. */
  20965. static readonly MiscDirtyFlag: number;
  20966. /**
  20967. * The all dirty flag value
  20968. */
  20969. static readonly AllDirtyFlag: number;
  20970. /**
  20971. * The ID of the material
  20972. */
  20973. id: string;
  20974. /**
  20975. * Gets or sets the unique id of the material
  20976. */
  20977. uniqueId: number;
  20978. /**
  20979. * The name of the material
  20980. */
  20981. name: string;
  20982. /**
  20983. * Gets or sets user defined metadata
  20984. */
  20985. metadata: any;
  20986. /**
  20987. * For internal use only. Please do not use.
  20988. */
  20989. reservedDataStore: any;
  20990. /**
  20991. * Specifies if the ready state should be checked on each call
  20992. */
  20993. checkReadyOnEveryCall: boolean;
  20994. /**
  20995. * Specifies if the ready state should be checked once
  20996. */
  20997. checkReadyOnlyOnce: boolean;
  20998. /**
  20999. * The state of the material
  21000. */
  21001. state: string;
  21002. /**
  21003. * The alpha value of the material
  21004. */
  21005. protected _alpha: number;
  21006. /**
  21007. * List of inspectable custom properties (used by the Inspector)
  21008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21009. */
  21010. inspectableCustomProperties: IInspectable[];
  21011. /**
  21012. * Sets the alpha value of the material
  21013. */
  21014. /**
  21015. * Gets the alpha value of the material
  21016. */
  21017. alpha: number;
  21018. /**
  21019. * Specifies if back face culling is enabled
  21020. */
  21021. protected _backFaceCulling: boolean;
  21022. /**
  21023. * Sets the back-face culling state
  21024. */
  21025. /**
  21026. * Gets the back-face culling state
  21027. */
  21028. backFaceCulling: boolean;
  21029. /**
  21030. * Stores the value for side orientation
  21031. */
  21032. sideOrientation: number;
  21033. /**
  21034. * Callback triggered when the material is compiled
  21035. */
  21036. onCompiled: Nullable<(effect: Effect) => void>;
  21037. /**
  21038. * Callback triggered when an error occurs
  21039. */
  21040. onError: Nullable<(effect: Effect, errors: string) => void>;
  21041. /**
  21042. * Callback triggered to get the render target textures
  21043. */
  21044. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21045. /**
  21046. * Gets a boolean indicating that current material needs to register RTT
  21047. */
  21048. readonly hasRenderTargetTextures: boolean;
  21049. /**
  21050. * Specifies if the material should be serialized
  21051. */
  21052. doNotSerialize: boolean;
  21053. /**
  21054. * @hidden
  21055. */
  21056. _storeEffectOnSubMeshes: boolean;
  21057. /**
  21058. * Stores the animations for the material
  21059. */
  21060. animations: Nullable<Array<Animation>>;
  21061. /**
  21062. * An event triggered when the material is disposed
  21063. */
  21064. onDisposeObservable: Observable<Material>;
  21065. /**
  21066. * An observer which watches for dispose events
  21067. */
  21068. private _onDisposeObserver;
  21069. private _onUnBindObservable;
  21070. /**
  21071. * Called during a dispose event
  21072. */
  21073. onDispose: () => void;
  21074. private _onBindObservable;
  21075. /**
  21076. * An event triggered when the material is bound
  21077. */
  21078. readonly onBindObservable: Observable<AbstractMesh>;
  21079. /**
  21080. * An observer which watches for bind events
  21081. */
  21082. private _onBindObserver;
  21083. /**
  21084. * Called during a bind event
  21085. */
  21086. onBind: (Mesh: AbstractMesh) => void;
  21087. /**
  21088. * An event triggered when the material is unbound
  21089. */
  21090. readonly onUnBindObservable: Observable<Material>;
  21091. /**
  21092. * Stores the value of the alpha mode
  21093. */
  21094. private _alphaMode;
  21095. /**
  21096. * Sets the value of the alpha mode.
  21097. *
  21098. * | Value | Type | Description |
  21099. * | --- | --- | --- |
  21100. * | 0 | ALPHA_DISABLE | |
  21101. * | 1 | ALPHA_ADD | |
  21102. * | 2 | ALPHA_COMBINE | |
  21103. * | 3 | ALPHA_SUBTRACT | |
  21104. * | 4 | ALPHA_MULTIPLY | |
  21105. * | 5 | ALPHA_MAXIMIZED | |
  21106. * | 6 | ALPHA_ONEONE | |
  21107. * | 7 | ALPHA_PREMULTIPLIED | |
  21108. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21109. * | 9 | ALPHA_INTERPOLATE | |
  21110. * | 10 | ALPHA_SCREENMODE | |
  21111. *
  21112. */
  21113. /**
  21114. * Gets the value of the alpha mode
  21115. */
  21116. alphaMode: number;
  21117. /**
  21118. * Stores the state of the need depth pre-pass value
  21119. */
  21120. private _needDepthPrePass;
  21121. /**
  21122. * Sets the need depth pre-pass value
  21123. */
  21124. /**
  21125. * Gets the depth pre-pass value
  21126. */
  21127. needDepthPrePass: boolean;
  21128. /**
  21129. * Specifies if depth writing should be disabled
  21130. */
  21131. disableDepthWrite: boolean;
  21132. /**
  21133. * Specifies if depth writing should be forced
  21134. */
  21135. forceDepthWrite: boolean;
  21136. /**
  21137. * Specifies if there should be a separate pass for culling
  21138. */
  21139. separateCullingPass: boolean;
  21140. /**
  21141. * Stores the state specifing if fog should be enabled
  21142. */
  21143. private _fogEnabled;
  21144. /**
  21145. * Sets the state for enabling fog
  21146. */
  21147. /**
  21148. * Gets the value of the fog enabled state
  21149. */
  21150. fogEnabled: boolean;
  21151. /**
  21152. * Stores the size of points
  21153. */
  21154. pointSize: number;
  21155. /**
  21156. * Stores the z offset value
  21157. */
  21158. zOffset: number;
  21159. /**
  21160. * Gets a value specifying if wireframe mode is enabled
  21161. */
  21162. /**
  21163. * Sets the state of wireframe mode
  21164. */
  21165. wireframe: boolean;
  21166. /**
  21167. * Gets the value specifying if point clouds are enabled
  21168. */
  21169. /**
  21170. * Sets the state of point cloud mode
  21171. */
  21172. pointsCloud: boolean;
  21173. /**
  21174. * Gets the material fill mode
  21175. */
  21176. /**
  21177. * Sets the material fill mode
  21178. */
  21179. fillMode: number;
  21180. /**
  21181. * @hidden
  21182. * Stores the effects for the material
  21183. */
  21184. _effect: Nullable<Effect>;
  21185. /**
  21186. * @hidden
  21187. * Specifies if the material was previously ready
  21188. */
  21189. _wasPreviouslyReady: boolean;
  21190. /**
  21191. * Specifies if uniform buffers should be used
  21192. */
  21193. private _useUBO;
  21194. /**
  21195. * Stores a reference to the scene
  21196. */
  21197. private _scene;
  21198. /**
  21199. * Stores the fill mode state
  21200. */
  21201. private _fillMode;
  21202. /**
  21203. * Specifies if the depth write state should be cached
  21204. */
  21205. private _cachedDepthWriteState;
  21206. /**
  21207. * Stores the uniform buffer
  21208. */
  21209. protected _uniformBuffer: UniformBuffer;
  21210. /** @hidden */
  21211. _indexInSceneMaterialArray: number;
  21212. /** @hidden */
  21213. meshMap: Nullable<{
  21214. [id: string]: AbstractMesh | undefined;
  21215. }>;
  21216. /**
  21217. * Creates a material instance
  21218. * @param name defines the name of the material
  21219. * @param scene defines the scene to reference
  21220. * @param doNotAdd specifies if the material should be added to the scene
  21221. */
  21222. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21223. /**
  21224. * Returns a string representation of the current material
  21225. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21226. * @returns a string with material information
  21227. */
  21228. toString(fullDetails?: boolean): string;
  21229. /**
  21230. * Gets the class name of the material
  21231. * @returns a string with the class name of the material
  21232. */
  21233. getClassName(): string;
  21234. /**
  21235. * Specifies if updates for the material been locked
  21236. */
  21237. readonly isFrozen: boolean;
  21238. /**
  21239. * Locks updates for the material
  21240. */
  21241. freeze(): void;
  21242. /**
  21243. * Unlocks updates for the material
  21244. */
  21245. unfreeze(): void;
  21246. /**
  21247. * Specifies if the material is ready to be used
  21248. * @param mesh defines the mesh to check
  21249. * @param useInstances specifies if instances should be used
  21250. * @returns a boolean indicating if the material is ready to be used
  21251. */
  21252. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21253. /**
  21254. * Specifies that the submesh is ready to be used
  21255. * @param mesh defines the mesh to check
  21256. * @param subMesh defines which submesh to check
  21257. * @param useInstances specifies that instances should be used
  21258. * @returns a boolean indicating that the submesh is ready or not
  21259. */
  21260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21261. /**
  21262. * Returns the material effect
  21263. * @returns the effect associated with the material
  21264. */
  21265. getEffect(): Nullable<Effect>;
  21266. /**
  21267. * Returns the current scene
  21268. * @returns a Scene
  21269. */
  21270. getScene(): Scene;
  21271. /**
  21272. * Specifies if the material will require alpha blending
  21273. * @returns a boolean specifying if alpha blending is needed
  21274. */
  21275. needAlphaBlending(): boolean;
  21276. /**
  21277. * Specifies if the mesh will require alpha blending
  21278. * @param mesh defines the mesh to check
  21279. * @returns a boolean specifying if alpha blending is needed for the mesh
  21280. */
  21281. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21282. /**
  21283. * Specifies if this material should be rendered in alpha test mode
  21284. * @returns a boolean specifying if an alpha test is needed.
  21285. */
  21286. needAlphaTesting(): boolean;
  21287. /**
  21288. * Gets the texture used for the alpha test
  21289. * @returns the texture to use for alpha testing
  21290. */
  21291. getAlphaTestTexture(): Nullable<BaseTexture>;
  21292. /**
  21293. * Marks the material to indicate that it needs to be re-calculated
  21294. */
  21295. markDirty(): void;
  21296. /** @hidden */
  21297. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21298. /**
  21299. * Binds the material to the mesh
  21300. * @param world defines the world transformation matrix
  21301. * @param mesh defines the mesh to bind the material to
  21302. */
  21303. bind(world: Matrix, mesh?: Mesh): void;
  21304. /**
  21305. * Binds the submesh to the material
  21306. * @param world defines the world transformation matrix
  21307. * @param mesh defines the mesh containing the submesh
  21308. * @param subMesh defines the submesh to bind the material to
  21309. */
  21310. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21311. /**
  21312. * Binds the world matrix to the material
  21313. * @param world defines the world transformation matrix
  21314. */
  21315. bindOnlyWorldMatrix(world: Matrix): void;
  21316. /**
  21317. * Binds the scene's uniform buffer to the effect.
  21318. * @param effect defines the effect to bind to the scene uniform buffer
  21319. * @param sceneUbo defines the uniform buffer storing scene data
  21320. */
  21321. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21322. /**
  21323. * Binds the view matrix to the effect
  21324. * @param effect defines the effect to bind the view matrix to
  21325. */
  21326. bindView(effect: Effect): void;
  21327. /**
  21328. * Binds the view projection matrix to the effect
  21329. * @param effect defines the effect to bind the view projection matrix to
  21330. */
  21331. bindViewProjection(effect: Effect): void;
  21332. /**
  21333. * Specifies if material alpha testing should be turned on for the mesh
  21334. * @param mesh defines the mesh to check
  21335. */
  21336. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21337. /**
  21338. * Processes to execute after binding the material to a mesh
  21339. * @param mesh defines the rendered mesh
  21340. */
  21341. protected _afterBind(mesh?: Mesh): void;
  21342. /**
  21343. * Unbinds the material from the mesh
  21344. */
  21345. unbind(): void;
  21346. /**
  21347. * Gets the active textures from the material
  21348. * @returns an array of textures
  21349. */
  21350. getActiveTextures(): BaseTexture[];
  21351. /**
  21352. * Specifies if the material uses a texture
  21353. * @param texture defines the texture to check against the material
  21354. * @returns a boolean specifying if the material uses the texture
  21355. */
  21356. hasTexture(texture: BaseTexture): boolean;
  21357. /**
  21358. * Makes a duplicate of the material, and gives it a new name
  21359. * @param name defines the new name for the duplicated material
  21360. * @returns the cloned material
  21361. */
  21362. clone(name: string): Nullable<Material>;
  21363. /**
  21364. * Gets the meshes bound to the material
  21365. * @returns an array of meshes bound to the material
  21366. */
  21367. getBindedMeshes(): AbstractMesh[];
  21368. /**
  21369. * Force shader compilation
  21370. * @param mesh defines the mesh associated with this material
  21371. * @param onCompiled defines a function to execute once the material is compiled
  21372. * @param options defines the options to configure the compilation
  21373. * @param onError defines a function to execute if the material fails compiling
  21374. */
  21375. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21376. /**
  21377. * Force shader compilation
  21378. * @param mesh defines the mesh that will use this material
  21379. * @param options defines additional options for compiling the shaders
  21380. * @returns a promise that resolves when the compilation completes
  21381. */
  21382. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21383. private static readonly _AllDirtyCallBack;
  21384. private static readonly _ImageProcessingDirtyCallBack;
  21385. private static readonly _TextureDirtyCallBack;
  21386. private static readonly _FresnelDirtyCallBack;
  21387. private static readonly _MiscDirtyCallBack;
  21388. private static readonly _LightsDirtyCallBack;
  21389. private static readonly _AttributeDirtyCallBack;
  21390. private static _FresnelAndMiscDirtyCallBack;
  21391. private static _TextureAndMiscDirtyCallBack;
  21392. private static readonly _DirtyCallbackArray;
  21393. private static readonly _RunDirtyCallBacks;
  21394. /**
  21395. * Marks a define in the material to indicate that it needs to be re-computed
  21396. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21397. */
  21398. markAsDirty(flag: number): void;
  21399. /**
  21400. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21401. * @param func defines a function which checks material defines against the submeshes
  21402. */
  21403. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21404. /**
  21405. * Indicates that we need to re-calculated for all submeshes
  21406. */
  21407. protected _markAllSubMeshesAsAllDirty(): void;
  21408. /**
  21409. * Indicates that image processing needs to be re-calculated for all submeshes
  21410. */
  21411. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21412. /**
  21413. * Indicates that textures need to be re-calculated for all submeshes
  21414. */
  21415. protected _markAllSubMeshesAsTexturesDirty(): void;
  21416. /**
  21417. * Indicates that fresnel needs to be re-calculated for all submeshes
  21418. */
  21419. protected _markAllSubMeshesAsFresnelDirty(): void;
  21420. /**
  21421. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21422. */
  21423. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21424. /**
  21425. * Indicates that lights need to be re-calculated for all submeshes
  21426. */
  21427. protected _markAllSubMeshesAsLightsDirty(): void;
  21428. /**
  21429. * Indicates that attributes need to be re-calculated for all submeshes
  21430. */
  21431. protected _markAllSubMeshesAsAttributesDirty(): void;
  21432. /**
  21433. * Indicates that misc needs to be re-calculated for all submeshes
  21434. */
  21435. protected _markAllSubMeshesAsMiscDirty(): void;
  21436. /**
  21437. * Indicates that textures and misc need to be re-calculated for all submeshes
  21438. */
  21439. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21440. /**
  21441. * Disposes the material
  21442. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21443. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21444. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21445. */
  21446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21447. /** @hidden */
  21448. private releaseVertexArrayObject;
  21449. /**
  21450. * Serializes this material
  21451. * @returns the serialized material object
  21452. */
  21453. serialize(): any;
  21454. /**
  21455. * Creates a material from parsed material data
  21456. * @param parsedMaterial defines parsed material data
  21457. * @param scene defines the hosting scene
  21458. * @param rootUrl defines the root URL to use to load textures
  21459. * @returns a new material
  21460. */
  21461. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21462. }
  21463. }
  21464. declare module "babylonjs/Materials/multiMaterial" {
  21465. import { Nullable } from "babylonjs/types";
  21466. import { Scene } from "babylonjs/scene";
  21467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21468. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21470. import { Material } from "babylonjs/Materials/material";
  21471. /**
  21472. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21473. * separate meshes. This can be use to improve performances.
  21474. * @see http://doc.babylonjs.com/how_to/multi_materials
  21475. */
  21476. export class MultiMaterial extends Material {
  21477. private _subMaterials;
  21478. /**
  21479. * Gets or Sets the list of Materials used within the multi material.
  21480. * They need to be ordered according to the submeshes order in the associated mesh
  21481. */
  21482. subMaterials: Nullable<Material>[];
  21483. /**
  21484. * Function used to align with Node.getChildren()
  21485. * @returns the list of Materials used within the multi material
  21486. */
  21487. getChildren(): Nullable<Material>[];
  21488. /**
  21489. * Instantiates a new Multi Material
  21490. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21491. * separate meshes. This can be use to improve performances.
  21492. * @see http://doc.babylonjs.com/how_to/multi_materials
  21493. * @param name Define the name in the scene
  21494. * @param scene Define the scene the material belongs to
  21495. */
  21496. constructor(name: string, scene: Scene);
  21497. private _hookArray;
  21498. /**
  21499. * Get one of the submaterial by its index in the submaterials array
  21500. * @param index The index to look the sub material at
  21501. * @returns The Material if the index has been defined
  21502. */
  21503. getSubMaterial(index: number): Nullable<Material>;
  21504. /**
  21505. * Get the list of active textures for the whole sub materials list.
  21506. * @returns All the textures that will be used during the rendering
  21507. */
  21508. getActiveTextures(): BaseTexture[];
  21509. /**
  21510. * Gets the current class name of the material e.g. "MultiMaterial"
  21511. * Mainly use in serialization.
  21512. * @returns the class name
  21513. */
  21514. getClassName(): string;
  21515. /**
  21516. * Checks if the material is ready to render the requested sub mesh
  21517. * @param mesh Define the mesh the submesh belongs to
  21518. * @param subMesh Define the sub mesh to look readyness for
  21519. * @param useInstances Define whether or not the material is used with instances
  21520. * @returns true if ready, otherwise false
  21521. */
  21522. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21523. /**
  21524. * Clones the current material and its related sub materials
  21525. * @param name Define the name of the newly cloned material
  21526. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21527. * @returns the cloned material
  21528. */
  21529. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21530. /**
  21531. * Serializes the materials into a JSON representation.
  21532. * @returns the JSON representation
  21533. */
  21534. serialize(): any;
  21535. /**
  21536. * Dispose the material and release its associated resources
  21537. * @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)
  21538. * @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)
  21539. * @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)
  21540. */
  21541. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21542. /**
  21543. * Creates a MultiMaterial from parsed MultiMaterial data.
  21544. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21545. * @param scene defines the hosting scene
  21546. * @returns a new MultiMaterial
  21547. */
  21548. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21549. }
  21550. }
  21551. declare module "babylonjs/Meshes/subMesh" {
  21552. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21553. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21554. import { Engine } from "babylonjs/Engines/engine";
  21555. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21556. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21557. import { Effect } from "babylonjs/Materials/effect";
  21558. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21559. import { Plane } from "babylonjs/Maths/math.plane";
  21560. import { Collider } from "babylonjs/Collisions/collider";
  21561. import { Material } from "babylonjs/Materials/material";
  21562. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21564. import { Mesh } from "babylonjs/Meshes/mesh";
  21565. import { Ray } from "babylonjs/Culling/ray";
  21566. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21567. /**
  21568. * Base class for submeshes
  21569. */
  21570. export class BaseSubMesh {
  21571. /** @hidden */
  21572. _materialDefines: Nullable<MaterialDefines>;
  21573. /** @hidden */
  21574. _materialEffect: Nullable<Effect>;
  21575. /**
  21576. * Gets associated effect
  21577. */
  21578. readonly effect: Nullable<Effect>;
  21579. /**
  21580. * Sets associated effect (effect used to render this submesh)
  21581. * @param effect defines the effect to associate with
  21582. * @param defines defines the set of defines used to compile this effect
  21583. */
  21584. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21585. }
  21586. /**
  21587. * Defines a subdivision inside a mesh
  21588. */
  21589. export class SubMesh extends BaseSubMesh implements ICullable {
  21590. /** the material index to use */
  21591. materialIndex: number;
  21592. /** vertex index start */
  21593. verticesStart: number;
  21594. /** vertices count */
  21595. verticesCount: number;
  21596. /** index start */
  21597. indexStart: number;
  21598. /** indices count */
  21599. indexCount: number;
  21600. /** @hidden */
  21601. _linesIndexCount: number;
  21602. private _mesh;
  21603. private _renderingMesh;
  21604. private _boundingInfo;
  21605. private _linesIndexBuffer;
  21606. /** @hidden */
  21607. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21608. /** @hidden */
  21609. _trianglePlanes: Plane[];
  21610. /** @hidden */
  21611. _lastColliderTransformMatrix: Nullable<Matrix>;
  21612. /** @hidden */
  21613. _renderId: number;
  21614. /** @hidden */
  21615. _alphaIndex: number;
  21616. /** @hidden */
  21617. _distanceToCamera: number;
  21618. /** @hidden */
  21619. _id: number;
  21620. private _currentMaterial;
  21621. /**
  21622. * Add a new submesh to a mesh
  21623. * @param materialIndex defines the material index to use
  21624. * @param verticesStart defines vertex index start
  21625. * @param verticesCount defines vertices count
  21626. * @param indexStart defines index start
  21627. * @param indexCount defines indices count
  21628. * @param mesh defines the parent mesh
  21629. * @param renderingMesh defines an optional rendering mesh
  21630. * @param createBoundingBox defines if bounding box should be created for this submesh
  21631. * @returns the new submesh
  21632. */
  21633. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21634. /**
  21635. * Creates a new submesh
  21636. * @param materialIndex defines the material index to use
  21637. * @param verticesStart defines vertex index start
  21638. * @param verticesCount defines vertices count
  21639. * @param indexStart defines index start
  21640. * @param indexCount defines indices count
  21641. * @param mesh defines the parent mesh
  21642. * @param renderingMesh defines an optional rendering mesh
  21643. * @param createBoundingBox defines if bounding box should be created for this submesh
  21644. */
  21645. constructor(
  21646. /** the material index to use */
  21647. materialIndex: number,
  21648. /** vertex index start */
  21649. verticesStart: number,
  21650. /** vertices count */
  21651. verticesCount: number,
  21652. /** index start */
  21653. indexStart: number,
  21654. /** indices count */
  21655. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21656. /**
  21657. * Returns true if this submesh covers the entire parent mesh
  21658. * @ignorenaming
  21659. */
  21660. readonly IsGlobal: boolean;
  21661. /**
  21662. * Returns the submesh BoudingInfo object
  21663. * @returns current bounding info (or mesh's one if the submesh is global)
  21664. */
  21665. getBoundingInfo(): BoundingInfo;
  21666. /**
  21667. * Sets the submesh BoundingInfo
  21668. * @param boundingInfo defines the new bounding info to use
  21669. * @returns the SubMesh
  21670. */
  21671. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21672. /**
  21673. * Returns the mesh of the current submesh
  21674. * @return the parent mesh
  21675. */
  21676. getMesh(): AbstractMesh;
  21677. /**
  21678. * Returns the rendering mesh of the submesh
  21679. * @returns the rendering mesh (could be different from parent mesh)
  21680. */
  21681. getRenderingMesh(): Mesh;
  21682. /**
  21683. * Returns the submesh material
  21684. * @returns null or the current material
  21685. */
  21686. getMaterial(): Nullable<Material>;
  21687. /**
  21688. * Sets a new updated BoundingInfo object to the submesh
  21689. * @param data defines an optional position array to use to determine the bounding info
  21690. * @returns the SubMesh
  21691. */
  21692. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21693. /** @hidden */
  21694. _checkCollision(collider: Collider): boolean;
  21695. /**
  21696. * Updates the submesh BoundingInfo
  21697. * @param world defines the world matrix to use to update the bounding info
  21698. * @returns the submesh
  21699. */
  21700. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21701. /**
  21702. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21703. * @param frustumPlanes defines the frustum planes
  21704. * @returns true if the submesh is intersecting with the frustum
  21705. */
  21706. isInFrustum(frustumPlanes: Plane[]): boolean;
  21707. /**
  21708. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21709. * @param frustumPlanes defines the frustum planes
  21710. * @returns true if the submesh is inside the frustum
  21711. */
  21712. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21713. /**
  21714. * Renders the submesh
  21715. * @param enableAlphaMode defines if alpha needs to be used
  21716. * @returns the submesh
  21717. */
  21718. render(enableAlphaMode: boolean): SubMesh;
  21719. /**
  21720. * @hidden
  21721. */
  21722. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21723. /**
  21724. * Checks if the submesh intersects with a ray
  21725. * @param ray defines the ray to test
  21726. * @returns true is the passed ray intersects the submesh bounding box
  21727. */
  21728. canIntersects(ray: Ray): boolean;
  21729. /**
  21730. * Intersects current submesh with a ray
  21731. * @param ray defines the ray to test
  21732. * @param positions defines mesh's positions array
  21733. * @param indices defines mesh's indices array
  21734. * @param fastCheck defines if only bounding info should be used
  21735. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21736. * @returns intersection info or null if no intersection
  21737. */
  21738. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21739. /** @hidden */
  21740. private _intersectLines;
  21741. /** @hidden */
  21742. private _intersectUnIndexedLines;
  21743. /** @hidden */
  21744. private _intersectTriangles;
  21745. /** @hidden */
  21746. private _intersectUnIndexedTriangles;
  21747. /** @hidden */
  21748. _rebuild(): void;
  21749. /**
  21750. * Creates a new submesh from the passed mesh
  21751. * @param newMesh defines the new hosting mesh
  21752. * @param newRenderingMesh defines an optional rendering mesh
  21753. * @returns the new submesh
  21754. */
  21755. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21756. /**
  21757. * Release associated resources
  21758. */
  21759. dispose(): void;
  21760. /**
  21761. * Gets the class name
  21762. * @returns the string "SubMesh".
  21763. */
  21764. getClassName(): string;
  21765. /**
  21766. * Creates a new submesh from indices data
  21767. * @param materialIndex the index of the main mesh material
  21768. * @param startIndex the index where to start the copy in the mesh indices array
  21769. * @param indexCount the number of indices to copy then from the startIndex
  21770. * @param mesh the main mesh to create the submesh from
  21771. * @param renderingMesh the optional rendering mesh
  21772. * @returns a new submesh
  21773. */
  21774. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21775. }
  21776. }
  21777. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21778. /**
  21779. * Class used to represent data loading progression
  21780. */
  21781. export class SceneLoaderFlags {
  21782. private static _ForceFullSceneLoadingForIncremental;
  21783. private static _ShowLoadingScreen;
  21784. private static _CleanBoneMatrixWeights;
  21785. private static _loggingLevel;
  21786. /**
  21787. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21788. */
  21789. static ForceFullSceneLoadingForIncremental: boolean;
  21790. /**
  21791. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21792. */
  21793. static ShowLoadingScreen: boolean;
  21794. /**
  21795. * Defines the current logging level (while loading the scene)
  21796. * @ignorenaming
  21797. */
  21798. static loggingLevel: number;
  21799. /**
  21800. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21801. */
  21802. static CleanBoneMatrixWeights: boolean;
  21803. }
  21804. }
  21805. declare module "babylonjs/Meshes/geometry" {
  21806. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21807. import { Scene } from "babylonjs/scene";
  21808. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21809. import { Engine } from "babylonjs/Engines/engine";
  21810. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21811. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21812. import { Effect } from "babylonjs/Materials/effect";
  21813. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21814. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21815. import { Mesh } from "babylonjs/Meshes/mesh";
  21816. /**
  21817. * Class used to store geometry data (vertex buffers + index buffer)
  21818. */
  21819. export class Geometry implements IGetSetVerticesData {
  21820. /**
  21821. * Gets or sets the ID of the geometry
  21822. */
  21823. id: string;
  21824. /**
  21825. * Gets or sets the unique ID of the geometry
  21826. */
  21827. uniqueId: number;
  21828. /**
  21829. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21830. */
  21831. delayLoadState: number;
  21832. /**
  21833. * Gets the file containing the data to load when running in delay load state
  21834. */
  21835. delayLoadingFile: Nullable<string>;
  21836. /**
  21837. * Callback called when the geometry is updated
  21838. */
  21839. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21840. private _scene;
  21841. private _engine;
  21842. private _meshes;
  21843. private _totalVertices;
  21844. /** @hidden */
  21845. _indices: IndicesArray;
  21846. /** @hidden */
  21847. _vertexBuffers: {
  21848. [key: string]: VertexBuffer;
  21849. };
  21850. private _isDisposed;
  21851. private _extend;
  21852. private _boundingBias;
  21853. /** @hidden */
  21854. _delayInfo: Array<string>;
  21855. private _indexBuffer;
  21856. private _indexBufferIsUpdatable;
  21857. /** @hidden */
  21858. _boundingInfo: Nullable<BoundingInfo>;
  21859. /** @hidden */
  21860. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21861. /** @hidden */
  21862. _softwareSkinningFrameId: number;
  21863. private _vertexArrayObjects;
  21864. private _updatable;
  21865. /** @hidden */
  21866. _positions: Nullable<Vector3[]>;
  21867. /**
  21868. * 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
  21869. */
  21870. /**
  21871. * 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
  21872. */
  21873. boundingBias: Vector2;
  21874. /**
  21875. * Static function used to attach a new empty geometry to a mesh
  21876. * @param mesh defines the mesh to attach the geometry to
  21877. * @returns the new Geometry
  21878. */
  21879. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21880. /**
  21881. * Creates a new geometry
  21882. * @param id defines the unique ID
  21883. * @param scene defines the hosting scene
  21884. * @param vertexData defines the VertexData used to get geometry data
  21885. * @param updatable defines if geometry must be updatable (false by default)
  21886. * @param mesh defines the mesh that will be associated with the geometry
  21887. */
  21888. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21889. /**
  21890. * Gets the current extend of the geometry
  21891. */
  21892. readonly extend: {
  21893. minimum: Vector3;
  21894. maximum: Vector3;
  21895. };
  21896. /**
  21897. * Gets the hosting scene
  21898. * @returns the hosting Scene
  21899. */
  21900. getScene(): Scene;
  21901. /**
  21902. * Gets the hosting engine
  21903. * @returns the hosting Engine
  21904. */
  21905. getEngine(): Engine;
  21906. /**
  21907. * Defines if the geometry is ready to use
  21908. * @returns true if the geometry is ready to be used
  21909. */
  21910. isReady(): boolean;
  21911. /**
  21912. * Gets a value indicating that the geometry should not be serialized
  21913. */
  21914. readonly doNotSerialize: boolean;
  21915. /** @hidden */
  21916. _rebuild(): void;
  21917. /**
  21918. * Affects all geometry data in one call
  21919. * @param vertexData defines the geometry data
  21920. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21921. */
  21922. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21923. /**
  21924. * Set specific vertex data
  21925. * @param kind defines the data kind (Position, normal, etc...)
  21926. * @param data defines the vertex data to use
  21927. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21928. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21929. */
  21930. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21931. /**
  21932. * Removes a specific vertex data
  21933. * @param kind defines the data kind (Position, normal, etc...)
  21934. */
  21935. removeVerticesData(kind: string): void;
  21936. /**
  21937. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21938. * @param buffer defines the vertex buffer to use
  21939. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21940. */
  21941. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21942. /**
  21943. * Update a specific vertex buffer
  21944. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21945. * It will do nothing if the buffer is not updatable
  21946. * @param kind defines the data kind (Position, normal, etc...)
  21947. * @param data defines the data to use
  21948. * @param offset defines the offset in the target buffer where to store the data
  21949. * @param useBytes set to true if the offset is in bytes
  21950. */
  21951. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21952. /**
  21953. * Update a specific vertex buffer
  21954. * This function will create a new buffer if the current one is not updatable
  21955. * @param kind defines the data kind (Position, normal, etc...)
  21956. * @param data defines the data to use
  21957. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21958. */
  21959. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21960. private _updateBoundingInfo;
  21961. /** @hidden */
  21962. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21963. /**
  21964. * Gets total number of vertices
  21965. * @returns the total number of vertices
  21966. */
  21967. getTotalVertices(): number;
  21968. /**
  21969. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21970. * @param kind defines the data kind (Position, normal, etc...)
  21971. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21972. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21973. * @returns a float array containing vertex data
  21974. */
  21975. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21976. /**
  21977. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21978. * @param kind defines the data kind (Position, normal, etc...)
  21979. * @returns true if the vertex buffer with the specified kind is updatable
  21980. */
  21981. isVertexBufferUpdatable(kind: string): boolean;
  21982. /**
  21983. * Gets a specific vertex buffer
  21984. * @param kind defines the data kind (Position, normal, etc...)
  21985. * @returns a VertexBuffer
  21986. */
  21987. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21988. /**
  21989. * Returns all vertex buffers
  21990. * @return an object holding all vertex buffers indexed by kind
  21991. */
  21992. getVertexBuffers(): Nullable<{
  21993. [key: string]: VertexBuffer;
  21994. }>;
  21995. /**
  21996. * Gets a boolean indicating if specific vertex buffer is present
  21997. * @param kind defines the data kind (Position, normal, etc...)
  21998. * @returns true if data is present
  21999. */
  22000. isVerticesDataPresent(kind: string): boolean;
  22001. /**
  22002. * Gets a list of all attached data kinds (Position, normal, etc...)
  22003. * @returns a list of string containing all kinds
  22004. */
  22005. getVerticesDataKinds(): string[];
  22006. /**
  22007. * Update index buffer
  22008. * @param indices defines the indices to store in the index buffer
  22009. * @param offset defines the offset in the target buffer where to store the data
  22010. * @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)
  22011. */
  22012. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22013. /**
  22014. * Creates a new index buffer
  22015. * @param indices defines the indices to store in the index buffer
  22016. * @param totalVertices defines the total number of vertices (could be null)
  22017. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22018. */
  22019. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22020. /**
  22021. * Return the total number of indices
  22022. * @returns the total number of indices
  22023. */
  22024. getTotalIndices(): number;
  22025. /**
  22026. * Gets the index buffer array
  22027. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22028. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22029. * @returns the index buffer array
  22030. */
  22031. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22032. /**
  22033. * Gets the index buffer
  22034. * @return the index buffer
  22035. */
  22036. getIndexBuffer(): Nullable<DataBuffer>;
  22037. /** @hidden */
  22038. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22039. /**
  22040. * Release the associated resources for a specific mesh
  22041. * @param mesh defines the source mesh
  22042. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22043. */
  22044. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22045. /**
  22046. * Apply current geometry to a given mesh
  22047. * @param mesh defines the mesh to apply geometry to
  22048. */
  22049. applyToMesh(mesh: Mesh): void;
  22050. private _updateExtend;
  22051. private _applyToMesh;
  22052. private notifyUpdate;
  22053. /**
  22054. * Load the geometry if it was flagged as delay loaded
  22055. * @param scene defines the hosting scene
  22056. * @param onLoaded defines a callback called when the geometry is loaded
  22057. */
  22058. load(scene: Scene, onLoaded?: () => void): void;
  22059. private _queueLoad;
  22060. /**
  22061. * Invert the geometry to move from a right handed system to a left handed one.
  22062. */
  22063. toLeftHanded(): void;
  22064. /** @hidden */
  22065. _resetPointsArrayCache(): void;
  22066. /** @hidden */
  22067. _generatePointsArray(): boolean;
  22068. /**
  22069. * Gets a value indicating if the geometry is disposed
  22070. * @returns true if the geometry was disposed
  22071. */
  22072. isDisposed(): boolean;
  22073. private _disposeVertexArrayObjects;
  22074. /**
  22075. * Free all associated resources
  22076. */
  22077. dispose(): void;
  22078. /**
  22079. * Clone the current geometry into a new geometry
  22080. * @param id defines the unique ID of the new geometry
  22081. * @returns a new geometry object
  22082. */
  22083. copy(id: string): Geometry;
  22084. /**
  22085. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22086. * @return a JSON representation of the current geometry data (without the vertices data)
  22087. */
  22088. serialize(): any;
  22089. private toNumberArray;
  22090. /**
  22091. * Serialize all vertices data into a JSON oject
  22092. * @returns a JSON representation of the current geometry data
  22093. */
  22094. serializeVerticeData(): any;
  22095. /**
  22096. * Extracts a clone of a mesh geometry
  22097. * @param mesh defines the source mesh
  22098. * @param id defines the unique ID of the new geometry object
  22099. * @returns the new geometry object
  22100. */
  22101. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22102. /**
  22103. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22104. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22105. * Be aware Math.random() could cause collisions, but:
  22106. * "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"
  22107. * @returns a string containing a new GUID
  22108. */
  22109. static RandomId(): string;
  22110. /** @hidden */
  22111. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22112. private static _CleanMatricesWeights;
  22113. /**
  22114. * Create a new geometry from persisted data (Using .babylon file format)
  22115. * @param parsedVertexData defines the persisted data
  22116. * @param scene defines the hosting scene
  22117. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22118. * @returns the new geometry object
  22119. */
  22120. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22121. }
  22122. }
  22123. declare module "babylonjs/Meshes/mesh.vertexData" {
  22124. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22125. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22126. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22127. import { Geometry } from "babylonjs/Meshes/geometry";
  22128. import { Mesh } from "babylonjs/Meshes/mesh";
  22129. /**
  22130. * Define an interface for all classes that will get and set the data on vertices
  22131. */
  22132. export interface IGetSetVerticesData {
  22133. /**
  22134. * Gets a boolean indicating if specific vertex data is present
  22135. * @param kind defines the vertex data kind to use
  22136. * @returns true is data kind is present
  22137. */
  22138. isVerticesDataPresent(kind: string): boolean;
  22139. /**
  22140. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22141. * @param kind defines the data kind (Position, normal, etc...)
  22142. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22143. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22144. * @returns a float array containing vertex data
  22145. */
  22146. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22147. /**
  22148. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22149. * @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.
  22150. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22151. * @returns the indices array or an empty array if the mesh has no geometry
  22152. */
  22153. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22154. /**
  22155. * Set specific vertex data
  22156. * @param kind defines the data kind (Position, normal, etc...)
  22157. * @param data defines the vertex data to use
  22158. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22159. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22160. */
  22161. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22162. /**
  22163. * Update a specific associated vertex buffer
  22164. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22165. * - VertexBuffer.PositionKind
  22166. * - VertexBuffer.UVKind
  22167. * - VertexBuffer.UV2Kind
  22168. * - VertexBuffer.UV3Kind
  22169. * - VertexBuffer.UV4Kind
  22170. * - VertexBuffer.UV5Kind
  22171. * - VertexBuffer.UV6Kind
  22172. * - VertexBuffer.ColorKind
  22173. * - VertexBuffer.MatricesIndicesKind
  22174. * - VertexBuffer.MatricesIndicesExtraKind
  22175. * - VertexBuffer.MatricesWeightsKind
  22176. * - VertexBuffer.MatricesWeightsExtraKind
  22177. * @param data defines the data source
  22178. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22179. * @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)
  22180. */
  22181. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22182. /**
  22183. * Creates a new index buffer
  22184. * @param indices defines the indices to store in the index buffer
  22185. * @param totalVertices defines the total number of vertices (could be null)
  22186. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22187. */
  22188. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22189. }
  22190. /**
  22191. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22192. */
  22193. export class VertexData {
  22194. /**
  22195. * Mesh side orientation : usually the external or front surface
  22196. */
  22197. static readonly FRONTSIDE: number;
  22198. /**
  22199. * Mesh side orientation : usually the internal or back surface
  22200. */
  22201. static readonly BACKSIDE: number;
  22202. /**
  22203. * Mesh side orientation : both internal and external or front and back surfaces
  22204. */
  22205. static readonly DOUBLESIDE: number;
  22206. /**
  22207. * Mesh side orientation : by default, `FRONTSIDE`
  22208. */
  22209. static readonly DEFAULTSIDE: number;
  22210. /**
  22211. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22212. */
  22213. positions: Nullable<FloatArray>;
  22214. /**
  22215. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22216. */
  22217. normals: Nullable<FloatArray>;
  22218. /**
  22219. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22220. */
  22221. tangents: Nullable<FloatArray>;
  22222. /**
  22223. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22224. */
  22225. uvs: Nullable<FloatArray>;
  22226. /**
  22227. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22228. */
  22229. uvs2: Nullable<FloatArray>;
  22230. /**
  22231. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22232. */
  22233. uvs3: Nullable<FloatArray>;
  22234. /**
  22235. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22236. */
  22237. uvs4: Nullable<FloatArray>;
  22238. /**
  22239. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22240. */
  22241. uvs5: Nullable<FloatArray>;
  22242. /**
  22243. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22244. */
  22245. uvs6: Nullable<FloatArray>;
  22246. /**
  22247. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22248. */
  22249. colors: Nullable<FloatArray>;
  22250. /**
  22251. * 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).
  22252. */
  22253. matricesIndices: Nullable<FloatArray>;
  22254. /**
  22255. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22256. */
  22257. matricesWeights: Nullable<FloatArray>;
  22258. /**
  22259. * An array extending the number of possible indices
  22260. */
  22261. matricesIndicesExtra: Nullable<FloatArray>;
  22262. /**
  22263. * An array extending the number of possible weights when the number of indices is extended
  22264. */
  22265. matricesWeightsExtra: Nullable<FloatArray>;
  22266. /**
  22267. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22268. */
  22269. indices: Nullable<IndicesArray>;
  22270. /**
  22271. * Uses the passed data array to set the set the values for the specified kind of data
  22272. * @param data a linear array of floating numbers
  22273. * @param kind the type of data that is being set, eg positions, colors etc
  22274. */
  22275. set(data: FloatArray, kind: string): void;
  22276. /**
  22277. * Associates the vertexData to the passed Mesh.
  22278. * Sets it as updatable or not (default `false`)
  22279. * @param mesh the mesh the vertexData is applied to
  22280. * @param updatable when used and having the value true allows new data to update the vertexData
  22281. * @returns the VertexData
  22282. */
  22283. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22284. /**
  22285. * Associates the vertexData to the passed Geometry.
  22286. * Sets it as updatable or not (default `false`)
  22287. * @param geometry the geometry the vertexData is applied to
  22288. * @param updatable when used and having the value true allows new data to update the vertexData
  22289. * @returns VertexData
  22290. */
  22291. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22292. /**
  22293. * Updates the associated mesh
  22294. * @param mesh the mesh to be updated
  22295. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22296. * @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
  22297. * @returns VertexData
  22298. */
  22299. updateMesh(mesh: Mesh): VertexData;
  22300. /**
  22301. * Updates the associated geometry
  22302. * @param geometry the geometry to be updated
  22303. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22304. * @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
  22305. * @returns VertexData.
  22306. */
  22307. updateGeometry(geometry: Geometry): VertexData;
  22308. private _applyTo;
  22309. private _update;
  22310. /**
  22311. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22312. * @param matrix the transforming matrix
  22313. * @returns the VertexData
  22314. */
  22315. transform(matrix: Matrix): VertexData;
  22316. /**
  22317. * Merges the passed VertexData into the current one
  22318. * @param other the VertexData to be merged into the current one
  22319. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22320. * @returns the modified VertexData
  22321. */
  22322. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22323. private _mergeElement;
  22324. private _validate;
  22325. /**
  22326. * Serializes the VertexData
  22327. * @returns a serialized object
  22328. */
  22329. serialize(): any;
  22330. /**
  22331. * Extracts the vertexData from a mesh
  22332. * @param mesh the mesh from which to extract the VertexData
  22333. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22334. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22335. * @returns the object VertexData associated to the passed mesh
  22336. */
  22337. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22338. /**
  22339. * Extracts the vertexData from the geometry
  22340. * @param geometry the geometry from which to extract the VertexData
  22341. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22342. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22343. * @returns the object VertexData associated to the passed mesh
  22344. */
  22345. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22346. private static _ExtractFrom;
  22347. /**
  22348. * Creates the VertexData for a Ribbon
  22349. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22350. * * pathArray array of paths, each of which an array of successive Vector3
  22351. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22352. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22353. * * 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
  22354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22355. * * 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)
  22356. * * 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)
  22357. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22358. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22359. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22360. * @returns the VertexData of the ribbon
  22361. */
  22362. static CreateRibbon(options: {
  22363. pathArray: Vector3[][];
  22364. closeArray?: boolean;
  22365. closePath?: boolean;
  22366. offset?: number;
  22367. sideOrientation?: number;
  22368. frontUVs?: Vector4;
  22369. backUVs?: Vector4;
  22370. invertUV?: boolean;
  22371. uvs?: Vector2[];
  22372. colors?: Color4[];
  22373. }): VertexData;
  22374. /**
  22375. * Creates the VertexData for a box
  22376. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22377. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22378. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22379. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22380. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22381. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22382. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22383. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22384. * * 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)
  22385. * * 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)
  22386. * @returns the VertexData of the box
  22387. */
  22388. static CreateBox(options: {
  22389. size?: number;
  22390. width?: number;
  22391. height?: number;
  22392. depth?: number;
  22393. faceUV?: Vector4[];
  22394. faceColors?: Color4[];
  22395. sideOrientation?: number;
  22396. frontUVs?: Vector4;
  22397. backUVs?: Vector4;
  22398. }): VertexData;
  22399. /**
  22400. * Creates the VertexData for a tiled box
  22401. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22402. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22403. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22404. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22405. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22406. * @returns the VertexData of the box
  22407. */
  22408. static CreateTiledBox(options: {
  22409. pattern?: number;
  22410. width?: number;
  22411. height?: number;
  22412. depth?: number;
  22413. tileSize?: number;
  22414. tileWidth?: number;
  22415. tileHeight?: number;
  22416. alignHorizontal?: number;
  22417. alignVertical?: number;
  22418. faceUV?: Vector4[];
  22419. faceColors?: Color4[];
  22420. sideOrientation?: number;
  22421. }): VertexData;
  22422. /**
  22423. * Creates the VertexData for a tiled plane
  22424. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22425. * * pattern a limited pattern arrangement depending on the number
  22426. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22427. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22428. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22430. * * 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)
  22431. * * 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)
  22432. * @returns the VertexData of the tiled plane
  22433. */
  22434. static CreateTiledPlane(options: {
  22435. pattern?: number;
  22436. tileSize?: number;
  22437. tileWidth?: number;
  22438. tileHeight?: number;
  22439. size?: number;
  22440. width?: number;
  22441. height?: number;
  22442. alignHorizontal?: number;
  22443. alignVertical?: number;
  22444. sideOrientation?: number;
  22445. frontUVs?: Vector4;
  22446. backUVs?: Vector4;
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22450. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22451. * * segments sets the number of horizontal strips optional, default 32
  22452. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22453. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22454. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22455. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22456. * * 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
  22457. * * 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
  22458. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22459. * * 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)
  22460. * * 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)
  22461. * @returns the VertexData of the ellipsoid
  22462. */
  22463. static CreateSphere(options: {
  22464. segments?: number;
  22465. diameter?: number;
  22466. diameterX?: number;
  22467. diameterY?: number;
  22468. diameterZ?: number;
  22469. arc?: number;
  22470. slice?: number;
  22471. sideOrientation?: number;
  22472. frontUVs?: Vector4;
  22473. backUVs?: Vector4;
  22474. }): VertexData;
  22475. /**
  22476. * Creates the VertexData for a cylinder, cone or prism
  22477. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22478. * * height sets the height (y direction) of the cylinder, optional, default 2
  22479. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22480. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22481. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22482. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22483. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22484. * * 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
  22485. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22486. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22487. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22488. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22490. * * 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)
  22491. * * 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)
  22492. * @returns the VertexData of the cylinder, cone or prism
  22493. */
  22494. static CreateCylinder(options: {
  22495. height?: number;
  22496. diameterTop?: number;
  22497. diameterBottom?: number;
  22498. diameter?: number;
  22499. tessellation?: number;
  22500. subdivisions?: number;
  22501. arc?: number;
  22502. faceColors?: Color4[];
  22503. faceUV?: Vector4[];
  22504. hasRings?: boolean;
  22505. enclose?: boolean;
  22506. sideOrientation?: number;
  22507. frontUVs?: Vector4;
  22508. backUVs?: Vector4;
  22509. }): VertexData;
  22510. /**
  22511. * Creates the VertexData for a torus
  22512. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22513. * * diameter the diameter of the torus, optional default 1
  22514. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22515. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22517. * * 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)
  22518. * * 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)
  22519. * @returns the VertexData of the torus
  22520. */
  22521. static CreateTorus(options: {
  22522. diameter?: number;
  22523. thickness?: number;
  22524. tessellation?: number;
  22525. sideOrientation?: number;
  22526. frontUVs?: Vector4;
  22527. backUVs?: Vector4;
  22528. }): VertexData;
  22529. /**
  22530. * Creates the VertexData of the LineSystem
  22531. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22532. * - lines an array of lines, each line being an array of successive Vector3
  22533. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22534. * @returns the VertexData of the LineSystem
  22535. */
  22536. static CreateLineSystem(options: {
  22537. lines: Vector3[][];
  22538. colors?: Nullable<Color4[][]>;
  22539. }): VertexData;
  22540. /**
  22541. * Create the VertexData for a DashedLines
  22542. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22543. * - points an array successive Vector3
  22544. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22545. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22546. * - dashNb the intended total number of dashes, optional, default 200
  22547. * @returns the VertexData for the DashedLines
  22548. */
  22549. static CreateDashedLines(options: {
  22550. points: Vector3[];
  22551. dashSize?: number;
  22552. gapSize?: number;
  22553. dashNb?: number;
  22554. }): VertexData;
  22555. /**
  22556. * Creates the VertexData for a Ground
  22557. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22558. * - width the width (x direction) of the ground, optional, default 1
  22559. * - height the height (z direction) of the ground, optional, default 1
  22560. * - subdivisions the number of subdivisions per side, optional, default 1
  22561. * @returns the VertexData of the Ground
  22562. */
  22563. static CreateGround(options: {
  22564. width?: number;
  22565. height?: number;
  22566. subdivisions?: number;
  22567. subdivisionsX?: number;
  22568. subdivisionsY?: number;
  22569. }): VertexData;
  22570. /**
  22571. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22572. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22573. * * xmin the ground minimum X coordinate, optional, default -1
  22574. * * zmin the ground minimum Z coordinate, optional, default -1
  22575. * * xmax the ground maximum X coordinate, optional, default 1
  22576. * * zmax the ground maximum Z coordinate, optional, default 1
  22577. * * 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}
  22578. * * 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}
  22579. * @returns the VertexData of the TiledGround
  22580. */
  22581. static CreateTiledGround(options: {
  22582. xmin: number;
  22583. zmin: number;
  22584. xmax: number;
  22585. zmax: number;
  22586. subdivisions?: {
  22587. w: number;
  22588. h: number;
  22589. };
  22590. precision?: {
  22591. w: number;
  22592. h: number;
  22593. };
  22594. }): VertexData;
  22595. /**
  22596. * Creates the VertexData of the Ground designed from a heightmap
  22597. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22598. * * width the width (x direction) of the ground
  22599. * * height the height (z direction) of the ground
  22600. * * subdivisions the number of subdivisions per side
  22601. * * minHeight the minimum altitude on the ground, optional, default 0
  22602. * * maxHeight the maximum altitude on the ground, optional default 1
  22603. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22604. * * buffer the array holding the image color data
  22605. * * bufferWidth the width of image
  22606. * * bufferHeight the height of image
  22607. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22608. * @returns the VertexData of the Ground designed from a heightmap
  22609. */
  22610. static CreateGroundFromHeightMap(options: {
  22611. width: number;
  22612. height: number;
  22613. subdivisions: number;
  22614. minHeight: number;
  22615. maxHeight: number;
  22616. colorFilter: Color3;
  22617. buffer: Uint8Array;
  22618. bufferWidth: number;
  22619. bufferHeight: number;
  22620. alphaFilter: number;
  22621. }): VertexData;
  22622. /**
  22623. * Creates the VertexData for a Plane
  22624. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22625. * * size sets the width and height of the plane to the value of size, optional default 1
  22626. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22627. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22628. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22629. * * 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)
  22630. * * 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)
  22631. * @returns the VertexData of the box
  22632. */
  22633. static CreatePlane(options: {
  22634. size?: number;
  22635. width?: number;
  22636. height?: number;
  22637. sideOrientation?: number;
  22638. frontUVs?: Vector4;
  22639. backUVs?: Vector4;
  22640. }): VertexData;
  22641. /**
  22642. * Creates the VertexData of the Disc or regular Polygon
  22643. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22644. * * radius the radius of the disc, optional default 0.5
  22645. * * tessellation the number of polygon sides, optional, default 64
  22646. * * 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
  22647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22648. * * 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)
  22649. * * 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)
  22650. * @returns the VertexData of the box
  22651. */
  22652. static CreateDisc(options: {
  22653. radius?: number;
  22654. tessellation?: number;
  22655. arc?: number;
  22656. sideOrientation?: number;
  22657. frontUVs?: Vector4;
  22658. backUVs?: Vector4;
  22659. }): VertexData;
  22660. /**
  22661. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22662. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22663. * @param polygon a mesh built from polygonTriangulation.build()
  22664. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22665. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22666. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22667. * @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)
  22668. * @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)
  22669. * @returns the VertexData of the Polygon
  22670. */
  22671. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22672. /**
  22673. * Creates the VertexData of the IcoSphere
  22674. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22675. * * radius the radius of the IcoSphere, optional default 1
  22676. * * radiusX allows stretching in the x direction, optional, default radius
  22677. * * radiusY allows stretching in the y direction, optional, default radius
  22678. * * radiusZ allows stretching in the z direction, optional, default radius
  22679. * * flat when true creates a flat shaded mesh, optional, default true
  22680. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22681. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22682. * * 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)
  22683. * * 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)
  22684. * @returns the VertexData of the IcoSphere
  22685. */
  22686. static CreateIcoSphere(options: {
  22687. radius?: number;
  22688. radiusX?: number;
  22689. radiusY?: number;
  22690. radiusZ?: number;
  22691. flat?: boolean;
  22692. subdivisions?: number;
  22693. sideOrientation?: number;
  22694. frontUVs?: Vector4;
  22695. backUVs?: Vector4;
  22696. }): VertexData;
  22697. /**
  22698. * Creates the VertexData for a Polyhedron
  22699. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22700. * * type provided types are:
  22701. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22702. * * 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)
  22703. * * size the size of the IcoSphere, optional default 1
  22704. * * sizeX allows stretching in the x direction, optional, default size
  22705. * * sizeY allows stretching in the y direction, optional, default size
  22706. * * sizeZ allows stretching in the z direction, optional, default size
  22707. * * 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
  22708. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22709. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22710. * * flat when true creates a flat shaded mesh, optional, default true
  22711. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22713. * * 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)
  22714. * * 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)
  22715. * @returns the VertexData of the Polyhedron
  22716. */
  22717. static CreatePolyhedron(options: {
  22718. type?: number;
  22719. size?: number;
  22720. sizeX?: number;
  22721. sizeY?: number;
  22722. sizeZ?: number;
  22723. custom?: any;
  22724. faceUV?: Vector4[];
  22725. faceColors?: Color4[];
  22726. flat?: boolean;
  22727. sideOrientation?: number;
  22728. frontUVs?: Vector4;
  22729. backUVs?: Vector4;
  22730. }): VertexData;
  22731. /**
  22732. * Creates the VertexData for a TorusKnot
  22733. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22734. * * radius the radius of the torus knot, optional, default 2
  22735. * * tube the thickness of the tube, optional, default 0.5
  22736. * * radialSegments the number of sides on each tube segments, optional, default 32
  22737. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22738. * * p the number of windings around the z axis, optional, default 2
  22739. * * q the number of windings around the x axis, optional, default 3
  22740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22741. * * 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)
  22742. * * 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)
  22743. * @returns the VertexData of the Torus Knot
  22744. */
  22745. static CreateTorusKnot(options: {
  22746. radius?: number;
  22747. tube?: number;
  22748. radialSegments?: number;
  22749. tubularSegments?: number;
  22750. p?: number;
  22751. q?: number;
  22752. sideOrientation?: number;
  22753. frontUVs?: Vector4;
  22754. backUVs?: Vector4;
  22755. }): VertexData;
  22756. /**
  22757. * Compute normals for given positions and indices
  22758. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22759. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22760. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22761. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22762. * * facetNormals : optional array of facet normals (vector3)
  22763. * * facetPositions : optional array of facet positions (vector3)
  22764. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22765. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22766. * * bInfo : optional bounding info, required for facetPartitioning computation
  22767. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22768. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22769. * * useRightHandedSystem: optional boolean to for right handed system computation
  22770. * * depthSort : optional boolean to enable the facet depth sort computation
  22771. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22772. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22773. */
  22774. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22775. facetNormals?: any;
  22776. facetPositions?: any;
  22777. facetPartitioning?: any;
  22778. ratio?: number;
  22779. bInfo?: any;
  22780. bbSize?: Vector3;
  22781. subDiv?: any;
  22782. useRightHandedSystem?: boolean;
  22783. depthSort?: boolean;
  22784. distanceTo?: Vector3;
  22785. depthSortedFacets?: any;
  22786. }): void;
  22787. /** @hidden */
  22788. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22789. /**
  22790. * Applies VertexData created from the imported parameters to the geometry
  22791. * @param parsedVertexData the parsed data from an imported file
  22792. * @param geometry the geometry to apply the VertexData to
  22793. */
  22794. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22795. }
  22796. }
  22797. declare module "babylonjs/Morph/morphTarget" {
  22798. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22799. import { Observable } from "babylonjs/Misc/observable";
  22800. import { Nullable, FloatArray } from "babylonjs/types";
  22801. import { Scene } from "babylonjs/scene";
  22802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22803. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22804. /**
  22805. * Defines a target to use with MorphTargetManager
  22806. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22807. */
  22808. export class MorphTarget implements IAnimatable {
  22809. /** defines the name of the target */
  22810. name: string;
  22811. /**
  22812. * Gets or sets the list of animations
  22813. */
  22814. animations: import("babylonjs/Animations/animation").Animation[];
  22815. private _scene;
  22816. private _positions;
  22817. private _normals;
  22818. private _tangents;
  22819. private _uvs;
  22820. private _influence;
  22821. private _uniqueId;
  22822. /**
  22823. * Observable raised when the influence changes
  22824. */
  22825. onInfluenceChanged: Observable<boolean>;
  22826. /** @hidden */
  22827. _onDataLayoutChanged: Observable<void>;
  22828. /**
  22829. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22830. */
  22831. influence: number;
  22832. /**
  22833. * Gets or sets the id of the morph Target
  22834. */
  22835. id: string;
  22836. private _animationPropertiesOverride;
  22837. /**
  22838. * Gets or sets the animation properties override
  22839. */
  22840. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22841. /**
  22842. * Creates a new MorphTarget
  22843. * @param name defines the name of the target
  22844. * @param influence defines the influence to use
  22845. * @param scene defines the scene the morphtarget belongs to
  22846. */
  22847. constructor(
  22848. /** defines the name of the target */
  22849. name: string, influence?: number, scene?: Nullable<Scene>);
  22850. /**
  22851. * Gets the unique ID of this manager
  22852. */
  22853. readonly uniqueId: number;
  22854. /**
  22855. * Gets a boolean defining if the target contains position data
  22856. */
  22857. readonly hasPositions: boolean;
  22858. /**
  22859. * Gets a boolean defining if the target contains normal data
  22860. */
  22861. readonly hasNormals: boolean;
  22862. /**
  22863. * Gets a boolean defining if the target contains tangent data
  22864. */
  22865. readonly hasTangents: boolean;
  22866. /**
  22867. * Gets a boolean defining if the target contains texture coordinates data
  22868. */
  22869. readonly hasUVs: boolean;
  22870. /**
  22871. * Affects position data to this target
  22872. * @param data defines the position data to use
  22873. */
  22874. setPositions(data: Nullable<FloatArray>): void;
  22875. /**
  22876. * Gets the position data stored in this target
  22877. * @returns a FloatArray containing the position data (or null if not present)
  22878. */
  22879. getPositions(): Nullable<FloatArray>;
  22880. /**
  22881. * Affects normal data to this target
  22882. * @param data defines the normal data to use
  22883. */
  22884. setNormals(data: Nullable<FloatArray>): void;
  22885. /**
  22886. * Gets the normal data stored in this target
  22887. * @returns a FloatArray containing the normal data (or null if not present)
  22888. */
  22889. getNormals(): Nullable<FloatArray>;
  22890. /**
  22891. * Affects tangent data to this target
  22892. * @param data defines the tangent data to use
  22893. */
  22894. setTangents(data: Nullable<FloatArray>): void;
  22895. /**
  22896. * Gets the tangent data stored in this target
  22897. * @returns a FloatArray containing the tangent data (or null if not present)
  22898. */
  22899. getTangents(): Nullable<FloatArray>;
  22900. /**
  22901. * Affects texture coordinates data to this target
  22902. * @param data defines the texture coordinates data to use
  22903. */
  22904. setUVs(data: Nullable<FloatArray>): void;
  22905. /**
  22906. * Gets the texture coordinates data stored in this target
  22907. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22908. */
  22909. getUVs(): Nullable<FloatArray>;
  22910. /**
  22911. * Clone the current target
  22912. * @returns a new MorphTarget
  22913. */
  22914. clone(): MorphTarget;
  22915. /**
  22916. * Serializes the current target into a Serialization object
  22917. * @returns the serialized object
  22918. */
  22919. serialize(): any;
  22920. /**
  22921. * Returns the string "MorphTarget"
  22922. * @returns "MorphTarget"
  22923. */
  22924. getClassName(): string;
  22925. /**
  22926. * Creates a new target from serialized data
  22927. * @param serializationObject defines the serialized data to use
  22928. * @returns a new MorphTarget
  22929. */
  22930. static Parse(serializationObject: any): MorphTarget;
  22931. /**
  22932. * Creates a MorphTarget from mesh data
  22933. * @param mesh defines the source mesh
  22934. * @param name defines the name to use for the new target
  22935. * @param influence defines the influence to attach to the target
  22936. * @returns a new MorphTarget
  22937. */
  22938. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22939. }
  22940. }
  22941. declare module "babylonjs/Morph/morphTargetManager" {
  22942. import { Nullable } from "babylonjs/types";
  22943. import { Scene } from "babylonjs/scene";
  22944. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22945. /**
  22946. * This class is used to deform meshes using morphing between different targets
  22947. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22948. */
  22949. export class MorphTargetManager {
  22950. private _targets;
  22951. private _targetInfluenceChangedObservers;
  22952. private _targetDataLayoutChangedObservers;
  22953. private _activeTargets;
  22954. private _scene;
  22955. private _influences;
  22956. private _supportsNormals;
  22957. private _supportsTangents;
  22958. private _supportsUVs;
  22959. private _vertexCount;
  22960. private _uniqueId;
  22961. private _tempInfluences;
  22962. /**
  22963. * Gets or sets a boolean indicating if normals must be morphed
  22964. */
  22965. enableNormalMorphing: boolean;
  22966. /**
  22967. * Gets or sets a boolean indicating if tangents must be morphed
  22968. */
  22969. enableTangentMorphing: boolean;
  22970. /**
  22971. * Gets or sets a boolean indicating if UV must be morphed
  22972. */
  22973. enableUVMorphing: boolean;
  22974. /**
  22975. * Creates a new MorphTargetManager
  22976. * @param scene defines the current scene
  22977. */
  22978. constructor(scene?: Nullable<Scene>);
  22979. /**
  22980. * Gets the unique ID of this manager
  22981. */
  22982. readonly uniqueId: number;
  22983. /**
  22984. * Gets the number of vertices handled by this manager
  22985. */
  22986. readonly vertexCount: number;
  22987. /**
  22988. * Gets a boolean indicating if this manager supports morphing of normals
  22989. */
  22990. readonly supportsNormals: boolean;
  22991. /**
  22992. * Gets a boolean indicating if this manager supports morphing of tangents
  22993. */
  22994. readonly supportsTangents: boolean;
  22995. /**
  22996. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22997. */
  22998. readonly supportsUVs: boolean;
  22999. /**
  23000. * Gets the number of targets stored in this manager
  23001. */
  23002. readonly numTargets: number;
  23003. /**
  23004. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23005. */
  23006. readonly numInfluencers: number;
  23007. /**
  23008. * Gets the list of influences (one per target)
  23009. */
  23010. readonly influences: Float32Array;
  23011. /**
  23012. * Gets the active target at specified index. An active target is a target with an influence > 0
  23013. * @param index defines the index to check
  23014. * @returns the requested target
  23015. */
  23016. getActiveTarget(index: number): MorphTarget;
  23017. /**
  23018. * Gets the target at specified index
  23019. * @param index defines the index to check
  23020. * @returns the requested target
  23021. */
  23022. getTarget(index: number): MorphTarget;
  23023. /**
  23024. * Add a new target to this manager
  23025. * @param target defines the target to add
  23026. */
  23027. addTarget(target: MorphTarget): void;
  23028. /**
  23029. * Removes a target from the manager
  23030. * @param target defines the target to remove
  23031. */
  23032. removeTarget(target: MorphTarget): void;
  23033. /**
  23034. * Clone the current manager
  23035. * @returns a new MorphTargetManager
  23036. */
  23037. clone(): MorphTargetManager;
  23038. /**
  23039. * Serializes the current manager into a Serialization object
  23040. * @returns the serialized object
  23041. */
  23042. serialize(): any;
  23043. private _syncActiveTargets;
  23044. /**
  23045. * Syncrhonize the targets with all the meshes using this morph target manager
  23046. */
  23047. synchronize(): void;
  23048. /**
  23049. * Creates a new MorphTargetManager from serialized data
  23050. * @param serializationObject defines the serialized data
  23051. * @param scene defines the hosting scene
  23052. * @returns the new MorphTargetManager
  23053. */
  23054. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23055. }
  23056. }
  23057. declare module "babylonjs/Meshes/meshLODLevel" {
  23058. import { Mesh } from "babylonjs/Meshes/mesh";
  23059. import { Nullable } from "babylonjs/types";
  23060. /**
  23061. * Class used to represent a specific level of detail of a mesh
  23062. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23063. */
  23064. export class MeshLODLevel {
  23065. /** Defines the distance where this level should start being displayed */
  23066. distance: number;
  23067. /** Defines the mesh to use to render this level */
  23068. mesh: Nullable<Mesh>;
  23069. /**
  23070. * Creates a new LOD level
  23071. * @param distance defines the distance where this level should star being displayed
  23072. * @param mesh defines the mesh to use to render this level
  23073. */
  23074. constructor(
  23075. /** Defines the distance where this level should start being displayed */
  23076. distance: number,
  23077. /** Defines the mesh to use to render this level */
  23078. mesh: Nullable<Mesh>);
  23079. }
  23080. }
  23081. declare module "babylonjs/Meshes/groundMesh" {
  23082. import { Scene } from "babylonjs/scene";
  23083. import { Vector3 } from "babylonjs/Maths/math.vector";
  23084. import { Mesh } from "babylonjs/Meshes/mesh";
  23085. /**
  23086. * Mesh representing the gorund
  23087. */
  23088. export class GroundMesh extends Mesh {
  23089. /** If octree should be generated */
  23090. generateOctree: boolean;
  23091. private _heightQuads;
  23092. /** @hidden */
  23093. _subdivisionsX: number;
  23094. /** @hidden */
  23095. _subdivisionsY: number;
  23096. /** @hidden */
  23097. _width: number;
  23098. /** @hidden */
  23099. _height: number;
  23100. /** @hidden */
  23101. _minX: number;
  23102. /** @hidden */
  23103. _maxX: number;
  23104. /** @hidden */
  23105. _minZ: number;
  23106. /** @hidden */
  23107. _maxZ: number;
  23108. constructor(name: string, scene: Scene);
  23109. /**
  23110. * "GroundMesh"
  23111. * @returns "GroundMesh"
  23112. */
  23113. getClassName(): string;
  23114. /**
  23115. * The minimum of x and y subdivisions
  23116. */
  23117. readonly subdivisions: number;
  23118. /**
  23119. * X subdivisions
  23120. */
  23121. readonly subdivisionsX: number;
  23122. /**
  23123. * Y subdivisions
  23124. */
  23125. readonly subdivisionsY: number;
  23126. /**
  23127. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23128. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23129. * @param chunksCount the number of subdivisions for x and y
  23130. * @param octreeBlocksSize (Default: 32)
  23131. */
  23132. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23133. /**
  23134. * Returns a height (y) value in the Worl system :
  23135. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23136. * @param x x coordinate
  23137. * @param z z coordinate
  23138. * @returns the ground y position if (x, z) are outside the ground surface.
  23139. */
  23140. getHeightAtCoordinates(x: number, z: number): number;
  23141. /**
  23142. * Returns a normalized vector (Vector3) orthogonal to the ground
  23143. * at the ground coordinates (x, z) expressed in the World system.
  23144. * @param x x coordinate
  23145. * @param z z coordinate
  23146. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23147. */
  23148. getNormalAtCoordinates(x: number, z: number): Vector3;
  23149. /**
  23150. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23151. * at the ground coordinates (x, z) expressed in the World system.
  23152. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23153. * @param x x coordinate
  23154. * @param z z coordinate
  23155. * @param ref vector to store the result
  23156. * @returns the GroundMesh.
  23157. */
  23158. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23159. /**
  23160. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23161. * if the ground has been updated.
  23162. * This can be used in the render loop.
  23163. * @returns the GroundMesh.
  23164. */
  23165. updateCoordinateHeights(): GroundMesh;
  23166. private _getFacetAt;
  23167. private _initHeightQuads;
  23168. private _computeHeightQuads;
  23169. /**
  23170. * Serializes this ground mesh
  23171. * @param serializationObject object to write serialization to
  23172. */
  23173. serialize(serializationObject: any): void;
  23174. /**
  23175. * Parses a serialized ground mesh
  23176. * @param parsedMesh the serialized mesh
  23177. * @param scene the scene to create the ground mesh in
  23178. * @returns the created ground mesh
  23179. */
  23180. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23181. }
  23182. }
  23183. declare module "babylonjs/Physics/physicsJoint" {
  23184. import { Vector3 } from "babylonjs/Maths/math.vector";
  23185. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23186. /**
  23187. * Interface for Physics-Joint data
  23188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23189. */
  23190. export interface PhysicsJointData {
  23191. /**
  23192. * The main pivot of the joint
  23193. */
  23194. mainPivot?: Vector3;
  23195. /**
  23196. * The connected pivot of the joint
  23197. */
  23198. connectedPivot?: Vector3;
  23199. /**
  23200. * The main axis of the joint
  23201. */
  23202. mainAxis?: Vector3;
  23203. /**
  23204. * The connected axis of the joint
  23205. */
  23206. connectedAxis?: Vector3;
  23207. /**
  23208. * The collision of the joint
  23209. */
  23210. collision?: boolean;
  23211. /**
  23212. * Native Oimo/Cannon/Energy data
  23213. */
  23214. nativeParams?: any;
  23215. }
  23216. /**
  23217. * This is a holder class for the physics joint created by the physics plugin
  23218. * It holds a set of functions to control the underlying joint
  23219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23220. */
  23221. export class PhysicsJoint {
  23222. /**
  23223. * The type of the physics joint
  23224. */
  23225. type: number;
  23226. /**
  23227. * The data for the physics joint
  23228. */
  23229. jointData: PhysicsJointData;
  23230. private _physicsJoint;
  23231. protected _physicsPlugin: IPhysicsEnginePlugin;
  23232. /**
  23233. * Initializes the physics joint
  23234. * @param type The type of the physics joint
  23235. * @param jointData The data for the physics joint
  23236. */
  23237. constructor(
  23238. /**
  23239. * The type of the physics joint
  23240. */
  23241. type: number,
  23242. /**
  23243. * The data for the physics joint
  23244. */
  23245. jointData: PhysicsJointData);
  23246. /**
  23247. * Gets the physics joint
  23248. */
  23249. /**
  23250. * Sets the physics joint
  23251. */
  23252. physicsJoint: any;
  23253. /**
  23254. * Sets the physics plugin
  23255. */
  23256. physicsPlugin: IPhysicsEnginePlugin;
  23257. /**
  23258. * Execute a function that is physics-plugin specific.
  23259. * @param {Function} func the function that will be executed.
  23260. * It accepts two parameters: the physics world and the physics joint
  23261. */
  23262. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23263. /**
  23264. * Distance-Joint type
  23265. */
  23266. static DistanceJoint: number;
  23267. /**
  23268. * Hinge-Joint type
  23269. */
  23270. static HingeJoint: number;
  23271. /**
  23272. * Ball-and-Socket joint type
  23273. */
  23274. static BallAndSocketJoint: number;
  23275. /**
  23276. * Wheel-Joint type
  23277. */
  23278. static WheelJoint: number;
  23279. /**
  23280. * Slider-Joint type
  23281. */
  23282. static SliderJoint: number;
  23283. /**
  23284. * Prismatic-Joint type
  23285. */
  23286. static PrismaticJoint: number;
  23287. /**
  23288. * Universal-Joint type
  23289. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23290. */
  23291. static UniversalJoint: number;
  23292. /**
  23293. * Hinge-Joint 2 type
  23294. */
  23295. static Hinge2Joint: number;
  23296. /**
  23297. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23298. */
  23299. static PointToPointJoint: number;
  23300. /**
  23301. * Spring-Joint type
  23302. */
  23303. static SpringJoint: number;
  23304. /**
  23305. * Lock-Joint type
  23306. */
  23307. static LockJoint: number;
  23308. }
  23309. /**
  23310. * A class representing a physics distance joint
  23311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23312. */
  23313. export class DistanceJoint extends PhysicsJoint {
  23314. /**
  23315. *
  23316. * @param jointData The data for the Distance-Joint
  23317. */
  23318. constructor(jointData: DistanceJointData);
  23319. /**
  23320. * Update the predefined distance.
  23321. * @param maxDistance The maximum preferred distance
  23322. * @param minDistance The minimum preferred distance
  23323. */
  23324. updateDistance(maxDistance: number, minDistance?: number): void;
  23325. }
  23326. /**
  23327. * Represents a Motor-Enabled Joint
  23328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23329. */
  23330. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23331. /**
  23332. * Initializes the Motor-Enabled Joint
  23333. * @param type The type of the joint
  23334. * @param jointData The physica joint data for the joint
  23335. */
  23336. constructor(type: number, jointData: PhysicsJointData);
  23337. /**
  23338. * Set the motor values.
  23339. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23340. * @param force the force to apply
  23341. * @param maxForce max force for this motor.
  23342. */
  23343. setMotor(force?: number, maxForce?: number): void;
  23344. /**
  23345. * Set the motor's limits.
  23346. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23347. * @param upperLimit The upper limit of the motor
  23348. * @param lowerLimit The lower limit of the motor
  23349. */
  23350. setLimit(upperLimit: number, lowerLimit?: number): void;
  23351. }
  23352. /**
  23353. * This class represents a single physics Hinge-Joint
  23354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23355. */
  23356. export class HingeJoint extends MotorEnabledJoint {
  23357. /**
  23358. * Initializes the Hinge-Joint
  23359. * @param jointData The joint data for the Hinge-Joint
  23360. */
  23361. constructor(jointData: PhysicsJointData);
  23362. /**
  23363. * Set the motor values.
  23364. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23365. * @param {number} force the force to apply
  23366. * @param {number} maxForce max force for this motor.
  23367. */
  23368. setMotor(force?: number, maxForce?: number): void;
  23369. /**
  23370. * Set the motor's limits.
  23371. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23372. * @param upperLimit The upper limit of the motor
  23373. * @param lowerLimit The lower limit of the motor
  23374. */
  23375. setLimit(upperLimit: number, lowerLimit?: number): void;
  23376. }
  23377. /**
  23378. * This class represents a dual hinge physics joint (same as wheel joint)
  23379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23380. */
  23381. export class Hinge2Joint extends MotorEnabledJoint {
  23382. /**
  23383. * Initializes the Hinge2-Joint
  23384. * @param jointData The joint data for the Hinge2-Joint
  23385. */
  23386. constructor(jointData: PhysicsJointData);
  23387. /**
  23388. * Set the motor values.
  23389. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23390. * @param {number} targetSpeed the speed the motor is to reach
  23391. * @param {number} maxForce max force for this motor.
  23392. * @param {motorIndex} the motor's index, 0 or 1.
  23393. */
  23394. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23395. /**
  23396. * Set the motor limits.
  23397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23398. * @param {number} upperLimit the upper limit
  23399. * @param {number} lowerLimit lower limit
  23400. * @param {motorIndex} the motor's index, 0 or 1.
  23401. */
  23402. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23403. }
  23404. /**
  23405. * Interface for a motor enabled joint
  23406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23407. */
  23408. export interface IMotorEnabledJoint {
  23409. /**
  23410. * Physics joint
  23411. */
  23412. physicsJoint: any;
  23413. /**
  23414. * Sets the motor of the motor-enabled joint
  23415. * @param force The force of the motor
  23416. * @param maxForce The maximum force of the motor
  23417. * @param motorIndex The index of the motor
  23418. */
  23419. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23420. /**
  23421. * Sets the limit of the motor
  23422. * @param upperLimit The upper limit of the motor
  23423. * @param lowerLimit The lower limit of the motor
  23424. * @param motorIndex The index of the motor
  23425. */
  23426. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23427. }
  23428. /**
  23429. * Joint data for a Distance-Joint
  23430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23431. */
  23432. export interface DistanceJointData extends PhysicsJointData {
  23433. /**
  23434. * Max distance the 2 joint objects can be apart
  23435. */
  23436. maxDistance: number;
  23437. }
  23438. /**
  23439. * Joint data from a spring joint
  23440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23441. */
  23442. export interface SpringJointData extends PhysicsJointData {
  23443. /**
  23444. * Length of the spring
  23445. */
  23446. length: number;
  23447. /**
  23448. * Stiffness of the spring
  23449. */
  23450. stiffness: number;
  23451. /**
  23452. * Damping of the spring
  23453. */
  23454. damping: number;
  23455. /** this callback will be called when applying the force to the impostors. */
  23456. forceApplicationCallback: () => void;
  23457. }
  23458. }
  23459. declare module "babylonjs/Physics/physicsRaycastResult" {
  23460. import { Vector3 } from "babylonjs/Maths/math.vector";
  23461. /**
  23462. * Holds the data for the raycast result
  23463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23464. */
  23465. export class PhysicsRaycastResult {
  23466. private _hasHit;
  23467. private _hitDistance;
  23468. private _hitNormalWorld;
  23469. private _hitPointWorld;
  23470. private _rayFromWorld;
  23471. private _rayToWorld;
  23472. /**
  23473. * Gets if there was a hit
  23474. */
  23475. readonly hasHit: boolean;
  23476. /**
  23477. * Gets the distance from the hit
  23478. */
  23479. readonly hitDistance: number;
  23480. /**
  23481. * Gets the hit normal/direction in the world
  23482. */
  23483. readonly hitNormalWorld: Vector3;
  23484. /**
  23485. * Gets the hit point in the world
  23486. */
  23487. readonly hitPointWorld: Vector3;
  23488. /**
  23489. * Gets the ray "start point" of the ray in the world
  23490. */
  23491. readonly rayFromWorld: Vector3;
  23492. /**
  23493. * Gets the ray "end point" of the ray in the world
  23494. */
  23495. readonly rayToWorld: Vector3;
  23496. /**
  23497. * Sets the hit data (normal & point in world space)
  23498. * @param hitNormalWorld defines the normal in world space
  23499. * @param hitPointWorld defines the point in world space
  23500. */
  23501. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23502. /**
  23503. * Sets the distance from the start point to the hit point
  23504. * @param distance
  23505. */
  23506. setHitDistance(distance: number): void;
  23507. /**
  23508. * Calculates the distance manually
  23509. */
  23510. calculateHitDistance(): void;
  23511. /**
  23512. * Resets all the values to default
  23513. * @param from The from point on world space
  23514. * @param to The to point on world space
  23515. */
  23516. reset(from?: Vector3, to?: Vector3): void;
  23517. }
  23518. /**
  23519. * Interface for the size containing width and height
  23520. */
  23521. interface IXYZ {
  23522. /**
  23523. * X
  23524. */
  23525. x: number;
  23526. /**
  23527. * Y
  23528. */
  23529. y: number;
  23530. /**
  23531. * Z
  23532. */
  23533. z: number;
  23534. }
  23535. }
  23536. declare module "babylonjs/Physics/IPhysicsEngine" {
  23537. import { Nullable } from "babylonjs/types";
  23538. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23540. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23541. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23542. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23543. /**
  23544. * Interface used to describe a physics joint
  23545. */
  23546. export interface PhysicsImpostorJoint {
  23547. /** Defines the main impostor to which the joint is linked */
  23548. mainImpostor: PhysicsImpostor;
  23549. /** Defines the impostor that is connected to the main impostor using this joint */
  23550. connectedImpostor: PhysicsImpostor;
  23551. /** Defines the joint itself */
  23552. joint: PhysicsJoint;
  23553. }
  23554. /** @hidden */
  23555. export interface IPhysicsEnginePlugin {
  23556. world: any;
  23557. name: string;
  23558. setGravity(gravity: Vector3): void;
  23559. setTimeStep(timeStep: number): void;
  23560. getTimeStep(): number;
  23561. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23562. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23563. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23564. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23565. removePhysicsBody(impostor: PhysicsImpostor): void;
  23566. generateJoint(joint: PhysicsImpostorJoint): void;
  23567. removeJoint(joint: PhysicsImpostorJoint): void;
  23568. isSupported(): boolean;
  23569. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23570. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23571. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23572. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23573. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23574. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23575. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23576. getBodyMass(impostor: PhysicsImpostor): number;
  23577. getBodyFriction(impostor: PhysicsImpostor): number;
  23578. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23579. getBodyRestitution(impostor: PhysicsImpostor): number;
  23580. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23581. getBodyPressure?(impostor: PhysicsImpostor): number;
  23582. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23583. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23584. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23585. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23586. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23587. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23588. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23589. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23590. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23591. sleepBody(impostor: PhysicsImpostor): void;
  23592. wakeUpBody(impostor: PhysicsImpostor): void;
  23593. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23594. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23595. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23596. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23597. getRadius(impostor: PhysicsImpostor): number;
  23598. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23599. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23600. dispose(): void;
  23601. }
  23602. /**
  23603. * Interface used to define a physics engine
  23604. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23605. */
  23606. export interface IPhysicsEngine {
  23607. /**
  23608. * Gets the gravity vector used by the simulation
  23609. */
  23610. gravity: Vector3;
  23611. /**
  23612. * Sets the gravity vector used by the simulation
  23613. * @param gravity defines the gravity vector to use
  23614. */
  23615. setGravity(gravity: Vector3): void;
  23616. /**
  23617. * Set the time step of the physics engine.
  23618. * Default is 1/60.
  23619. * To slow it down, enter 1/600 for example.
  23620. * To speed it up, 1/30
  23621. * @param newTimeStep the new timestep to apply to this world.
  23622. */
  23623. setTimeStep(newTimeStep: number): void;
  23624. /**
  23625. * Get the time step of the physics engine.
  23626. * @returns the current time step
  23627. */
  23628. getTimeStep(): number;
  23629. /**
  23630. * Release all resources
  23631. */
  23632. dispose(): void;
  23633. /**
  23634. * Gets the name of the current physics plugin
  23635. * @returns the name of the plugin
  23636. */
  23637. getPhysicsPluginName(): string;
  23638. /**
  23639. * Adding a new impostor for the impostor tracking.
  23640. * This will be done by the impostor itself.
  23641. * @param impostor the impostor to add
  23642. */
  23643. addImpostor(impostor: PhysicsImpostor): void;
  23644. /**
  23645. * Remove an impostor from the engine.
  23646. * This impostor and its mesh will not longer be updated by the physics engine.
  23647. * @param impostor the impostor to remove
  23648. */
  23649. removeImpostor(impostor: PhysicsImpostor): void;
  23650. /**
  23651. * Add a joint to the physics engine
  23652. * @param mainImpostor defines the main impostor to which the joint is added.
  23653. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23654. * @param joint defines the joint that will connect both impostors.
  23655. */
  23656. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23657. /**
  23658. * Removes a joint from the simulation
  23659. * @param mainImpostor defines the impostor used with the joint
  23660. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23661. * @param joint defines the joint to remove
  23662. */
  23663. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23664. /**
  23665. * Gets the current plugin used to run the simulation
  23666. * @returns current plugin
  23667. */
  23668. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23669. /**
  23670. * Gets the list of physic impostors
  23671. * @returns an array of PhysicsImpostor
  23672. */
  23673. getImpostors(): Array<PhysicsImpostor>;
  23674. /**
  23675. * Gets the impostor for a physics enabled object
  23676. * @param object defines the object impersonated by the impostor
  23677. * @returns the PhysicsImpostor or null if not found
  23678. */
  23679. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23680. /**
  23681. * Gets the impostor for a physics body object
  23682. * @param body defines physics body used by the impostor
  23683. * @returns the PhysicsImpostor or null if not found
  23684. */
  23685. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23686. /**
  23687. * Does a raycast in the physics world
  23688. * @param from when should the ray start?
  23689. * @param to when should the ray end?
  23690. * @returns PhysicsRaycastResult
  23691. */
  23692. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23693. /**
  23694. * Called by the scene. No need to call it.
  23695. * @param delta defines the timespam between frames
  23696. */
  23697. _step(delta: number): void;
  23698. }
  23699. }
  23700. declare module "babylonjs/Physics/physicsImpostor" {
  23701. import { Nullable, IndicesArray } from "babylonjs/types";
  23702. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23703. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23705. import { Scene } from "babylonjs/scene";
  23706. import { Bone } from "babylonjs/Bones/bone";
  23707. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23708. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23709. import { Space } from "babylonjs/Maths/math.axis";
  23710. /**
  23711. * The interface for the physics imposter parameters
  23712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23713. */
  23714. export interface PhysicsImpostorParameters {
  23715. /**
  23716. * The mass of the physics imposter
  23717. */
  23718. mass: number;
  23719. /**
  23720. * The friction of the physics imposter
  23721. */
  23722. friction?: number;
  23723. /**
  23724. * The coefficient of restitution of the physics imposter
  23725. */
  23726. restitution?: number;
  23727. /**
  23728. * The native options of the physics imposter
  23729. */
  23730. nativeOptions?: any;
  23731. /**
  23732. * Specifies if the parent should be ignored
  23733. */
  23734. ignoreParent?: boolean;
  23735. /**
  23736. * Specifies if bi-directional transformations should be disabled
  23737. */
  23738. disableBidirectionalTransformation?: boolean;
  23739. /**
  23740. * The pressure inside the physics imposter, soft object only
  23741. */
  23742. pressure?: number;
  23743. /**
  23744. * The stiffness the physics imposter, soft object only
  23745. */
  23746. stiffness?: number;
  23747. /**
  23748. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23749. */
  23750. velocityIterations?: number;
  23751. /**
  23752. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23753. */
  23754. positionIterations?: number;
  23755. /**
  23756. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23757. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23758. * Add to fix multiple points
  23759. */
  23760. fixedPoints?: number;
  23761. /**
  23762. * The collision margin around a soft object
  23763. */
  23764. margin?: number;
  23765. /**
  23766. * The collision margin around a soft object
  23767. */
  23768. damping?: number;
  23769. /**
  23770. * The path for a rope based on an extrusion
  23771. */
  23772. path?: any;
  23773. /**
  23774. * The shape of an extrusion used for a rope based on an extrusion
  23775. */
  23776. shape?: any;
  23777. }
  23778. /**
  23779. * Interface for a physics-enabled object
  23780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23781. */
  23782. export interface IPhysicsEnabledObject {
  23783. /**
  23784. * The position of the physics-enabled object
  23785. */
  23786. position: Vector3;
  23787. /**
  23788. * The rotation of the physics-enabled object
  23789. */
  23790. rotationQuaternion: Nullable<Quaternion>;
  23791. /**
  23792. * The scale of the physics-enabled object
  23793. */
  23794. scaling: Vector3;
  23795. /**
  23796. * The rotation of the physics-enabled object
  23797. */
  23798. rotation?: Vector3;
  23799. /**
  23800. * The parent of the physics-enabled object
  23801. */
  23802. parent?: any;
  23803. /**
  23804. * The bounding info of the physics-enabled object
  23805. * @returns The bounding info of the physics-enabled object
  23806. */
  23807. getBoundingInfo(): BoundingInfo;
  23808. /**
  23809. * Computes the world matrix
  23810. * @param force Specifies if the world matrix should be computed by force
  23811. * @returns A world matrix
  23812. */
  23813. computeWorldMatrix(force: boolean): Matrix;
  23814. /**
  23815. * Gets the world matrix
  23816. * @returns A world matrix
  23817. */
  23818. getWorldMatrix?(): Matrix;
  23819. /**
  23820. * Gets the child meshes
  23821. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23822. * @returns An array of abstract meshes
  23823. */
  23824. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23825. /**
  23826. * Gets the vertex data
  23827. * @param kind The type of vertex data
  23828. * @returns A nullable array of numbers, or a float32 array
  23829. */
  23830. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23831. /**
  23832. * Gets the indices from the mesh
  23833. * @returns A nullable array of index arrays
  23834. */
  23835. getIndices?(): Nullable<IndicesArray>;
  23836. /**
  23837. * Gets the scene from the mesh
  23838. * @returns the indices array or null
  23839. */
  23840. getScene?(): Scene;
  23841. /**
  23842. * Gets the absolute position from the mesh
  23843. * @returns the absolute position
  23844. */
  23845. getAbsolutePosition(): Vector3;
  23846. /**
  23847. * Gets the absolute pivot point from the mesh
  23848. * @returns the absolute pivot point
  23849. */
  23850. getAbsolutePivotPoint(): Vector3;
  23851. /**
  23852. * Rotates the mesh
  23853. * @param axis The axis of rotation
  23854. * @param amount The amount of rotation
  23855. * @param space The space of the rotation
  23856. * @returns The rotation transform node
  23857. */
  23858. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23859. /**
  23860. * Translates the mesh
  23861. * @param axis The axis of translation
  23862. * @param distance The distance of translation
  23863. * @param space The space of the translation
  23864. * @returns The transform node
  23865. */
  23866. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23867. /**
  23868. * Sets the absolute position of the mesh
  23869. * @param absolutePosition The absolute position of the mesh
  23870. * @returns The transform node
  23871. */
  23872. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23873. /**
  23874. * Gets the class name of the mesh
  23875. * @returns The class name
  23876. */
  23877. getClassName(): string;
  23878. }
  23879. /**
  23880. * Represents a physics imposter
  23881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23882. */
  23883. export class PhysicsImpostor {
  23884. /**
  23885. * The physics-enabled object used as the physics imposter
  23886. */
  23887. object: IPhysicsEnabledObject;
  23888. /**
  23889. * The type of the physics imposter
  23890. */
  23891. type: number;
  23892. private _options;
  23893. private _scene?;
  23894. /**
  23895. * The default object size of the imposter
  23896. */
  23897. static DEFAULT_OBJECT_SIZE: Vector3;
  23898. /**
  23899. * The identity quaternion of the imposter
  23900. */
  23901. static IDENTITY_QUATERNION: Quaternion;
  23902. /** @hidden */
  23903. _pluginData: any;
  23904. private _physicsEngine;
  23905. private _physicsBody;
  23906. private _bodyUpdateRequired;
  23907. private _onBeforePhysicsStepCallbacks;
  23908. private _onAfterPhysicsStepCallbacks;
  23909. /** @hidden */
  23910. _onPhysicsCollideCallbacks: Array<{
  23911. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23912. otherImpostors: Array<PhysicsImpostor>;
  23913. }>;
  23914. private _deltaPosition;
  23915. private _deltaRotation;
  23916. private _deltaRotationConjugated;
  23917. /** @hidden */
  23918. _isFromLine: boolean;
  23919. private _parent;
  23920. private _isDisposed;
  23921. private static _tmpVecs;
  23922. private static _tmpQuat;
  23923. /**
  23924. * Specifies if the physics imposter is disposed
  23925. */
  23926. readonly isDisposed: boolean;
  23927. /**
  23928. * Gets the mass of the physics imposter
  23929. */
  23930. mass: number;
  23931. /**
  23932. * Gets the coefficient of friction
  23933. */
  23934. /**
  23935. * Sets the coefficient of friction
  23936. */
  23937. friction: number;
  23938. /**
  23939. * Gets the coefficient of restitution
  23940. */
  23941. /**
  23942. * Sets the coefficient of restitution
  23943. */
  23944. restitution: number;
  23945. /**
  23946. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23947. */
  23948. /**
  23949. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23950. */
  23951. pressure: number;
  23952. /**
  23953. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23954. */
  23955. /**
  23956. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23957. */
  23958. stiffness: number;
  23959. /**
  23960. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23961. */
  23962. /**
  23963. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23964. */
  23965. velocityIterations: number;
  23966. /**
  23967. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23968. */
  23969. /**
  23970. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23971. */
  23972. positionIterations: number;
  23973. /**
  23974. * The unique id of the physics imposter
  23975. * set by the physics engine when adding this impostor to the array
  23976. */
  23977. uniqueId: number;
  23978. /**
  23979. * @hidden
  23980. */
  23981. soft: boolean;
  23982. /**
  23983. * @hidden
  23984. */
  23985. segments: number;
  23986. private _joints;
  23987. /**
  23988. * Initializes the physics imposter
  23989. * @param object The physics-enabled object used as the physics imposter
  23990. * @param type The type of the physics imposter
  23991. * @param _options The options for the physics imposter
  23992. * @param _scene The Babylon scene
  23993. */
  23994. constructor(
  23995. /**
  23996. * The physics-enabled object used as the physics imposter
  23997. */
  23998. object: IPhysicsEnabledObject,
  23999. /**
  24000. * The type of the physics imposter
  24001. */
  24002. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24003. /**
  24004. * This function will completly initialize this impostor.
  24005. * It will create a new body - but only if this mesh has no parent.
  24006. * If it has, this impostor will not be used other than to define the impostor
  24007. * of the child mesh.
  24008. * @hidden
  24009. */
  24010. _init(): void;
  24011. private _getPhysicsParent;
  24012. /**
  24013. * Should a new body be generated.
  24014. * @returns boolean specifying if body initialization is required
  24015. */
  24016. isBodyInitRequired(): boolean;
  24017. /**
  24018. * Sets the updated scaling
  24019. * @param updated Specifies if the scaling is updated
  24020. */
  24021. setScalingUpdated(): void;
  24022. /**
  24023. * Force a regeneration of this or the parent's impostor's body.
  24024. * Use under cautious - This will remove all joints already implemented.
  24025. */
  24026. forceUpdate(): void;
  24027. /**
  24028. * Gets the body that holds this impostor. Either its own, or its parent.
  24029. */
  24030. /**
  24031. * Set the physics body. Used mainly by the physics engine/plugin
  24032. */
  24033. physicsBody: any;
  24034. /**
  24035. * Get the parent of the physics imposter
  24036. * @returns Physics imposter or null
  24037. */
  24038. /**
  24039. * Sets the parent of the physics imposter
  24040. */
  24041. parent: Nullable<PhysicsImpostor>;
  24042. /**
  24043. * Resets the update flags
  24044. */
  24045. resetUpdateFlags(): void;
  24046. /**
  24047. * Gets the object extend size
  24048. * @returns the object extend size
  24049. */
  24050. getObjectExtendSize(): Vector3;
  24051. /**
  24052. * Gets the object center
  24053. * @returns The object center
  24054. */
  24055. getObjectCenter(): Vector3;
  24056. /**
  24057. * Get a specific parametes from the options parameter
  24058. * @param paramName The object parameter name
  24059. * @returns The object parameter
  24060. */
  24061. getParam(paramName: string): any;
  24062. /**
  24063. * Sets a specific parameter in the options given to the physics plugin
  24064. * @param paramName The parameter name
  24065. * @param value The value of the parameter
  24066. */
  24067. setParam(paramName: string, value: number): void;
  24068. /**
  24069. * Specifically change the body's mass option. Won't recreate the physics body object
  24070. * @param mass The mass of the physics imposter
  24071. */
  24072. setMass(mass: number): void;
  24073. /**
  24074. * Gets the linear velocity
  24075. * @returns linear velocity or null
  24076. */
  24077. getLinearVelocity(): Nullable<Vector3>;
  24078. /**
  24079. * Sets the linear velocity
  24080. * @param velocity linear velocity or null
  24081. */
  24082. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24083. /**
  24084. * Gets the angular velocity
  24085. * @returns angular velocity or null
  24086. */
  24087. getAngularVelocity(): Nullable<Vector3>;
  24088. /**
  24089. * Sets the angular velocity
  24090. * @param velocity The velocity or null
  24091. */
  24092. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24093. /**
  24094. * Execute a function with the physics plugin native code
  24095. * Provide a function the will have two variables - the world object and the physics body object
  24096. * @param func The function to execute with the physics plugin native code
  24097. */
  24098. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24099. /**
  24100. * Register a function that will be executed before the physics world is stepping forward
  24101. * @param func The function to execute before the physics world is stepped forward
  24102. */
  24103. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24104. /**
  24105. * Unregister a function that will be executed before the physics world is stepping forward
  24106. * @param func The function to execute before the physics world is stepped forward
  24107. */
  24108. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24109. /**
  24110. * Register a function that will be executed after the physics step
  24111. * @param func The function to execute after physics step
  24112. */
  24113. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24114. /**
  24115. * Unregisters a function that will be executed after the physics step
  24116. * @param func The function to execute after physics step
  24117. */
  24118. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24119. /**
  24120. * register a function that will be executed when this impostor collides against a different body
  24121. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24122. * @param func Callback that is executed on collision
  24123. */
  24124. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24125. /**
  24126. * Unregisters the physics imposter on contact
  24127. * @param collideAgainst The physics object to collide against
  24128. * @param func Callback to execute on collision
  24129. */
  24130. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24131. private _tmpQuat;
  24132. private _tmpQuat2;
  24133. /**
  24134. * Get the parent rotation
  24135. * @returns The parent rotation
  24136. */
  24137. getParentsRotation(): Quaternion;
  24138. /**
  24139. * this function is executed by the physics engine.
  24140. */
  24141. beforeStep: () => void;
  24142. /**
  24143. * this function is executed by the physics engine
  24144. */
  24145. afterStep: () => void;
  24146. /**
  24147. * Legacy collision detection event support
  24148. */
  24149. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24150. /**
  24151. * event and body object due to cannon's event-based architecture.
  24152. */
  24153. onCollide: (e: {
  24154. body: any;
  24155. }) => void;
  24156. /**
  24157. * Apply a force
  24158. * @param force The force to apply
  24159. * @param contactPoint The contact point for the force
  24160. * @returns The physics imposter
  24161. */
  24162. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24163. /**
  24164. * Apply an impulse
  24165. * @param force The impulse force
  24166. * @param contactPoint The contact point for the impulse force
  24167. * @returns The physics imposter
  24168. */
  24169. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24170. /**
  24171. * A help function to create a joint
  24172. * @param otherImpostor A physics imposter used to create a joint
  24173. * @param jointType The type of joint
  24174. * @param jointData The data for the joint
  24175. * @returns The physics imposter
  24176. */
  24177. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24178. /**
  24179. * Add a joint to this impostor with a different impostor
  24180. * @param otherImpostor A physics imposter used to add a joint
  24181. * @param joint The joint to add
  24182. * @returns The physics imposter
  24183. */
  24184. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24185. /**
  24186. * Add an anchor to a cloth impostor
  24187. * @param otherImpostor rigid impostor to anchor to
  24188. * @param width ratio across width from 0 to 1
  24189. * @param height ratio up height from 0 to 1
  24190. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24191. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24192. * @returns impostor the soft imposter
  24193. */
  24194. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24195. /**
  24196. * Add a hook to a rope impostor
  24197. * @param otherImpostor rigid impostor to anchor to
  24198. * @param length ratio across rope from 0 to 1
  24199. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24200. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24201. * @returns impostor the rope imposter
  24202. */
  24203. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24204. /**
  24205. * Will keep this body still, in a sleep mode.
  24206. * @returns the physics imposter
  24207. */
  24208. sleep(): PhysicsImpostor;
  24209. /**
  24210. * Wake the body up.
  24211. * @returns The physics imposter
  24212. */
  24213. wakeUp(): PhysicsImpostor;
  24214. /**
  24215. * Clones the physics imposter
  24216. * @param newObject The physics imposter clones to this physics-enabled object
  24217. * @returns A nullable physics imposter
  24218. */
  24219. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24220. /**
  24221. * Disposes the physics imposter
  24222. */
  24223. dispose(): void;
  24224. /**
  24225. * Sets the delta position
  24226. * @param position The delta position amount
  24227. */
  24228. setDeltaPosition(position: Vector3): void;
  24229. /**
  24230. * Sets the delta rotation
  24231. * @param rotation The delta rotation amount
  24232. */
  24233. setDeltaRotation(rotation: Quaternion): void;
  24234. /**
  24235. * Gets the box size of the physics imposter and stores the result in the input parameter
  24236. * @param result Stores the box size
  24237. * @returns The physics imposter
  24238. */
  24239. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24240. /**
  24241. * Gets the radius of the physics imposter
  24242. * @returns Radius of the physics imposter
  24243. */
  24244. getRadius(): number;
  24245. /**
  24246. * Sync a bone with this impostor
  24247. * @param bone The bone to sync to the impostor.
  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. */
  24253. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24254. /**
  24255. * Sync impostor to a bone
  24256. * @param bone The bone that the impostor will be synced to.
  24257. * @param boneMesh The mesh that the bone is influencing.
  24258. * @param jointPivot The pivot of the joint / bone in local space.
  24259. * @param distToJoint Optional distance from the impostor to the joint.
  24260. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24261. * @param boneAxis Optional vector3 axis the bone is aligned with
  24262. */
  24263. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24264. /**
  24265. * No-Imposter type
  24266. */
  24267. static NoImpostor: number;
  24268. /**
  24269. * Sphere-Imposter type
  24270. */
  24271. static SphereImpostor: number;
  24272. /**
  24273. * Box-Imposter type
  24274. */
  24275. static BoxImpostor: number;
  24276. /**
  24277. * Plane-Imposter type
  24278. */
  24279. static PlaneImpostor: number;
  24280. /**
  24281. * Mesh-imposter type
  24282. */
  24283. static MeshImpostor: number;
  24284. /**
  24285. * Capsule-Impostor type (Ammo.js plugin only)
  24286. */
  24287. static CapsuleImpostor: number;
  24288. /**
  24289. * Cylinder-Imposter type
  24290. */
  24291. static CylinderImpostor: number;
  24292. /**
  24293. * Particle-Imposter type
  24294. */
  24295. static ParticleImpostor: number;
  24296. /**
  24297. * Heightmap-Imposter type
  24298. */
  24299. static HeightmapImpostor: number;
  24300. /**
  24301. * ConvexHull-Impostor type (Ammo.js plugin only)
  24302. */
  24303. static ConvexHullImpostor: number;
  24304. /**
  24305. * Rope-Imposter type
  24306. */
  24307. static RopeImpostor: number;
  24308. /**
  24309. * Cloth-Imposter type
  24310. */
  24311. static ClothImpostor: number;
  24312. /**
  24313. * Softbody-Imposter type
  24314. */
  24315. static SoftbodyImpostor: number;
  24316. }
  24317. }
  24318. declare module "babylonjs/Meshes/mesh" {
  24319. import { Observable } from "babylonjs/Misc/observable";
  24320. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24321. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24322. import { Camera } from "babylonjs/Cameras/camera";
  24323. import { Scene } from "babylonjs/scene";
  24324. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24325. import { Color4 } from "babylonjs/Maths/math.color";
  24326. import { Engine } from "babylonjs/Engines/engine";
  24327. import { Node } from "babylonjs/node";
  24328. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24329. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24330. import { Buffer } from "babylonjs/Meshes/buffer";
  24331. import { Geometry } from "babylonjs/Meshes/geometry";
  24332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24333. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24334. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24335. import { Effect } from "babylonjs/Materials/effect";
  24336. import { Material } from "babylonjs/Materials/material";
  24337. import { Skeleton } from "babylonjs/Bones/skeleton";
  24338. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24339. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24340. import { Path3D } from "babylonjs/Maths/math.path";
  24341. import { Plane } from "babylonjs/Maths/math.plane";
  24342. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24343. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24344. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24345. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24346. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24347. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24348. /**
  24349. * @hidden
  24350. **/
  24351. export class _CreationDataStorage {
  24352. closePath?: boolean;
  24353. closeArray?: boolean;
  24354. idx: number[];
  24355. dashSize: number;
  24356. gapSize: number;
  24357. path3D: Path3D;
  24358. pathArray: Vector3[][];
  24359. arc: number;
  24360. radius: number;
  24361. cap: number;
  24362. tessellation: number;
  24363. }
  24364. /**
  24365. * @hidden
  24366. **/
  24367. class _InstanceDataStorage {
  24368. visibleInstances: any;
  24369. batchCache: _InstancesBatch;
  24370. instancesBufferSize: number;
  24371. instancesBuffer: Nullable<Buffer>;
  24372. instancesData: Float32Array;
  24373. overridenInstanceCount: number;
  24374. isFrozen: boolean;
  24375. previousBatch: Nullable<_InstancesBatch>;
  24376. hardwareInstancedRendering: boolean;
  24377. sideOrientation: number;
  24378. }
  24379. /**
  24380. * @hidden
  24381. **/
  24382. export class _InstancesBatch {
  24383. mustReturn: boolean;
  24384. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24385. renderSelf: boolean[];
  24386. hardwareInstancedRendering: boolean[];
  24387. }
  24388. /**
  24389. * Class used to represent renderable models
  24390. */
  24391. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24392. /**
  24393. * Mesh side orientation : usually the external or front surface
  24394. */
  24395. static readonly FRONTSIDE: number;
  24396. /**
  24397. * Mesh side orientation : usually the internal or back surface
  24398. */
  24399. static readonly BACKSIDE: number;
  24400. /**
  24401. * Mesh side orientation : both internal and external or front and back surfaces
  24402. */
  24403. static readonly DOUBLESIDE: number;
  24404. /**
  24405. * Mesh side orientation : by default, `FRONTSIDE`
  24406. */
  24407. static readonly DEFAULTSIDE: number;
  24408. /**
  24409. * Mesh cap setting : no cap
  24410. */
  24411. static readonly NO_CAP: number;
  24412. /**
  24413. * Mesh cap setting : one cap at the beginning of the mesh
  24414. */
  24415. static readonly CAP_START: number;
  24416. /**
  24417. * Mesh cap setting : one cap at the end of the mesh
  24418. */
  24419. static readonly CAP_END: number;
  24420. /**
  24421. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24422. */
  24423. static readonly CAP_ALL: number;
  24424. /**
  24425. * Mesh pattern setting : no flip or rotate
  24426. */
  24427. static readonly NO_FLIP: number;
  24428. /**
  24429. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24430. */
  24431. static readonly FLIP_TILE: number;
  24432. /**
  24433. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24434. */
  24435. static readonly ROTATE_TILE: number;
  24436. /**
  24437. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24438. */
  24439. static readonly FLIP_ROW: number;
  24440. /**
  24441. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24442. */
  24443. static readonly ROTATE_ROW: number;
  24444. /**
  24445. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24446. */
  24447. static readonly FLIP_N_ROTATE_TILE: number;
  24448. /**
  24449. * Mesh pattern setting : rotate pattern and rotate
  24450. */
  24451. static readonly FLIP_N_ROTATE_ROW: number;
  24452. /**
  24453. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24454. */
  24455. static readonly CENTER: number;
  24456. /**
  24457. * Mesh tile positioning : part tiles on left
  24458. */
  24459. static readonly LEFT: number;
  24460. /**
  24461. * Mesh tile positioning : part tiles on right
  24462. */
  24463. static readonly RIGHT: number;
  24464. /**
  24465. * Mesh tile positioning : part tiles on top
  24466. */
  24467. static readonly TOP: number;
  24468. /**
  24469. * Mesh tile positioning : part tiles on bottom
  24470. */
  24471. static readonly BOTTOM: number;
  24472. /**
  24473. * Gets the default side orientation.
  24474. * @param orientation the orientation to value to attempt to get
  24475. * @returns the default orientation
  24476. * @hidden
  24477. */
  24478. static _GetDefaultSideOrientation(orientation?: number): number;
  24479. private _internalMeshDataInfo;
  24480. /**
  24481. * An event triggered before rendering the mesh
  24482. */
  24483. readonly onBeforeRenderObservable: Observable<Mesh>;
  24484. /**
  24485. * An event triggered before binding the mesh
  24486. */
  24487. readonly onBeforeBindObservable: Observable<Mesh>;
  24488. /**
  24489. * An event triggered after rendering the mesh
  24490. */
  24491. readonly onAfterRenderObservable: Observable<Mesh>;
  24492. /**
  24493. * An event triggered before drawing the mesh
  24494. */
  24495. readonly onBeforeDrawObservable: Observable<Mesh>;
  24496. private _onBeforeDrawObserver;
  24497. /**
  24498. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24499. */
  24500. onBeforeDraw: () => void;
  24501. readonly hasInstances: boolean;
  24502. /**
  24503. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24504. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24505. */
  24506. delayLoadState: number;
  24507. /**
  24508. * Gets the list of instances created from this mesh
  24509. * it is not supposed to be modified manually.
  24510. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24511. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24512. */
  24513. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24514. /**
  24515. * Gets the file containing delay loading data for this mesh
  24516. */
  24517. delayLoadingFile: string;
  24518. /** @hidden */
  24519. _binaryInfo: any;
  24520. /**
  24521. * User defined function used to change how LOD level selection is done
  24522. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24523. */
  24524. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24525. /**
  24526. * Gets or sets the morph target manager
  24527. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24528. */
  24529. morphTargetManager: Nullable<MorphTargetManager>;
  24530. /** @hidden */
  24531. _creationDataStorage: Nullable<_CreationDataStorage>;
  24532. /** @hidden */
  24533. _geometry: Nullable<Geometry>;
  24534. /** @hidden */
  24535. _delayInfo: Array<string>;
  24536. /** @hidden */
  24537. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24538. /** @hidden */
  24539. _instanceDataStorage: _InstanceDataStorage;
  24540. private _effectiveMaterial;
  24541. /** @hidden */
  24542. _shouldGenerateFlatShading: boolean;
  24543. /** @hidden */
  24544. _originalBuilderSideOrientation: number;
  24545. /**
  24546. * Use this property to change the original side orientation defined at construction time
  24547. */
  24548. overrideMaterialSideOrientation: Nullable<number>;
  24549. /**
  24550. * Gets the source mesh (the one used to clone this one from)
  24551. */
  24552. readonly source: Nullable<Mesh>;
  24553. /**
  24554. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24555. */
  24556. isUnIndexed: boolean;
  24557. /**
  24558. * @constructor
  24559. * @param name The value used by scene.getMeshByName() to do a lookup.
  24560. * @param scene The scene to add this mesh to.
  24561. * @param parent The parent of this mesh, if it has one
  24562. * @param source An optional Mesh from which geometry is shared, cloned.
  24563. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24564. * When false, achieved by calling a clone(), also passing False.
  24565. * This will make creation of children, recursive.
  24566. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24567. */
  24568. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24569. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24570. doNotInstantiate: boolean;
  24571. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24572. /**
  24573. * Gets the class name
  24574. * @returns the string "Mesh".
  24575. */
  24576. getClassName(): string;
  24577. /** @hidden */
  24578. readonly _isMesh: boolean;
  24579. /**
  24580. * Returns a description of this mesh
  24581. * @param fullDetails define if full details about this mesh must be used
  24582. * @returns a descriptive string representing this mesh
  24583. */
  24584. toString(fullDetails?: boolean): string;
  24585. /** @hidden */
  24586. _unBindEffect(): void;
  24587. /**
  24588. * Gets a boolean indicating if this mesh has LOD
  24589. */
  24590. readonly hasLODLevels: boolean;
  24591. /**
  24592. * Gets the list of MeshLODLevel associated with the current mesh
  24593. * @returns an array of MeshLODLevel
  24594. */
  24595. getLODLevels(): MeshLODLevel[];
  24596. private _sortLODLevels;
  24597. /**
  24598. * Add a mesh as LOD level triggered at the given distance.
  24599. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24600. * @param distance The distance from the center of the object to show this level
  24601. * @param mesh The mesh to be added as LOD level (can be null)
  24602. * @return This mesh (for chaining)
  24603. */
  24604. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24605. /**
  24606. * Returns the LOD level mesh at the passed distance or null if not found.
  24607. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24608. * @param distance The distance from the center of the object to show this level
  24609. * @returns a Mesh or `null`
  24610. */
  24611. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24612. /**
  24613. * Remove a mesh from the LOD array
  24614. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24615. * @param mesh defines the mesh to be removed
  24616. * @return This mesh (for chaining)
  24617. */
  24618. removeLODLevel(mesh: Mesh): Mesh;
  24619. /**
  24620. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24621. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24622. * @param camera defines the camera to use to compute distance
  24623. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24624. * @return This mesh (for chaining)
  24625. */
  24626. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24627. /**
  24628. * Gets the mesh internal Geometry object
  24629. */
  24630. readonly geometry: Nullable<Geometry>;
  24631. /**
  24632. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24633. * @returns the total number of vertices
  24634. */
  24635. getTotalVertices(): number;
  24636. /**
  24637. * Returns the content of an associated vertex buffer
  24638. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24639. * - VertexBuffer.PositionKind
  24640. * - VertexBuffer.UVKind
  24641. * - VertexBuffer.UV2Kind
  24642. * - VertexBuffer.UV3Kind
  24643. * - VertexBuffer.UV4Kind
  24644. * - VertexBuffer.UV5Kind
  24645. * - VertexBuffer.UV6Kind
  24646. * - VertexBuffer.ColorKind
  24647. * - VertexBuffer.MatricesIndicesKind
  24648. * - VertexBuffer.MatricesIndicesExtraKind
  24649. * - VertexBuffer.MatricesWeightsKind
  24650. * - VertexBuffer.MatricesWeightsExtraKind
  24651. * @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
  24652. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24653. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24654. */
  24655. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24656. /**
  24657. * Returns the mesh VertexBuffer object from the requested `kind`
  24658. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24659. * - VertexBuffer.PositionKind
  24660. * - VertexBuffer.NormalKind
  24661. * - VertexBuffer.UVKind
  24662. * - VertexBuffer.UV2Kind
  24663. * - VertexBuffer.UV3Kind
  24664. * - VertexBuffer.UV4Kind
  24665. * - VertexBuffer.UV5Kind
  24666. * - VertexBuffer.UV6Kind
  24667. * - VertexBuffer.ColorKind
  24668. * - VertexBuffer.MatricesIndicesKind
  24669. * - VertexBuffer.MatricesIndicesExtraKind
  24670. * - VertexBuffer.MatricesWeightsKind
  24671. * - VertexBuffer.MatricesWeightsExtraKind
  24672. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24673. */
  24674. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24675. /**
  24676. * Tests if a specific vertex buffer is associated with this mesh
  24677. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24678. * - VertexBuffer.PositionKind
  24679. * - VertexBuffer.NormalKind
  24680. * - VertexBuffer.UVKind
  24681. * - VertexBuffer.UV2Kind
  24682. * - VertexBuffer.UV3Kind
  24683. * - VertexBuffer.UV4Kind
  24684. * - VertexBuffer.UV5Kind
  24685. * - VertexBuffer.UV6Kind
  24686. * - VertexBuffer.ColorKind
  24687. * - VertexBuffer.MatricesIndicesKind
  24688. * - VertexBuffer.MatricesIndicesExtraKind
  24689. * - VertexBuffer.MatricesWeightsKind
  24690. * - VertexBuffer.MatricesWeightsExtraKind
  24691. * @returns a boolean
  24692. */
  24693. isVerticesDataPresent(kind: string): boolean;
  24694. /**
  24695. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24696. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24697. * - VertexBuffer.PositionKind
  24698. * - VertexBuffer.UVKind
  24699. * - VertexBuffer.UV2Kind
  24700. * - VertexBuffer.UV3Kind
  24701. * - VertexBuffer.UV4Kind
  24702. * - VertexBuffer.UV5Kind
  24703. * - VertexBuffer.UV6Kind
  24704. * - VertexBuffer.ColorKind
  24705. * - VertexBuffer.MatricesIndicesKind
  24706. * - VertexBuffer.MatricesIndicesExtraKind
  24707. * - VertexBuffer.MatricesWeightsKind
  24708. * - VertexBuffer.MatricesWeightsExtraKind
  24709. * @returns a boolean
  24710. */
  24711. isVertexBufferUpdatable(kind: string): boolean;
  24712. /**
  24713. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24714. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24715. * - VertexBuffer.PositionKind
  24716. * - VertexBuffer.NormalKind
  24717. * - VertexBuffer.UVKind
  24718. * - VertexBuffer.UV2Kind
  24719. * - VertexBuffer.UV3Kind
  24720. * - VertexBuffer.UV4Kind
  24721. * - VertexBuffer.UV5Kind
  24722. * - VertexBuffer.UV6Kind
  24723. * - VertexBuffer.ColorKind
  24724. * - VertexBuffer.MatricesIndicesKind
  24725. * - VertexBuffer.MatricesIndicesExtraKind
  24726. * - VertexBuffer.MatricesWeightsKind
  24727. * - VertexBuffer.MatricesWeightsExtraKind
  24728. * @returns an array of strings
  24729. */
  24730. getVerticesDataKinds(): string[];
  24731. /**
  24732. * Returns a positive integer : the total number of indices in this mesh geometry.
  24733. * @returns the numner of indices or zero if the mesh has no geometry.
  24734. */
  24735. getTotalIndices(): number;
  24736. /**
  24737. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24738. * @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.
  24739. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24740. * @returns the indices array or an empty array if the mesh has no geometry
  24741. */
  24742. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24743. readonly isBlocked: boolean;
  24744. /**
  24745. * Determine if the current mesh is ready to be rendered
  24746. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24747. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24748. * @returns true if all associated assets are ready (material, textures, shaders)
  24749. */
  24750. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24751. /**
  24752. * 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.
  24753. */
  24754. readonly areNormalsFrozen: boolean;
  24755. /**
  24756. * 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.
  24757. * @returns the current mesh
  24758. */
  24759. freezeNormals(): Mesh;
  24760. /**
  24761. * 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
  24762. * @returns the current mesh
  24763. */
  24764. unfreezeNormals(): Mesh;
  24765. /**
  24766. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24767. */
  24768. overridenInstanceCount: number;
  24769. /** @hidden */
  24770. _preActivate(): Mesh;
  24771. /** @hidden */
  24772. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24773. /** @hidden */
  24774. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24775. /**
  24776. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24777. * This means the mesh underlying bounding box and sphere are recomputed.
  24778. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24779. * @returns the current mesh
  24780. */
  24781. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24782. /** @hidden */
  24783. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24784. /**
  24785. * This function will subdivide the mesh into multiple submeshes
  24786. * @param count defines the expected number of submeshes
  24787. */
  24788. subdivide(count: number): void;
  24789. /**
  24790. * Copy a FloatArray into a specific associated vertex buffer
  24791. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24792. * - VertexBuffer.PositionKind
  24793. * - VertexBuffer.UVKind
  24794. * - VertexBuffer.UV2Kind
  24795. * - VertexBuffer.UV3Kind
  24796. * - VertexBuffer.UV4Kind
  24797. * - VertexBuffer.UV5Kind
  24798. * - VertexBuffer.UV6Kind
  24799. * - VertexBuffer.ColorKind
  24800. * - VertexBuffer.MatricesIndicesKind
  24801. * - VertexBuffer.MatricesIndicesExtraKind
  24802. * - VertexBuffer.MatricesWeightsKind
  24803. * - VertexBuffer.MatricesWeightsExtraKind
  24804. * @param data defines the data source
  24805. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24806. * @param stride defines the data stride size (can be null)
  24807. * @returns the current mesh
  24808. */
  24809. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24810. /**
  24811. * Delete a vertex buffer associated with this mesh
  24812. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24813. * - VertexBuffer.PositionKind
  24814. * - VertexBuffer.UVKind
  24815. * - VertexBuffer.UV2Kind
  24816. * - VertexBuffer.UV3Kind
  24817. * - VertexBuffer.UV4Kind
  24818. * - VertexBuffer.UV5Kind
  24819. * - VertexBuffer.UV6Kind
  24820. * - VertexBuffer.ColorKind
  24821. * - VertexBuffer.MatricesIndicesKind
  24822. * - VertexBuffer.MatricesIndicesExtraKind
  24823. * - VertexBuffer.MatricesWeightsKind
  24824. * - VertexBuffer.MatricesWeightsExtraKind
  24825. */
  24826. removeVerticesData(kind: string): void;
  24827. /**
  24828. * Flags an associated vertex buffer as updatable
  24829. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24830. * - VertexBuffer.PositionKind
  24831. * - VertexBuffer.UVKind
  24832. * - VertexBuffer.UV2Kind
  24833. * - VertexBuffer.UV3Kind
  24834. * - VertexBuffer.UV4Kind
  24835. * - VertexBuffer.UV5Kind
  24836. * - VertexBuffer.UV6Kind
  24837. * - VertexBuffer.ColorKind
  24838. * - VertexBuffer.MatricesIndicesKind
  24839. * - VertexBuffer.MatricesIndicesExtraKind
  24840. * - VertexBuffer.MatricesWeightsKind
  24841. * - VertexBuffer.MatricesWeightsExtraKind
  24842. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24843. */
  24844. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24845. /**
  24846. * Sets the mesh global Vertex Buffer
  24847. * @param buffer defines the buffer to use
  24848. * @returns the current mesh
  24849. */
  24850. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24851. /**
  24852. * Update a specific associated vertex buffer
  24853. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24854. * - VertexBuffer.PositionKind
  24855. * - VertexBuffer.UVKind
  24856. * - VertexBuffer.UV2Kind
  24857. * - VertexBuffer.UV3Kind
  24858. * - VertexBuffer.UV4Kind
  24859. * - VertexBuffer.UV5Kind
  24860. * - VertexBuffer.UV6Kind
  24861. * - VertexBuffer.ColorKind
  24862. * - VertexBuffer.MatricesIndicesKind
  24863. * - VertexBuffer.MatricesIndicesExtraKind
  24864. * - VertexBuffer.MatricesWeightsKind
  24865. * - VertexBuffer.MatricesWeightsExtraKind
  24866. * @param data defines the data source
  24867. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24868. * @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)
  24869. * @returns the current mesh
  24870. */
  24871. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24872. /**
  24873. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24874. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24875. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24876. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24877. * @returns the current mesh
  24878. */
  24879. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24880. /**
  24881. * Creates a un-shared specific occurence of the geometry for the mesh.
  24882. * @returns the current mesh
  24883. */
  24884. makeGeometryUnique(): Mesh;
  24885. /**
  24886. * Set the index buffer of this mesh
  24887. * @param indices defines the source data
  24888. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24889. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24890. * @returns the current mesh
  24891. */
  24892. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24893. /**
  24894. * Update the current index buffer
  24895. * @param indices defines the source data
  24896. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24897. * @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)
  24898. * @returns the current mesh
  24899. */
  24900. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24901. /**
  24902. * Invert the geometry to move from a right handed system to a left handed one.
  24903. * @returns the current mesh
  24904. */
  24905. toLeftHanded(): Mesh;
  24906. /** @hidden */
  24907. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24908. /** @hidden */
  24909. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24910. /**
  24911. * Registers for this mesh a javascript function called just before the rendering process
  24912. * @param func defines the function to call before rendering this mesh
  24913. * @returns the current mesh
  24914. */
  24915. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24916. /**
  24917. * Disposes a previously registered javascript function called before the rendering
  24918. * @param func defines the function to remove
  24919. * @returns the current mesh
  24920. */
  24921. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24922. /**
  24923. * Registers for this mesh a javascript function called just after the rendering is complete
  24924. * @param func defines the function to call after rendering this mesh
  24925. * @returns the current mesh
  24926. */
  24927. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24928. /**
  24929. * Disposes a previously registered javascript function called after the rendering.
  24930. * @param func defines the function to remove
  24931. * @returns the current mesh
  24932. */
  24933. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24934. /** @hidden */
  24935. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24936. /** @hidden */
  24937. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24938. /** @hidden */
  24939. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24940. /** @hidden */
  24941. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24942. /** @hidden */
  24943. _rebuild(): void;
  24944. /** @hidden */
  24945. _freeze(): void;
  24946. /** @hidden */
  24947. _unFreeze(): void;
  24948. /**
  24949. * 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
  24950. * @param subMesh defines the subMesh to render
  24951. * @param enableAlphaMode defines if alpha mode can be changed
  24952. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24953. * @returns the current mesh
  24954. */
  24955. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24956. private _onBeforeDraw;
  24957. /**
  24958. * Renormalize the mesh and patch it up if there are no weights
  24959. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24960. * However in the case of zero weights then we set just a single influence to 1.
  24961. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24962. */
  24963. cleanMatrixWeights(): void;
  24964. private normalizeSkinFourWeights;
  24965. private normalizeSkinWeightsAndExtra;
  24966. /**
  24967. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24968. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24969. * the user know there was an issue with importing the mesh
  24970. * @returns a validation object with skinned, valid and report string
  24971. */
  24972. validateSkinning(): {
  24973. skinned: boolean;
  24974. valid: boolean;
  24975. report: string;
  24976. };
  24977. /** @hidden */
  24978. _checkDelayState(): Mesh;
  24979. private _queueLoad;
  24980. /**
  24981. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24982. * A mesh is in the frustum if its bounding box intersects the frustum
  24983. * @param frustumPlanes defines the frustum to test
  24984. * @returns true if the mesh is in the frustum planes
  24985. */
  24986. isInFrustum(frustumPlanes: Plane[]): boolean;
  24987. /**
  24988. * Sets the mesh material by the material or multiMaterial `id` property
  24989. * @param id is a string identifying the material or the multiMaterial
  24990. * @returns the current mesh
  24991. */
  24992. setMaterialByID(id: string): Mesh;
  24993. /**
  24994. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24995. * @returns an array of IAnimatable
  24996. */
  24997. getAnimatables(): IAnimatable[];
  24998. /**
  24999. * Modifies the mesh geometry according to the passed transformation matrix.
  25000. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25001. * The mesh normals are modified using the same transformation.
  25002. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25003. * @param transform defines the transform matrix to use
  25004. * @see http://doc.babylonjs.com/resources/baking_transformations
  25005. * @returns the current mesh
  25006. */
  25007. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25008. /**
  25009. * Modifies the mesh geometry according to its own current World Matrix.
  25010. * The mesh World Matrix is then reset.
  25011. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25012. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25013. * @see http://doc.babylonjs.com/resources/baking_transformations
  25014. * @returns the current mesh
  25015. */
  25016. bakeCurrentTransformIntoVertices(): Mesh;
  25017. /** @hidden */
  25018. readonly _positions: Nullable<Vector3[]>;
  25019. /** @hidden */
  25020. _resetPointsArrayCache(): Mesh;
  25021. /** @hidden */
  25022. _generatePointsArray(): boolean;
  25023. /**
  25024. * Returns a new Mesh object generated from the current mesh properties.
  25025. * This method must not get confused with createInstance()
  25026. * @param name is a string, the name given to the new mesh
  25027. * @param newParent can be any Node object (default `null`)
  25028. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25029. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25030. * @returns a new mesh
  25031. */
  25032. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25033. /**
  25034. * Releases resources associated with this mesh.
  25035. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25036. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25037. */
  25038. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25039. /** @hidden */
  25040. _disposeInstanceSpecificData(): void;
  25041. /**
  25042. * Modifies the mesh geometry according to a displacement map.
  25043. * 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.
  25044. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25045. * @param url is a string, the URL from the image file is to be downloaded.
  25046. * @param minHeight is the lower limit of the displacement.
  25047. * @param maxHeight is the upper limit of the displacement.
  25048. * @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.
  25049. * @param uvOffset is an optional vector2 used to offset UV.
  25050. * @param uvScale is an optional vector2 used to scale UV.
  25051. * @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.
  25052. * @returns the Mesh.
  25053. */
  25054. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25055. /**
  25056. * Modifies the mesh geometry according to a displacementMap buffer.
  25057. * 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.
  25058. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25059. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25060. * @param heightMapWidth is the width of the buffer image.
  25061. * @param heightMapHeight is the height of the buffer image.
  25062. * @param minHeight is the lower limit of the displacement.
  25063. * @param maxHeight is the upper limit of the displacement.
  25064. * @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.
  25065. * @param uvOffset is an optional vector2 used to offset UV.
  25066. * @param uvScale is an optional vector2 used to scale UV.
  25067. * @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.
  25068. * @returns the Mesh.
  25069. */
  25070. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25071. /**
  25072. * Modify the mesh to get a flat shading rendering.
  25073. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25074. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25075. * @returns current mesh
  25076. */
  25077. convertToFlatShadedMesh(): Mesh;
  25078. /**
  25079. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25080. * In other words, more vertices, no more indices and a single bigger VBO.
  25081. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25082. * @returns current mesh
  25083. */
  25084. convertToUnIndexedMesh(): Mesh;
  25085. /**
  25086. * Inverses facet orientations.
  25087. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25088. * @param flipNormals will also inverts the normals
  25089. * @returns current mesh
  25090. */
  25091. flipFaces(flipNormals?: boolean): Mesh;
  25092. /**
  25093. * Increase the number of facets and hence vertices in a mesh
  25094. * Vertex normals are interpolated from existing vertex normals
  25095. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25096. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25097. */
  25098. increaseVertices(numberPerEdge: number): void;
  25099. /**
  25100. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25101. * This will undo any application of covertToFlatShadedMesh
  25102. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25103. */
  25104. forceSharedVertices(): void;
  25105. /** @hidden */
  25106. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25107. /** @hidden */
  25108. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25109. /**
  25110. * Creates a new InstancedMesh object from the mesh model.
  25111. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25112. * @param name defines the name of the new instance
  25113. * @returns a new InstancedMesh
  25114. */
  25115. createInstance(name: string): InstancedMesh;
  25116. /**
  25117. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25118. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25119. * @returns the current mesh
  25120. */
  25121. synchronizeInstances(): Mesh;
  25122. /**
  25123. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25124. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25125. * This should be used together with the simplification to avoid disappearing triangles.
  25126. * @param successCallback an optional success callback to be called after the optimization finished.
  25127. * @returns the current mesh
  25128. */
  25129. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25130. /**
  25131. * Serialize current mesh
  25132. * @param serializationObject defines the object which will receive the serialization data
  25133. */
  25134. serialize(serializationObject: any): void;
  25135. /** @hidden */
  25136. _syncGeometryWithMorphTargetManager(): void;
  25137. /** @hidden */
  25138. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25139. /**
  25140. * Returns a new Mesh object parsed from the source provided.
  25141. * @param parsedMesh is the source
  25142. * @param scene defines the hosting scene
  25143. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25144. * @returns a new Mesh
  25145. */
  25146. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25147. /**
  25148. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25149. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25150. * @param name defines the name of the mesh to create
  25151. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25152. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25153. * @param closePath creates a seam between the first and the last points of each path of the path array
  25154. * @param offset is taken in account only if the `pathArray` is containing a single path
  25155. * @param scene defines the hosting scene
  25156. * @param updatable defines if the mesh must be flagged as updatable
  25157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25158. * @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)
  25159. * @returns a new Mesh
  25160. */
  25161. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25162. /**
  25163. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25164. * @param name defines the name of the mesh to create
  25165. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25166. * @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
  25167. * @param scene defines the hosting scene
  25168. * @param updatable defines if the mesh must be flagged as updatable
  25169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25170. * @returns a new Mesh
  25171. */
  25172. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25173. /**
  25174. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25175. * @param name defines the name of the mesh to create
  25176. * @param size sets the size (float) of each box side (default 1)
  25177. * @param scene defines the hosting scene
  25178. * @param updatable defines if the mesh must be flagged as updatable
  25179. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25180. * @returns a new Mesh
  25181. */
  25182. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25183. /**
  25184. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25185. * @param name defines the name of the mesh to create
  25186. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25187. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25188. * @param scene defines the hosting scene
  25189. * @param updatable defines if the mesh must be flagged as updatable
  25190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25191. * @returns a new Mesh
  25192. */
  25193. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25194. /**
  25195. * Creates a hemisphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25198. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25199. * @param scene defines the hosting scene
  25200. * @returns a new Mesh
  25201. */
  25202. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25203. /**
  25204. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25205. * @param name defines the name of the mesh to create
  25206. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25207. * @param diameterTop set the top cap diameter (floats, default 1)
  25208. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25209. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25210. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25211. * @param scene defines the hosting scene
  25212. * @param updatable defines if the mesh must be flagged as updatable
  25213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25214. * @returns a new Mesh
  25215. */
  25216. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25217. /**
  25218. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25219. * @param name defines the name of the mesh to create
  25220. * @param diameter sets the diameter size (float) of the torus (default 1)
  25221. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25222. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25223. * @param scene defines the hosting scene
  25224. * @param updatable defines if the mesh must be flagged as updatable
  25225. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25226. * @returns a new Mesh
  25227. */
  25228. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25229. /**
  25230. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25231. * @param name defines the name of the mesh to create
  25232. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25233. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25234. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25235. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25236. * @param p the number of windings on X axis (positive integers, default 2)
  25237. * @param q the number of windings on Y axis (positive integers, default 3)
  25238. * @param scene defines the hosting scene
  25239. * @param updatable defines if the mesh must be flagged as updatable
  25240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25241. * @returns a new Mesh
  25242. */
  25243. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25244. /**
  25245. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25246. * @param name defines the name of the mesh to create
  25247. * @param points is an array successive Vector3
  25248. * @param scene defines the hosting scene
  25249. * @param updatable defines if the mesh must be flagged as updatable
  25250. * @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).
  25251. * @returns a new Mesh
  25252. */
  25253. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25254. /**
  25255. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25256. * @param name defines the name of the mesh to create
  25257. * @param points is an array successive Vector3
  25258. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25259. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25260. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25261. * @param scene defines the hosting scene
  25262. * @param updatable defines if the mesh must be flagged as updatable
  25263. * @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)
  25264. * @returns a new Mesh
  25265. */
  25266. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25267. /**
  25268. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25269. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25270. * 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.
  25271. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25272. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25273. * Remember you can only change the shape positions, not their number when updating a polygon.
  25274. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25275. * @param name defines the name of the mesh to create
  25276. * @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
  25277. * @param scene defines the hosting scene
  25278. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25279. * @param updatable defines if the mesh must be flagged as updatable
  25280. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25281. * @param earcutInjection can be used to inject your own earcut reference
  25282. * @returns a new Mesh
  25283. */
  25284. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25285. /**
  25286. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25287. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25288. * @param name defines the name of the mesh to create
  25289. * @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
  25290. * @param depth defines the height of extrusion
  25291. * @param scene defines the hosting scene
  25292. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25293. * @param updatable defines if the mesh must be flagged as updatable
  25294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25295. * @param earcutInjection can be used to inject your own earcut reference
  25296. * @returns a new Mesh
  25297. */
  25298. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25299. /**
  25300. * Creates an extruded shape mesh.
  25301. * 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
  25302. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25303. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25304. * @param name defines the name of the mesh to create
  25305. * @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
  25306. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25307. * @param scale is the value to scale the shape
  25308. * @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
  25309. * @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
  25310. * @param scene defines the hosting scene
  25311. * @param updatable defines if the mesh must be flagged as updatable
  25312. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25313. * @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)
  25314. * @returns a new Mesh
  25315. */
  25316. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25317. /**
  25318. * Creates an custom extruded shape mesh.
  25319. * The custom extrusion is a parametric shape.
  25320. * It has no predefined shape. Its final shape will depend on the input parameters.
  25321. * Please consider using the same method from the MeshBuilder class instead
  25322. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25323. * @param name defines the name of the mesh to create
  25324. * @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
  25325. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25326. * @param scaleFunction is a custom Javascript function called on each path point
  25327. * @param rotationFunction is a custom Javascript function called on each path point
  25328. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25329. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25330. * @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
  25331. * @param scene defines the hosting scene
  25332. * @param updatable defines if the mesh must be flagged as updatable
  25333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25334. * @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)
  25335. * @returns a new Mesh
  25336. */
  25337. 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;
  25338. /**
  25339. * Creates lathe mesh.
  25340. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25341. * Please consider using the same method from the MeshBuilder class instead
  25342. * @param name defines the name of the mesh to create
  25343. * @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
  25344. * @param radius is the radius value of the lathe
  25345. * @param tessellation is the side number of the lathe.
  25346. * @param scene defines the hosting scene
  25347. * @param updatable defines if the mesh must be flagged as updatable
  25348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25349. * @returns a new Mesh
  25350. */
  25351. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25352. /**
  25353. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25354. * @param name defines the name of the mesh to create
  25355. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25356. * @param scene defines the hosting scene
  25357. * @param updatable defines if the mesh must be flagged as updatable
  25358. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25359. * @returns a new Mesh
  25360. */
  25361. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25362. /**
  25363. * Creates a ground mesh.
  25364. * Please consider using the same method from the MeshBuilder class instead
  25365. * @param name defines the name of the mesh to create
  25366. * @param width set the width of the ground
  25367. * @param height set the height of the ground
  25368. * @param subdivisions sets the number of subdivisions per side
  25369. * @param scene defines the hosting scene
  25370. * @param updatable defines if the mesh must be flagged as updatable
  25371. * @returns a new Mesh
  25372. */
  25373. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25374. /**
  25375. * Creates a tiled ground mesh.
  25376. * Please consider using the same method from the MeshBuilder class instead
  25377. * @param name defines the name of the mesh to create
  25378. * @param xmin set the ground minimum X coordinate
  25379. * @param zmin set the ground minimum Y coordinate
  25380. * @param xmax set the ground maximum X coordinate
  25381. * @param zmax set the ground maximum Z coordinate
  25382. * @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
  25383. * @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
  25384. * @param scene defines the hosting scene
  25385. * @param updatable defines if the mesh must be flagged as updatable
  25386. * @returns a new Mesh
  25387. */
  25388. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25389. w: number;
  25390. h: number;
  25391. }, precision: {
  25392. w: number;
  25393. h: number;
  25394. }, scene: Scene, updatable?: boolean): Mesh;
  25395. /**
  25396. * Creates a ground mesh from a height map.
  25397. * Please consider using the same method from the MeshBuilder class instead
  25398. * @see http://doc.babylonjs.com/babylon101/height_map
  25399. * @param name defines the name of the mesh to create
  25400. * @param url sets the URL of the height map image resource
  25401. * @param width set the ground width size
  25402. * @param height set the ground height size
  25403. * @param subdivisions sets the number of subdivision per side
  25404. * @param minHeight is the minimum altitude on the ground
  25405. * @param maxHeight is the maximum altitude on the ground
  25406. * @param scene defines the hosting scene
  25407. * @param updatable defines if the mesh must be flagged as updatable
  25408. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25409. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25410. * @returns a new Mesh
  25411. */
  25412. 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;
  25413. /**
  25414. * Creates a tube mesh.
  25415. * The tube is a parametric shape.
  25416. * It has no predefined shape. Its final shape will depend on the input parameters.
  25417. * Please consider using the same method from the MeshBuilder class instead
  25418. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25419. * @param name defines the name of the mesh to create
  25420. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25421. * @param radius sets the tube radius size
  25422. * @param tessellation is the number of sides on the tubular surface
  25423. * @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
  25424. * @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
  25425. * @param scene defines the hosting scene
  25426. * @param updatable defines if the mesh must be flagged as updatable
  25427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25428. * @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)
  25429. * @returns a new Mesh
  25430. */
  25431. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25432. (i: number, distance: number): number;
  25433. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25434. /**
  25435. * Creates a polyhedron mesh.
  25436. * Please consider using the same method from the MeshBuilder class instead.
  25437. * * 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
  25438. * * The parameter `size` (positive float, default 1) sets the polygon size
  25439. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25440. * * 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`
  25441. * * 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
  25442. * * 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)`)
  25443. * * 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
  25444. * * 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
  25445. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25446. * * If you create a double-sided mesh, you can choose what parts of 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
  25447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25448. * @param name defines the name of the mesh to create
  25449. * @param options defines the options used to create the mesh
  25450. * @param scene defines the hosting scene
  25451. * @returns a new Mesh
  25452. */
  25453. static CreatePolyhedron(name: string, options: {
  25454. type?: number;
  25455. size?: number;
  25456. sizeX?: number;
  25457. sizeY?: number;
  25458. sizeZ?: number;
  25459. custom?: any;
  25460. faceUV?: Vector4[];
  25461. faceColors?: Color4[];
  25462. updatable?: boolean;
  25463. sideOrientation?: number;
  25464. }, scene: Scene): Mesh;
  25465. /**
  25466. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25467. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25468. * * 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`)
  25469. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25470. * * 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
  25471. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25472. * * If you create a double-sided mesh, you can choose what parts of 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
  25473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25474. * @param name defines the name of the mesh
  25475. * @param options defines the options used to create the mesh
  25476. * @param scene defines the hosting scene
  25477. * @returns a new Mesh
  25478. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25479. */
  25480. static CreateIcoSphere(name: string, options: {
  25481. radius?: number;
  25482. flat?: boolean;
  25483. subdivisions?: number;
  25484. sideOrientation?: number;
  25485. updatable?: boolean;
  25486. }, scene: Scene): Mesh;
  25487. /**
  25488. * Creates a decal mesh.
  25489. * Please consider using the same method from the MeshBuilder class instead.
  25490. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25491. * @param name defines the name of the mesh
  25492. * @param sourceMesh defines the mesh receiving the decal
  25493. * @param position sets the position of the decal in world coordinates
  25494. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25495. * @param size sets the decal scaling
  25496. * @param angle sets the angle to rotate the decal
  25497. * @returns a new Mesh
  25498. */
  25499. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25500. /**
  25501. * Prepare internal position array for software CPU skinning
  25502. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25503. */
  25504. setPositionsForCPUSkinning(): Float32Array;
  25505. /**
  25506. * Prepare internal normal array for software CPU skinning
  25507. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25508. */
  25509. setNormalsForCPUSkinning(): Float32Array;
  25510. /**
  25511. * Updates the vertex buffer by applying transformation from the bones
  25512. * @param skeleton defines the skeleton to apply to current mesh
  25513. * @returns the current mesh
  25514. */
  25515. applySkeleton(skeleton: Skeleton): Mesh;
  25516. /**
  25517. * 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
  25518. * @param meshes defines the list of meshes to scan
  25519. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25520. */
  25521. static MinMax(meshes: AbstractMesh[]): {
  25522. min: Vector3;
  25523. max: Vector3;
  25524. };
  25525. /**
  25526. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25527. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25528. * @returns a vector3
  25529. */
  25530. static Center(meshesOrMinMaxVector: {
  25531. min: Vector3;
  25532. max: Vector3;
  25533. } | AbstractMesh[]): Vector3;
  25534. /**
  25535. * Merge the array of meshes into a single mesh for performance reasons.
  25536. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25537. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25538. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25539. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25540. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25541. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25542. * @returns a new mesh
  25543. */
  25544. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25545. /** @hidden */
  25546. addInstance(instance: InstancedMesh): void;
  25547. /** @hidden */
  25548. removeInstance(instance: InstancedMesh): void;
  25549. }
  25550. }
  25551. declare module "babylonjs/Cameras/camera" {
  25552. import { SmartArray } from "babylonjs/Misc/smartArray";
  25553. import { Observable } from "babylonjs/Misc/observable";
  25554. import { Nullable } from "babylonjs/types";
  25555. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25556. import { Scene } from "babylonjs/scene";
  25557. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25558. import { Node } from "babylonjs/node";
  25559. import { Mesh } from "babylonjs/Meshes/mesh";
  25560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25561. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25562. import { Viewport } from "babylonjs/Maths/math.viewport";
  25563. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25564. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25565. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25566. import { Ray } from "babylonjs/Culling/ray";
  25567. /**
  25568. * This is the base class of all the camera used in the application.
  25569. * @see http://doc.babylonjs.com/features/cameras
  25570. */
  25571. export class Camera extends Node {
  25572. /** @hidden */
  25573. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25574. /**
  25575. * This is the default projection mode used by the cameras.
  25576. * It helps recreating a feeling of perspective and better appreciate depth.
  25577. * This is the best way to simulate real life cameras.
  25578. */
  25579. static readonly PERSPECTIVE_CAMERA: number;
  25580. /**
  25581. * This helps creating camera with an orthographic mode.
  25582. * 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.
  25583. */
  25584. static readonly ORTHOGRAPHIC_CAMERA: number;
  25585. /**
  25586. * This is the default FOV mode for perspective cameras.
  25587. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25588. */
  25589. static readonly FOVMODE_VERTICAL_FIXED: number;
  25590. /**
  25591. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25592. */
  25593. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25594. /**
  25595. * This specifies ther is no need for a camera rig.
  25596. * Basically only one eye is rendered corresponding to the camera.
  25597. */
  25598. static readonly RIG_MODE_NONE: number;
  25599. /**
  25600. * Simulates a camera Rig with one blue eye and one red eye.
  25601. * This can be use with 3d blue and red glasses.
  25602. */
  25603. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25604. /**
  25605. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25606. */
  25607. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25608. /**
  25609. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25610. */
  25611. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25612. /**
  25613. * Defines that both eyes of the camera will be rendered over under each other.
  25614. */
  25615. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25616. /**
  25617. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25618. */
  25619. static readonly RIG_MODE_VR: number;
  25620. /**
  25621. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25622. */
  25623. static readonly RIG_MODE_WEBVR: number;
  25624. /**
  25625. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25626. */
  25627. static readonly RIG_MODE_CUSTOM: number;
  25628. /**
  25629. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25630. */
  25631. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25632. /**
  25633. * Define the input manager associated with the camera.
  25634. */
  25635. inputs: CameraInputsManager<Camera>;
  25636. /** @hidden */
  25637. _position: Vector3;
  25638. /**
  25639. * Define the current local position of the camera in the scene
  25640. */
  25641. position: Vector3;
  25642. /**
  25643. * The vector the camera should consider as up.
  25644. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25645. */
  25646. upVector: Vector3;
  25647. /**
  25648. * Define the current limit on the left side for an orthographic camera
  25649. * In scene unit
  25650. */
  25651. orthoLeft: Nullable<number>;
  25652. /**
  25653. * Define the current limit on the right side for an orthographic camera
  25654. * In scene unit
  25655. */
  25656. orthoRight: Nullable<number>;
  25657. /**
  25658. * Define the current limit on the bottom side for an orthographic camera
  25659. * In scene unit
  25660. */
  25661. orthoBottom: Nullable<number>;
  25662. /**
  25663. * Define the current limit on the top side for an orthographic camera
  25664. * In scene unit
  25665. */
  25666. orthoTop: Nullable<number>;
  25667. /**
  25668. * Field Of View is set in Radians. (default is 0.8)
  25669. */
  25670. fov: number;
  25671. /**
  25672. * Define the minimum distance the camera can see from.
  25673. * This is important to note that the depth buffer are not infinite and the closer it starts
  25674. * the more your scene might encounter depth fighting issue.
  25675. */
  25676. minZ: number;
  25677. /**
  25678. * Define the maximum distance the camera can see to.
  25679. * This is important to note that the depth buffer are not infinite and the further it end
  25680. * the more your scene might encounter depth fighting issue.
  25681. */
  25682. maxZ: number;
  25683. /**
  25684. * Define the default inertia of the camera.
  25685. * This helps giving a smooth feeling to the camera movement.
  25686. */
  25687. inertia: number;
  25688. /**
  25689. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25690. */
  25691. mode: number;
  25692. /**
  25693. * Define wether the camera is intermediate.
  25694. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25695. */
  25696. isIntermediate: boolean;
  25697. /**
  25698. * Define the viewport of the camera.
  25699. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25700. */
  25701. viewport: Viewport;
  25702. /**
  25703. * Restricts the camera to viewing objects with the same layerMask.
  25704. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25705. */
  25706. layerMask: number;
  25707. /**
  25708. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25709. */
  25710. fovMode: number;
  25711. /**
  25712. * Rig mode of the camera.
  25713. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25714. * This is normally controlled byt the camera themselves as internal use.
  25715. */
  25716. cameraRigMode: number;
  25717. /**
  25718. * Defines the distance between both "eyes" in case of a RIG
  25719. */
  25720. interaxialDistance: number;
  25721. /**
  25722. * Defines if stereoscopic rendering is done side by side or over under.
  25723. */
  25724. isStereoscopicSideBySide: boolean;
  25725. /**
  25726. * 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
  25727. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25728. * else in the scene. (Eg. security camera)
  25729. *
  25730. * 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)
  25731. */
  25732. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25733. /**
  25734. * When set, the camera will render to this render target instead of the default canvas
  25735. *
  25736. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25737. */
  25738. outputRenderTarget: Nullable<RenderTargetTexture>;
  25739. /**
  25740. * Observable triggered when the camera view matrix has changed.
  25741. */
  25742. onViewMatrixChangedObservable: Observable<Camera>;
  25743. /**
  25744. * Observable triggered when the camera Projection matrix has changed.
  25745. */
  25746. onProjectionMatrixChangedObservable: Observable<Camera>;
  25747. /**
  25748. * Observable triggered when the inputs have been processed.
  25749. */
  25750. onAfterCheckInputsObservable: Observable<Camera>;
  25751. /**
  25752. * Observable triggered when reset has been called and applied to the camera.
  25753. */
  25754. onRestoreStateObservable: Observable<Camera>;
  25755. /** @hidden */
  25756. _cameraRigParams: any;
  25757. /** @hidden */
  25758. _rigCameras: Camera[];
  25759. /** @hidden */
  25760. _rigPostProcess: Nullable<PostProcess>;
  25761. protected _webvrViewMatrix: Matrix;
  25762. /** @hidden */
  25763. _skipRendering: boolean;
  25764. /** @hidden */
  25765. _projectionMatrix: Matrix;
  25766. /** @hidden */
  25767. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25768. /** @hidden */
  25769. _activeMeshes: SmartArray<AbstractMesh>;
  25770. protected _globalPosition: Vector3;
  25771. /** @hidden */
  25772. _computedViewMatrix: Matrix;
  25773. private _doNotComputeProjectionMatrix;
  25774. private _transformMatrix;
  25775. private _frustumPlanes;
  25776. private _refreshFrustumPlanes;
  25777. private _storedFov;
  25778. private _stateStored;
  25779. /**
  25780. * Instantiates a new camera object.
  25781. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25782. * @see http://doc.babylonjs.com/features/cameras
  25783. * @param name Defines the name of the camera in the scene
  25784. * @param position Defines the position of the camera
  25785. * @param scene Defines the scene the camera belongs too
  25786. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25787. */
  25788. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25789. /**
  25790. * Store current camera state (fov, position, etc..)
  25791. * @returns the camera
  25792. */
  25793. storeState(): Camera;
  25794. /**
  25795. * Restores the camera state values if it has been stored. You must call storeState() first
  25796. */
  25797. protected _restoreStateValues(): boolean;
  25798. /**
  25799. * Restored camera state. You must call storeState() first.
  25800. * @returns true if restored and false otherwise
  25801. */
  25802. restoreState(): boolean;
  25803. /**
  25804. * Gets the class name of the camera.
  25805. * @returns the class name
  25806. */
  25807. getClassName(): string;
  25808. /** @hidden */
  25809. readonly _isCamera: boolean;
  25810. /**
  25811. * Gets a string representation of the camera useful for debug purpose.
  25812. * @param fullDetails Defines that a more verboe level of logging is required
  25813. * @returns the string representation
  25814. */
  25815. toString(fullDetails?: boolean): string;
  25816. /**
  25817. * Gets the current world space position of the camera.
  25818. */
  25819. readonly globalPosition: Vector3;
  25820. /**
  25821. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25822. * @returns the active meshe list
  25823. */
  25824. getActiveMeshes(): SmartArray<AbstractMesh>;
  25825. /**
  25826. * Check wether a mesh is part of the current active mesh list of the camera
  25827. * @param mesh Defines the mesh to check
  25828. * @returns true if active, false otherwise
  25829. */
  25830. isActiveMesh(mesh: Mesh): boolean;
  25831. /**
  25832. * Is this camera ready to be used/rendered
  25833. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25834. * @return true if the camera is ready
  25835. */
  25836. isReady(completeCheck?: boolean): boolean;
  25837. /** @hidden */
  25838. _initCache(): void;
  25839. /** @hidden */
  25840. _updateCache(ignoreParentClass?: boolean): void;
  25841. /** @hidden */
  25842. _isSynchronized(): boolean;
  25843. /** @hidden */
  25844. _isSynchronizedViewMatrix(): boolean;
  25845. /** @hidden */
  25846. _isSynchronizedProjectionMatrix(): boolean;
  25847. /**
  25848. * Attach the input controls to a specific dom element to get the input from.
  25849. * @param element Defines the element the controls should be listened from
  25850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25851. */
  25852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25853. /**
  25854. * Detach the current controls from the specified dom element.
  25855. * @param element Defines the element to stop listening the inputs from
  25856. */
  25857. detachControl(element: HTMLElement): void;
  25858. /**
  25859. * Update the camera state according to the different inputs gathered during the frame.
  25860. */
  25861. update(): void;
  25862. /** @hidden */
  25863. _checkInputs(): void;
  25864. /** @hidden */
  25865. readonly rigCameras: Camera[];
  25866. /**
  25867. * Gets the post process used by the rig cameras
  25868. */
  25869. readonly rigPostProcess: Nullable<PostProcess>;
  25870. /**
  25871. * Internal, gets the first post proces.
  25872. * @returns the first post process to be run on this camera.
  25873. */
  25874. _getFirstPostProcess(): Nullable<PostProcess>;
  25875. private _cascadePostProcessesToRigCams;
  25876. /**
  25877. * Attach a post process to the camera.
  25878. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25879. * @param postProcess The post process to attach to the camera
  25880. * @param insertAt The position of the post process in case several of them are in use in the scene
  25881. * @returns the position the post process has been inserted at
  25882. */
  25883. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25884. /**
  25885. * Detach a post process to the camera.
  25886. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25887. * @param postProcess The post process to detach from the camera
  25888. */
  25889. detachPostProcess(postProcess: PostProcess): void;
  25890. /**
  25891. * Gets the current world matrix of the camera
  25892. */
  25893. getWorldMatrix(): Matrix;
  25894. /** @hidden */
  25895. _getViewMatrix(): Matrix;
  25896. /**
  25897. * Gets the current view matrix of the camera.
  25898. * @param force forces the camera to recompute the matrix without looking at the cached state
  25899. * @returns the view matrix
  25900. */
  25901. getViewMatrix(force?: boolean): Matrix;
  25902. /**
  25903. * Freeze the projection matrix.
  25904. * It will prevent the cache check of the camera projection compute and can speed up perf
  25905. * if no parameter of the camera are meant to change
  25906. * @param projection Defines manually a projection if necessary
  25907. */
  25908. freezeProjectionMatrix(projection?: Matrix): void;
  25909. /**
  25910. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25911. */
  25912. unfreezeProjectionMatrix(): void;
  25913. /**
  25914. * Gets the current projection matrix of the camera.
  25915. * @param force forces the camera to recompute the matrix without looking at the cached state
  25916. * @returns the projection matrix
  25917. */
  25918. getProjectionMatrix(force?: boolean): Matrix;
  25919. /**
  25920. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25921. * @returns a Matrix
  25922. */
  25923. getTransformationMatrix(): Matrix;
  25924. private _updateFrustumPlanes;
  25925. /**
  25926. * Checks if a cullable object (mesh...) is in the camera frustum
  25927. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25928. * @param target The object to check
  25929. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25930. * @returns true if the object is in frustum otherwise false
  25931. */
  25932. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25933. /**
  25934. * Checks if a cullable object (mesh...) is in the camera frustum
  25935. * Unlike isInFrustum this cheks the full bounding box
  25936. * @param target The object to check
  25937. * @returns true if the object is in frustum otherwise false
  25938. */
  25939. isCompletelyInFrustum(target: ICullable): boolean;
  25940. /**
  25941. * Gets a ray in the forward direction from the camera.
  25942. * @param length Defines the length of the ray to create
  25943. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25944. * @param origin Defines the start point of the ray which defaults to the camera position
  25945. * @returns the forward ray
  25946. */
  25947. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25948. /**
  25949. * Releases resources associated with this node.
  25950. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25951. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25952. */
  25953. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25954. /** @hidden */
  25955. _isLeftCamera: boolean;
  25956. /**
  25957. * Gets the left camera of a rig setup in case of Rigged Camera
  25958. */
  25959. readonly isLeftCamera: boolean;
  25960. /** @hidden */
  25961. _isRightCamera: boolean;
  25962. /**
  25963. * Gets the right camera of a rig setup in case of Rigged Camera
  25964. */
  25965. readonly isRightCamera: boolean;
  25966. /**
  25967. * Gets the left camera of a rig setup in case of Rigged Camera
  25968. */
  25969. readonly leftCamera: Nullable<FreeCamera>;
  25970. /**
  25971. * Gets the right camera of a rig setup in case of Rigged Camera
  25972. */
  25973. readonly rightCamera: Nullable<FreeCamera>;
  25974. /**
  25975. * Gets the left camera target of a rig setup in case of Rigged Camera
  25976. * @returns the target position
  25977. */
  25978. getLeftTarget(): Nullable<Vector3>;
  25979. /**
  25980. * Gets the right camera target of a rig setup in case of Rigged Camera
  25981. * @returns the target position
  25982. */
  25983. getRightTarget(): Nullable<Vector3>;
  25984. /**
  25985. * @hidden
  25986. */
  25987. setCameraRigMode(mode: number, rigParams: any): void;
  25988. /** @hidden */
  25989. static _setStereoscopicRigMode(camera: Camera): void;
  25990. /** @hidden */
  25991. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25992. /** @hidden */
  25993. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25994. /** @hidden */
  25995. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25996. /** @hidden */
  25997. _getVRProjectionMatrix(): Matrix;
  25998. protected _updateCameraRotationMatrix(): void;
  25999. protected _updateWebVRCameraRotationMatrix(): void;
  26000. /**
  26001. * This function MUST be overwritten by the different WebVR cameras available.
  26002. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26003. * @hidden
  26004. */
  26005. _getWebVRProjectionMatrix(): Matrix;
  26006. /**
  26007. * This function MUST be overwritten by the different WebVR cameras available.
  26008. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26009. * @hidden
  26010. */
  26011. _getWebVRViewMatrix(): Matrix;
  26012. /** @hidden */
  26013. setCameraRigParameter(name: string, value: any): void;
  26014. /**
  26015. * needs to be overridden by children so sub has required properties to be copied
  26016. * @hidden
  26017. */
  26018. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26019. /**
  26020. * May need to be overridden by children
  26021. * @hidden
  26022. */
  26023. _updateRigCameras(): void;
  26024. /** @hidden */
  26025. _setupInputs(): void;
  26026. /**
  26027. * Serialiaze the camera setup to a json represention
  26028. * @returns the JSON representation
  26029. */
  26030. serialize(): any;
  26031. /**
  26032. * Clones the current camera.
  26033. * @param name The cloned camera name
  26034. * @returns the cloned camera
  26035. */
  26036. clone(name: string): Camera;
  26037. /**
  26038. * Gets the direction of the camera relative to a given local axis.
  26039. * @param localAxis Defines the reference axis to provide a relative direction.
  26040. * @return the direction
  26041. */
  26042. getDirection(localAxis: Vector3): Vector3;
  26043. /**
  26044. * Returns the current camera absolute rotation
  26045. */
  26046. readonly absoluteRotation: Quaternion;
  26047. /**
  26048. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26049. * @param localAxis Defines the reference axis to provide a relative direction.
  26050. * @param result Defines the vector to store the result in
  26051. */
  26052. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26053. /**
  26054. * Gets a camera constructor for a given camera type
  26055. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26056. * @param name The name of the camera the result will be able to instantiate
  26057. * @param scene The scene the result will construct the camera in
  26058. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26059. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26060. * @returns a factory method to construc the camera
  26061. */
  26062. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26063. /**
  26064. * Compute the world matrix of the camera.
  26065. * @returns the camera world matrix
  26066. */
  26067. computeWorldMatrix(): Matrix;
  26068. /**
  26069. * Parse a JSON and creates the camera from the parsed information
  26070. * @param parsedCamera The JSON to parse
  26071. * @param scene The scene to instantiate the camera in
  26072. * @returns the newly constructed camera
  26073. */
  26074. static Parse(parsedCamera: any, scene: Scene): Camera;
  26075. }
  26076. }
  26077. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26078. import { Nullable } from "babylonjs/types";
  26079. import { Scene } from "babylonjs/scene";
  26080. import { Vector4 } from "babylonjs/Maths/math.vector";
  26081. import { Mesh } from "babylonjs/Meshes/mesh";
  26082. /**
  26083. * Class containing static functions to help procedurally build meshes
  26084. */
  26085. export class DiscBuilder {
  26086. /**
  26087. * Creates a plane polygonal mesh. By default, this is a disc
  26088. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26089. * * 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
  26090. * * 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
  26091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26094. * @param name defines the name of the mesh
  26095. * @param options defines the options used to create the mesh
  26096. * @param scene defines the hosting scene
  26097. * @returns the plane polygonal mesh
  26098. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26099. */
  26100. static CreateDisc(name: string, options: {
  26101. radius?: number;
  26102. tessellation?: number;
  26103. arc?: number;
  26104. updatable?: boolean;
  26105. sideOrientation?: number;
  26106. frontUVs?: Vector4;
  26107. backUVs?: Vector4;
  26108. }, scene?: Nullable<Scene>): Mesh;
  26109. }
  26110. }
  26111. declare module "babylonjs/Particles/solidParticleSystem" {
  26112. import { Nullable } from "babylonjs/types";
  26113. import { Vector3 } from "babylonjs/Maths/math.vector";
  26114. import { Mesh } from "babylonjs/Meshes/mesh";
  26115. import { Scene, IDisposable } from "babylonjs/scene";
  26116. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26117. /**
  26118. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26119. *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.
  26120. * The SPS is also a particle system. It provides some methods to manage the particles.
  26121. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26122. *
  26123. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26124. */
  26125. export class SolidParticleSystem implements IDisposable {
  26126. /**
  26127. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26128. * Example : var p = SPS.particles[i];
  26129. */
  26130. particles: SolidParticle[];
  26131. /**
  26132. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26133. */
  26134. nbParticles: number;
  26135. /**
  26136. * If the particles must ever face the camera (default false). Useful for planar particles.
  26137. */
  26138. billboard: boolean;
  26139. /**
  26140. * Recompute normals when adding a shape
  26141. */
  26142. recomputeNormals: boolean;
  26143. /**
  26144. * This a counter ofr your own usage. It's not set by any SPS functions.
  26145. */
  26146. counter: number;
  26147. /**
  26148. * The SPS name. This name is also given to the underlying mesh.
  26149. */
  26150. name: string;
  26151. /**
  26152. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26153. */
  26154. mesh: Mesh;
  26155. /**
  26156. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26157. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26158. */
  26159. vars: any;
  26160. /**
  26161. * This array is populated when the SPS is set as 'pickable'.
  26162. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26163. * Each element of this array is an object `{idx: int, faceId: int}`.
  26164. * `idx` is the picked particle index in the `SPS.particles` array
  26165. * `faceId` is the picked face index counted within this particle.
  26166. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26167. */
  26168. pickedParticles: {
  26169. idx: number;
  26170. faceId: number;
  26171. }[];
  26172. /**
  26173. * This array is populated when `enableDepthSort` is set to true.
  26174. * Each element of this array is an instance of the class DepthSortedParticle.
  26175. */
  26176. depthSortedParticles: DepthSortedParticle[];
  26177. /**
  26178. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26179. * @hidden
  26180. */
  26181. _bSphereOnly: boolean;
  26182. /**
  26183. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26184. * @hidden
  26185. */
  26186. _bSphereRadiusFactor: number;
  26187. private _scene;
  26188. private _positions;
  26189. private _indices;
  26190. private _normals;
  26191. private _colors;
  26192. private _uvs;
  26193. private _indices32;
  26194. private _positions32;
  26195. private _normals32;
  26196. private _fixedNormal32;
  26197. private _colors32;
  26198. private _uvs32;
  26199. private _index;
  26200. private _updatable;
  26201. private _pickable;
  26202. private _isVisibilityBoxLocked;
  26203. private _alwaysVisible;
  26204. private _depthSort;
  26205. private _expandable;
  26206. private _shapeCounter;
  26207. private _copy;
  26208. private _color;
  26209. private _computeParticleColor;
  26210. private _computeParticleTexture;
  26211. private _computeParticleRotation;
  26212. private _computeParticleVertex;
  26213. private _computeBoundingBox;
  26214. private _depthSortParticles;
  26215. private _camera;
  26216. private _mustUnrotateFixedNormals;
  26217. private _particlesIntersect;
  26218. private _needs32Bits;
  26219. private _isNotBuilt;
  26220. private _lastParticleId;
  26221. private _idxOfId;
  26222. /**
  26223. * Creates a SPS (Solid Particle System) object.
  26224. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26225. * @param scene (Scene) is the scene in which the SPS is added.
  26226. * @param options defines the options of the sps e.g.
  26227. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26228. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26229. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26230. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26231. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26232. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26233. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26234. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26235. */
  26236. constructor(name: string, scene: Scene, options?: {
  26237. updatable?: boolean;
  26238. isPickable?: boolean;
  26239. enableDepthSort?: boolean;
  26240. particleIntersection?: boolean;
  26241. boundingSphereOnly?: boolean;
  26242. bSphereRadiusFactor?: number;
  26243. expandable?: boolean;
  26244. });
  26245. /**
  26246. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26247. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26248. * @returns the created mesh
  26249. */
  26250. buildMesh(): Mesh;
  26251. /**
  26252. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26253. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26254. * Thus the particles generated from `digest()` have their property `position` set yet.
  26255. * @param mesh ( Mesh ) is the mesh to be digested
  26256. * @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
  26257. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26258. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26259. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26260. * @returns the current SPS
  26261. */
  26262. digest(mesh: Mesh, options?: {
  26263. facetNb?: number;
  26264. number?: number;
  26265. delta?: number;
  26266. storage?: [];
  26267. }): SolidParticleSystem;
  26268. /**
  26269. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26270. * @hidden
  26271. */
  26272. private _unrotateFixedNormals;
  26273. /**
  26274. * Resets the temporary working copy particle
  26275. * @hidden
  26276. */
  26277. private _resetCopy;
  26278. /**
  26279. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26280. * @param p the current index in the positions array to be updated
  26281. * @param shape a Vector3 array, the shape geometry
  26282. * @param positions the positions array to be updated
  26283. * @param meshInd the shape indices array
  26284. * @param indices the indices array to be updated
  26285. * @param meshUV the shape uv array
  26286. * @param uvs the uv array to be updated
  26287. * @param meshCol the shape color array
  26288. * @param colors the color array to be updated
  26289. * @param meshNor the shape normals array
  26290. * @param normals the normals array to be updated
  26291. * @param idx the particle index
  26292. * @param idxInShape the particle index in its shape
  26293. * @param options the addShape() method passed options
  26294. * @hidden
  26295. */
  26296. private _meshBuilder;
  26297. /**
  26298. * Returns a shape Vector3 array from positions float array
  26299. * @param positions float array
  26300. * @returns a vector3 array
  26301. * @hidden
  26302. */
  26303. private _posToShape;
  26304. /**
  26305. * Returns a shapeUV array from a float uvs (array deep copy)
  26306. * @param uvs as a float array
  26307. * @returns a shapeUV array
  26308. * @hidden
  26309. */
  26310. private _uvsToShapeUV;
  26311. /**
  26312. * Adds a new particle object in the particles array
  26313. * @param idx particle index in particles array
  26314. * @param id particle id
  26315. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26316. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26317. * @param model particle ModelShape object
  26318. * @param shapeId model shape identifier
  26319. * @param idxInShape index of the particle in the current model
  26320. * @param bInfo model bounding info object
  26321. * @param storage target storage array, if any
  26322. * @hidden
  26323. */
  26324. private _addParticle;
  26325. /**
  26326. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26327. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26328. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26329. * @param nb (positive integer) the number of particles to be created from this model
  26330. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26331. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26332. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26333. * @returns the number of shapes in the system
  26334. */
  26335. addShape(mesh: Mesh, nb: number, options?: {
  26336. positionFunction?: any;
  26337. vertexFunction?: any;
  26338. storage?: [];
  26339. }): number;
  26340. /**
  26341. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26342. * @hidden
  26343. */
  26344. private _rebuildParticle;
  26345. /**
  26346. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26347. * @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.
  26348. * @returns the SPS.
  26349. */
  26350. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26351. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26352. * Returns an array with the removed particles.
  26353. * 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.
  26354. * The SPS can't be empty so at least one particle needs to remain in place.
  26355. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26356. * @param start index of the first particle to remove
  26357. * @param end index of the last particle to remove (included)
  26358. * @returns an array populated with the removed particles
  26359. */
  26360. removeParticles(start: number, end: number): SolidParticle[];
  26361. /**
  26362. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26363. * @param solidParticleArray an array populated with Solid Particles objects
  26364. * @returns the SPS
  26365. */
  26366. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26367. /**
  26368. * Creates a new particle and modifies the SPS mesh geometry :
  26369. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26370. * - calls _addParticle() to populate the particle array
  26371. * factorized code from addShape() and insertParticlesFromArray()
  26372. * @param idx particle index in the particles array
  26373. * @param i particle index in its shape
  26374. * @param modelShape particle ModelShape object
  26375. * @param shape shape vertex array
  26376. * @param meshInd shape indices array
  26377. * @param meshUV shape uv array
  26378. * @param meshCol shape color array
  26379. * @param meshNor shape normals array
  26380. * @param bbInfo shape bounding info
  26381. * @param storage target particle storage
  26382. * @options addShape() passed options
  26383. * @hidden
  26384. */
  26385. private _insertNewParticle;
  26386. /**
  26387. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26388. * This method calls `updateParticle()` for each particle of the SPS.
  26389. * For an animated SPS, it is usually called within the render loop.
  26390. * 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.
  26391. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26392. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26393. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26394. * @returns the SPS.
  26395. */
  26396. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26397. /**
  26398. * Disposes the SPS.
  26399. */
  26400. dispose(): void;
  26401. /**
  26402. * Returns a SolidParticle object from its identifier : particle.id
  26403. * @param id (integer) the particle Id
  26404. * @returns the searched particle or null if not found in the SPS.
  26405. */
  26406. getParticleById(id: number): Nullable<SolidParticle>;
  26407. /**
  26408. * Returns a new array populated with the particles having the passed shapeId.
  26409. * @param shapeId (integer) the shape identifier
  26410. * @returns a new solid particle array
  26411. */
  26412. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26413. /**
  26414. * Populates the passed array "ref" with the particles having the passed shapeId.
  26415. * @param shapeId the shape identifier
  26416. * @returns the SPS
  26417. * @param ref
  26418. */
  26419. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26420. /**
  26421. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26422. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26423. * @returns the SPS.
  26424. */
  26425. refreshVisibleSize(): SolidParticleSystem;
  26426. /**
  26427. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26428. * @param size the size (float) of the visibility box
  26429. * note : this doesn't lock the SPS mesh bounding box.
  26430. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26431. */
  26432. setVisibilityBox(size: number): void;
  26433. /**
  26434. * Gets whether the SPS as always visible or not
  26435. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26436. */
  26437. /**
  26438. * Sets the SPS as always visible or not
  26439. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26440. */
  26441. isAlwaysVisible: boolean;
  26442. /**
  26443. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26444. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26445. */
  26446. /**
  26447. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26448. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26449. */
  26450. isVisibilityBoxLocked: boolean;
  26451. /**
  26452. * Tells to `setParticles()` to compute the particle rotations or not.
  26453. * Default value : true. The SPS is faster when it's set to false.
  26454. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26455. */
  26456. /**
  26457. * Gets if `setParticles()` computes the particle rotations or not.
  26458. * Default value : true. The SPS is faster when it's set to false.
  26459. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26460. */
  26461. computeParticleRotation: boolean;
  26462. /**
  26463. * Tells to `setParticles()` to compute the particle colors or not.
  26464. * Default value : true. The SPS is faster when it's set to false.
  26465. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26466. */
  26467. /**
  26468. * Gets if `setParticles()` computes the particle colors or not.
  26469. * Default value : true. The SPS is faster when it's set to false.
  26470. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26471. */
  26472. computeParticleColor: boolean;
  26473. /**
  26474. * Gets if `setParticles()` computes the particle textures or not.
  26475. * Default value : true. The SPS is faster when it's set to false.
  26476. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26477. */
  26478. computeParticleTexture: boolean;
  26479. /**
  26480. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26481. * Default value : false. The SPS is faster when it's set to false.
  26482. * Note : the particle custom vertex positions aren't stored values.
  26483. */
  26484. /**
  26485. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26486. * Default value : false. The SPS is faster when it's set to false.
  26487. * Note : the particle custom vertex positions aren't stored values.
  26488. */
  26489. computeParticleVertex: boolean;
  26490. /**
  26491. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26492. */
  26493. /**
  26494. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26495. */
  26496. computeBoundingBox: boolean;
  26497. /**
  26498. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26499. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26500. * Default : `true`
  26501. */
  26502. /**
  26503. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26504. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26505. * Default : `true`
  26506. */
  26507. depthSortParticles: boolean;
  26508. /**
  26509. * Gets if the SPS is created as expandable at construction time.
  26510. * Default : `false`
  26511. */
  26512. readonly expandable: boolean;
  26513. /**
  26514. * This function does nothing. It may be overwritten to set all the particle first values.
  26515. * The SPS doesn't call this function, you may have to call it by your own.
  26516. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26517. */
  26518. initParticles(): void;
  26519. /**
  26520. * This function does nothing. It may be overwritten to recycle a particle.
  26521. * The SPS doesn't call this function, you may have to call it by your own.
  26522. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26523. * @param particle The particle to recycle
  26524. * @returns the recycled particle
  26525. */
  26526. recycleParticle(particle: SolidParticle): SolidParticle;
  26527. /**
  26528. * Updates a particle : this function should be overwritten by the user.
  26529. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26530. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26531. * @example : just set a particle position or velocity and recycle conditions
  26532. * @param particle The particle to update
  26533. * @returns the updated particle
  26534. */
  26535. updateParticle(particle: SolidParticle): SolidParticle;
  26536. /**
  26537. * Updates a vertex of a particle : it can be overwritten by the user.
  26538. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26539. * @param particle the current particle
  26540. * @param vertex the current index of the current particle
  26541. * @param pt the index of the current vertex in the particle shape
  26542. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26543. * @example : just set a vertex particle position
  26544. * @returns the updated vertex
  26545. */
  26546. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26547. /**
  26548. * This will be called before any other treatment by `setParticles()` and 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. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26555. /**
  26556. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26557. * This will be passed three parameters.
  26558. * This does nothing and may be overwritten by the user.
  26559. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26560. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26561. * @param update the boolean update value actually passed to setParticles()
  26562. */
  26563. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26564. }
  26565. }
  26566. declare module "babylonjs/Particles/solidParticle" {
  26567. import { Nullable } from "babylonjs/types";
  26568. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26569. import { Color4 } from "babylonjs/Maths/math.color";
  26570. import { Mesh } from "babylonjs/Meshes/mesh";
  26571. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26572. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26573. import { Plane } from "babylonjs/Maths/math.plane";
  26574. /**
  26575. * Represents one particle of a solid particle system.
  26576. */
  26577. export class SolidParticle {
  26578. /**
  26579. * particle global index
  26580. */
  26581. idx: number;
  26582. /**
  26583. * particle identifier
  26584. */
  26585. id: number;
  26586. /**
  26587. * The color of the particle
  26588. */
  26589. color: Nullable<Color4>;
  26590. /**
  26591. * The world space position of the particle.
  26592. */
  26593. position: Vector3;
  26594. /**
  26595. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26596. */
  26597. rotation: Vector3;
  26598. /**
  26599. * The world space rotation quaternion of the particle.
  26600. */
  26601. rotationQuaternion: Nullable<Quaternion>;
  26602. /**
  26603. * The scaling of the particle.
  26604. */
  26605. scaling: Vector3;
  26606. /**
  26607. * The uvs of the particle.
  26608. */
  26609. uvs: Vector4;
  26610. /**
  26611. * The current speed of the particle.
  26612. */
  26613. velocity: Vector3;
  26614. /**
  26615. * The pivot point in the particle local space.
  26616. */
  26617. pivot: Vector3;
  26618. /**
  26619. * Must the particle be translated from its pivot point in its local space ?
  26620. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26621. * Default : false
  26622. */
  26623. translateFromPivot: boolean;
  26624. /**
  26625. * Is the particle active or not ?
  26626. */
  26627. alive: boolean;
  26628. /**
  26629. * Is the particle visible or not ?
  26630. */
  26631. isVisible: boolean;
  26632. /**
  26633. * Index of this particle in the global "positions" array (Internal use)
  26634. * @hidden
  26635. */
  26636. _pos: number;
  26637. /**
  26638. * @hidden Index of this particle in the global "indices" array (Internal use)
  26639. */
  26640. _ind: number;
  26641. /**
  26642. * @hidden ModelShape of this particle (Internal use)
  26643. */
  26644. _model: ModelShape;
  26645. /**
  26646. * ModelShape id of this particle
  26647. */
  26648. shapeId: number;
  26649. /**
  26650. * Index of the particle in its shape id
  26651. */
  26652. idxInShape: number;
  26653. /**
  26654. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26655. */
  26656. _modelBoundingInfo: BoundingInfo;
  26657. /**
  26658. * @hidden Particle BoundingInfo object (Internal use)
  26659. */
  26660. _boundingInfo: BoundingInfo;
  26661. /**
  26662. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26663. */
  26664. _sps: SolidParticleSystem;
  26665. /**
  26666. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26667. */
  26668. _stillInvisible: boolean;
  26669. /**
  26670. * @hidden Last computed particle rotation matrix
  26671. */
  26672. _rotationMatrix: number[];
  26673. /**
  26674. * Parent particle Id, if any.
  26675. * Default null.
  26676. */
  26677. parentId: Nullable<number>;
  26678. /**
  26679. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26680. * The possible values are :
  26681. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26682. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26683. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26684. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26685. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26686. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26687. * */
  26688. cullingStrategy: number;
  26689. /**
  26690. * @hidden Internal global position in the SPS.
  26691. */
  26692. _globalPosition: Vector3;
  26693. /**
  26694. * Creates a Solid Particle object.
  26695. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26696. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26697. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26698. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26699. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26700. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26701. * @param shapeId (integer) is the model shape identifier in the SPS.
  26702. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26703. * @param sps defines the sps it is associated to
  26704. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26705. */
  26706. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26707. /**
  26708. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26709. * @param target the particle target
  26710. * @returns the current particle
  26711. */
  26712. copyToRef(target: SolidParticle): SolidParticle;
  26713. /**
  26714. * Legacy support, changed scale to scaling
  26715. */
  26716. /**
  26717. * Legacy support, changed scale to scaling
  26718. */
  26719. scale: Vector3;
  26720. /**
  26721. * Legacy support, changed quaternion to rotationQuaternion
  26722. */
  26723. /**
  26724. * Legacy support, changed quaternion to rotationQuaternion
  26725. */
  26726. quaternion: Nullable<Quaternion>;
  26727. /**
  26728. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26729. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26730. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26731. * @returns true if it intersects
  26732. */
  26733. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26734. /**
  26735. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26736. * A particle is in the frustum if its bounding box intersects the frustum
  26737. * @param frustumPlanes defines the frustum to test
  26738. * @returns true if the particle is in the frustum planes
  26739. */
  26740. isInFrustum(frustumPlanes: Plane[]): boolean;
  26741. /**
  26742. * get the rotation matrix of the particle
  26743. * @hidden
  26744. */
  26745. getRotationMatrix(m: Matrix): void;
  26746. }
  26747. /**
  26748. * Represents the shape of the model used by one particle of a solid particle system.
  26749. * SPS internal tool, don't use it manually.
  26750. */
  26751. export class ModelShape {
  26752. /**
  26753. * The shape id
  26754. * @hidden
  26755. */
  26756. shapeID: number;
  26757. /**
  26758. * flat array of model positions (internal use)
  26759. * @hidden
  26760. */
  26761. _shape: Vector3[];
  26762. /**
  26763. * flat array of model UVs (internal use)
  26764. * @hidden
  26765. */
  26766. _shapeUV: number[];
  26767. /**
  26768. * color array of the model
  26769. * @hidden
  26770. */
  26771. _shapeColors: number[];
  26772. /**
  26773. * indices array of the model
  26774. * @hidden
  26775. */
  26776. _indices: number[];
  26777. /**
  26778. * normals array of the model
  26779. * @hidden
  26780. */
  26781. _normals: number[];
  26782. /**
  26783. * length of the shape in the model indices array (internal use)
  26784. * @hidden
  26785. */
  26786. _indicesLength: number;
  26787. /**
  26788. * Custom position function (internal use)
  26789. * @hidden
  26790. */
  26791. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26792. /**
  26793. * Custom vertex function (internal use)
  26794. * @hidden
  26795. */
  26796. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26797. /**
  26798. * 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.
  26799. * SPS internal tool, don't use it manually.
  26800. * @hidden
  26801. */
  26802. 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>);
  26803. }
  26804. /**
  26805. * Represents a Depth Sorted Particle in the solid particle system.
  26806. */
  26807. export class DepthSortedParticle {
  26808. /**
  26809. * Index of the particle in the "indices" array
  26810. */
  26811. ind: number;
  26812. /**
  26813. * Length of the particle shape in the "indices" array
  26814. */
  26815. indicesLength: number;
  26816. /**
  26817. * Squared distance from the particle to the camera
  26818. */
  26819. sqDistance: number;
  26820. }
  26821. }
  26822. declare module "babylonjs/Collisions/meshCollisionData" {
  26823. import { Collider } from "babylonjs/Collisions/collider";
  26824. import { Vector3 } from "babylonjs/Maths/math.vector";
  26825. import { Nullable } from "babylonjs/types";
  26826. import { Observer } from "babylonjs/Misc/observable";
  26827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26828. /**
  26829. * @hidden
  26830. */
  26831. export class _MeshCollisionData {
  26832. _checkCollisions: boolean;
  26833. _collisionMask: number;
  26834. _collisionGroup: number;
  26835. _collider: Nullable<Collider>;
  26836. _oldPositionForCollisions: Vector3;
  26837. _diffPositionForCollisions: Vector3;
  26838. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26839. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26840. }
  26841. }
  26842. declare module "babylonjs/Meshes/abstractMesh" {
  26843. import { Observable } from "babylonjs/Misc/observable";
  26844. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26845. import { Camera } from "babylonjs/Cameras/camera";
  26846. import { Scene, IDisposable } from "babylonjs/scene";
  26847. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26848. import { Node } from "babylonjs/node";
  26849. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26850. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26851. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26852. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26853. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26854. import { Material } from "babylonjs/Materials/material";
  26855. import { Light } from "babylonjs/Lights/light";
  26856. import { Skeleton } from "babylonjs/Bones/skeleton";
  26857. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26858. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26859. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26860. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26861. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26862. import { Plane } from "babylonjs/Maths/math.plane";
  26863. import { Ray } from "babylonjs/Culling/ray";
  26864. import { Collider } from "babylonjs/Collisions/collider";
  26865. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26866. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26867. /** @hidden */
  26868. class _FacetDataStorage {
  26869. facetPositions: Vector3[];
  26870. facetNormals: Vector3[];
  26871. facetPartitioning: number[][];
  26872. facetNb: number;
  26873. partitioningSubdivisions: number;
  26874. partitioningBBoxRatio: number;
  26875. facetDataEnabled: boolean;
  26876. facetParameters: any;
  26877. bbSize: Vector3;
  26878. subDiv: {
  26879. max: number;
  26880. X: number;
  26881. Y: number;
  26882. Z: number;
  26883. };
  26884. facetDepthSort: boolean;
  26885. facetDepthSortEnabled: boolean;
  26886. depthSortedIndices: IndicesArray;
  26887. depthSortedFacets: {
  26888. ind: number;
  26889. sqDistance: number;
  26890. }[];
  26891. facetDepthSortFunction: (f1: {
  26892. ind: number;
  26893. sqDistance: number;
  26894. }, f2: {
  26895. ind: number;
  26896. sqDistance: number;
  26897. }) => number;
  26898. facetDepthSortFrom: Vector3;
  26899. facetDepthSortOrigin: Vector3;
  26900. invertedMatrix: Matrix;
  26901. }
  26902. /**
  26903. * @hidden
  26904. **/
  26905. class _InternalAbstractMeshDataInfo {
  26906. _hasVertexAlpha: boolean;
  26907. _useVertexColors: boolean;
  26908. _numBoneInfluencers: number;
  26909. _applyFog: boolean;
  26910. _receiveShadows: boolean;
  26911. _facetData: _FacetDataStorage;
  26912. _visibility: number;
  26913. _skeleton: Nullable<Skeleton>;
  26914. _layerMask: number;
  26915. _computeBonesUsingShaders: boolean;
  26916. _isActive: boolean;
  26917. _onlyForInstances: boolean;
  26918. _isActiveIntermediate: boolean;
  26919. _onlyForInstancesIntermediate: boolean;
  26920. _actAsRegularMesh: boolean;
  26921. }
  26922. /**
  26923. * Class used to store all common mesh properties
  26924. */
  26925. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26926. /** No occlusion */
  26927. static OCCLUSION_TYPE_NONE: number;
  26928. /** Occlusion set to optimisitic */
  26929. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26930. /** Occlusion set to strict */
  26931. static OCCLUSION_TYPE_STRICT: number;
  26932. /** Use an accurante occlusion algorithm */
  26933. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26934. /** Use a conservative occlusion algorithm */
  26935. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26936. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26937. * Test order :
  26938. * Is the bounding sphere outside the frustum ?
  26939. * If not, are the bounding box vertices outside the frustum ?
  26940. * It not, then the cullable object is in the frustum.
  26941. */
  26942. static readonly CULLINGSTRATEGY_STANDARD: number;
  26943. /** Culling strategy : Bounding Sphere Only.
  26944. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26945. * It's also less accurate than the standard because some not visible objects can still be selected.
  26946. * Test : is the bounding sphere outside the frustum ?
  26947. * If not, then the cullable object is in the frustum.
  26948. */
  26949. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26950. /** Culling strategy : Optimistic Inclusion.
  26951. * This in an inclusion test first, then the standard exclusion test.
  26952. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26953. * 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.
  26954. * Anyway, it's as accurate as the standard strategy.
  26955. * Test :
  26956. * Is the cullable object bounding sphere center in the frustum ?
  26957. * If not, apply the default culling strategy.
  26958. */
  26959. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26960. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26961. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26962. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26963. * 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.
  26964. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26965. * Test :
  26966. * Is the cullable object bounding sphere center in the frustum ?
  26967. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26968. */
  26969. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26970. /**
  26971. * No billboard
  26972. */
  26973. static readonly BILLBOARDMODE_NONE: number;
  26974. /** Billboard on X axis */
  26975. static readonly BILLBOARDMODE_X: number;
  26976. /** Billboard on Y axis */
  26977. static readonly BILLBOARDMODE_Y: number;
  26978. /** Billboard on Z axis */
  26979. static readonly BILLBOARDMODE_Z: number;
  26980. /** Billboard on all axes */
  26981. static readonly BILLBOARDMODE_ALL: number;
  26982. /** Billboard on using position instead of orientation */
  26983. static readonly BILLBOARDMODE_USE_POSITION: number;
  26984. /** @hidden */
  26985. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26986. /**
  26987. * The culling strategy to use to check whether the mesh must be rendered or not.
  26988. * This value can be changed at any time and will be used on the next render mesh selection.
  26989. * The possible values are :
  26990. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26991. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26992. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26993. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26994. * Please read each static variable documentation to get details about the culling process.
  26995. * */
  26996. cullingStrategy: number;
  26997. /**
  26998. * Gets the number of facets in the mesh
  26999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27000. */
  27001. readonly facetNb: number;
  27002. /**
  27003. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27005. */
  27006. partitioningSubdivisions: number;
  27007. /**
  27008. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27009. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27011. */
  27012. partitioningBBoxRatio: number;
  27013. /**
  27014. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27015. * Works only for updatable meshes.
  27016. * Doesn't work with multi-materials
  27017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27018. */
  27019. mustDepthSortFacets: boolean;
  27020. /**
  27021. * The location (Vector3) where the facet depth sort must be computed from.
  27022. * By default, the active camera position.
  27023. * Used only when facet depth sort is enabled
  27024. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27025. */
  27026. facetDepthSortFrom: Vector3;
  27027. /**
  27028. * gets a boolean indicating if facetData is enabled
  27029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27030. */
  27031. readonly isFacetDataEnabled: boolean;
  27032. /** @hidden */
  27033. _updateNonUniformScalingState(value: boolean): boolean;
  27034. /**
  27035. * An event triggered when this mesh collides with another one
  27036. */
  27037. onCollideObservable: Observable<AbstractMesh>;
  27038. /** Set a function to call when this mesh collides with another one */
  27039. onCollide: () => void;
  27040. /**
  27041. * An event triggered when the collision's position changes
  27042. */
  27043. onCollisionPositionChangeObservable: Observable<Vector3>;
  27044. /** Set a function to call when the collision's position changes */
  27045. onCollisionPositionChange: () => void;
  27046. /**
  27047. * An event triggered when material is changed
  27048. */
  27049. onMaterialChangedObservable: Observable<AbstractMesh>;
  27050. /**
  27051. * Gets or sets the orientation for POV movement & rotation
  27052. */
  27053. definedFacingForward: boolean;
  27054. /** @hidden */
  27055. _occlusionQuery: Nullable<WebGLQuery>;
  27056. /** @hidden */
  27057. _renderingGroup: Nullable<RenderingGroup>;
  27058. /**
  27059. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27060. */
  27061. /**
  27062. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27063. */
  27064. visibility: number;
  27065. /** Gets or sets the alpha index used to sort transparent meshes
  27066. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27067. */
  27068. alphaIndex: number;
  27069. /**
  27070. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27071. */
  27072. isVisible: boolean;
  27073. /**
  27074. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27075. */
  27076. isPickable: boolean;
  27077. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27078. showSubMeshesBoundingBox: boolean;
  27079. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27080. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27081. */
  27082. isBlocker: boolean;
  27083. /**
  27084. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27085. */
  27086. enablePointerMoveEvents: boolean;
  27087. /**
  27088. * Specifies the rendering group id for this mesh (0 by default)
  27089. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27090. */
  27091. renderingGroupId: number;
  27092. private _material;
  27093. /** Gets or sets current material */
  27094. material: Nullable<Material>;
  27095. /**
  27096. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27097. * @see http://doc.babylonjs.com/babylon101/shadows
  27098. */
  27099. receiveShadows: boolean;
  27100. /** Defines color to use when rendering outline */
  27101. outlineColor: Color3;
  27102. /** Define width to use when rendering outline */
  27103. outlineWidth: number;
  27104. /** Defines color to use when rendering overlay */
  27105. overlayColor: Color3;
  27106. /** Defines alpha to use when rendering overlay */
  27107. overlayAlpha: number;
  27108. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27109. hasVertexAlpha: boolean;
  27110. /** 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) */
  27111. useVertexColors: boolean;
  27112. /**
  27113. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27114. */
  27115. computeBonesUsingShaders: boolean;
  27116. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27117. numBoneInfluencers: number;
  27118. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27119. applyFog: boolean;
  27120. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27121. useOctreeForRenderingSelection: boolean;
  27122. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27123. useOctreeForPicking: boolean;
  27124. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27125. useOctreeForCollisions: boolean;
  27126. /**
  27127. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27128. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27129. */
  27130. layerMask: number;
  27131. /**
  27132. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27133. */
  27134. alwaysSelectAsActiveMesh: boolean;
  27135. /**
  27136. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27137. */
  27138. doNotSyncBoundingInfo: boolean;
  27139. /**
  27140. * Gets or sets the current action manager
  27141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27142. */
  27143. actionManager: Nullable<AbstractActionManager>;
  27144. private _meshCollisionData;
  27145. /**
  27146. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27148. */
  27149. ellipsoid: Vector3;
  27150. /**
  27151. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27153. */
  27154. ellipsoidOffset: Vector3;
  27155. /**
  27156. * Gets or sets a collision mask used to mask collisions (default is -1).
  27157. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27158. */
  27159. collisionMask: number;
  27160. /**
  27161. * Gets or sets the current collision group mask (-1 by default).
  27162. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27163. */
  27164. collisionGroup: number;
  27165. /**
  27166. * Defines edge width used when edgesRenderer is enabled
  27167. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27168. */
  27169. edgesWidth: number;
  27170. /**
  27171. * Defines edge color used when edgesRenderer is enabled
  27172. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27173. */
  27174. edgesColor: Color4;
  27175. /** @hidden */
  27176. _edgesRenderer: Nullable<IEdgesRenderer>;
  27177. /** @hidden */
  27178. _masterMesh: Nullable<AbstractMesh>;
  27179. /** @hidden */
  27180. _boundingInfo: Nullable<BoundingInfo>;
  27181. /** @hidden */
  27182. _renderId: number;
  27183. /**
  27184. * Gets or sets the list of subMeshes
  27185. * @see http://doc.babylonjs.com/how_to/multi_materials
  27186. */
  27187. subMeshes: SubMesh[];
  27188. /** @hidden */
  27189. _intersectionsInProgress: AbstractMesh[];
  27190. /** @hidden */
  27191. _unIndexed: boolean;
  27192. /** @hidden */
  27193. _lightSources: Light[];
  27194. /** Gets the list of lights affecting that mesh */
  27195. readonly lightSources: Light[];
  27196. /** @hidden */
  27197. readonly _positions: Nullable<Vector3[]>;
  27198. /** @hidden */
  27199. _waitingData: {
  27200. lods: Nullable<any>;
  27201. actions: Nullable<any>;
  27202. freezeWorldMatrix: Nullable<boolean>;
  27203. };
  27204. /** @hidden */
  27205. _bonesTransformMatrices: Nullable<Float32Array>;
  27206. /** @hidden */
  27207. _transformMatrixTexture: Nullable<RawTexture>;
  27208. /**
  27209. * Gets or sets a skeleton to apply skining transformations
  27210. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27211. */
  27212. skeleton: Nullable<Skeleton>;
  27213. /**
  27214. * An event triggered when the mesh is rebuilt.
  27215. */
  27216. onRebuildObservable: Observable<AbstractMesh>;
  27217. /**
  27218. * Creates a new AbstractMesh
  27219. * @param name defines the name of the mesh
  27220. * @param scene defines the hosting scene
  27221. */
  27222. constructor(name: string, scene?: Nullable<Scene>);
  27223. /**
  27224. * Returns the string "AbstractMesh"
  27225. * @returns "AbstractMesh"
  27226. */
  27227. getClassName(): string;
  27228. /**
  27229. * Gets a string representation of the current mesh
  27230. * @param fullDetails defines a boolean indicating if full details must be included
  27231. * @returns a string representation of the current mesh
  27232. */
  27233. toString(fullDetails?: boolean): string;
  27234. /**
  27235. * @hidden
  27236. */
  27237. protected _getEffectiveParent(): Nullable<Node>;
  27238. /** @hidden */
  27239. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27240. /** @hidden */
  27241. _rebuild(): void;
  27242. /** @hidden */
  27243. _resyncLightSources(): void;
  27244. /** @hidden */
  27245. _resyncLighSource(light: Light): void;
  27246. /** @hidden */
  27247. _unBindEffect(): void;
  27248. /** @hidden */
  27249. _removeLightSource(light: Light, dispose: boolean): void;
  27250. private _markSubMeshesAsDirty;
  27251. /** @hidden */
  27252. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27253. /** @hidden */
  27254. _markSubMeshesAsAttributesDirty(): void;
  27255. /** @hidden */
  27256. _markSubMeshesAsMiscDirty(): void;
  27257. /**
  27258. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27259. */
  27260. scaling: Vector3;
  27261. /**
  27262. * Returns true if the mesh is blocked. Implemented by child classes
  27263. */
  27264. readonly isBlocked: boolean;
  27265. /**
  27266. * Returns the mesh itself by default. Implemented by child classes
  27267. * @param camera defines the camera to use to pick the right LOD level
  27268. * @returns the currentAbstractMesh
  27269. */
  27270. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27271. /**
  27272. * Returns 0 by default. Implemented by child classes
  27273. * @returns an integer
  27274. */
  27275. getTotalVertices(): number;
  27276. /**
  27277. * Returns a positive integer : the total number of indices in this mesh geometry.
  27278. * @returns the numner of indices or zero if the mesh has no geometry.
  27279. */
  27280. getTotalIndices(): number;
  27281. /**
  27282. * Returns null by default. Implemented by child classes
  27283. * @returns null
  27284. */
  27285. getIndices(): Nullable<IndicesArray>;
  27286. /**
  27287. * Returns the array of the requested vertex data kind. Implemented by child classes
  27288. * @param kind defines the vertex data kind to use
  27289. * @returns null
  27290. */
  27291. getVerticesData(kind: string): Nullable<FloatArray>;
  27292. /**
  27293. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27294. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27295. * Note that a new underlying VertexBuffer object is created each call.
  27296. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27297. * @param kind defines vertex data kind:
  27298. * * VertexBuffer.PositionKind
  27299. * * VertexBuffer.UVKind
  27300. * * VertexBuffer.UV2Kind
  27301. * * VertexBuffer.UV3Kind
  27302. * * VertexBuffer.UV4Kind
  27303. * * VertexBuffer.UV5Kind
  27304. * * VertexBuffer.UV6Kind
  27305. * * VertexBuffer.ColorKind
  27306. * * VertexBuffer.MatricesIndicesKind
  27307. * * VertexBuffer.MatricesIndicesExtraKind
  27308. * * VertexBuffer.MatricesWeightsKind
  27309. * * VertexBuffer.MatricesWeightsExtraKind
  27310. * @param data defines the data source
  27311. * @param updatable defines if the data must be flagged as updatable (or static)
  27312. * @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
  27313. * @returns the current mesh
  27314. */
  27315. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27316. /**
  27317. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27318. * If the mesh has no geometry, it is simply returned as it is.
  27319. * @param kind defines vertex data kind:
  27320. * * VertexBuffer.PositionKind
  27321. * * VertexBuffer.UVKind
  27322. * * VertexBuffer.UV2Kind
  27323. * * VertexBuffer.UV3Kind
  27324. * * VertexBuffer.UV4Kind
  27325. * * VertexBuffer.UV5Kind
  27326. * * VertexBuffer.UV6Kind
  27327. * * VertexBuffer.ColorKind
  27328. * * VertexBuffer.MatricesIndicesKind
  27329. * * VertexBuffer.MatricesIndicesExtraKind
  27330. * * VertexBuffer.MatricesWeightsKind
  27331. * * VertexBuffer.MatricesWeightsExtraKind
  27332. * @param data defines the data source
  27333. * @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
  27334. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27335. * @returns the current mesh
  27336. */
  27337. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27338. /**
  27339. * Sets the mesh indices,
  27340. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27341. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27342. * @param totalVertices Defines the total number of vertices
  27343. * @returns the current mesh
  27344. */
  27345. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27346. /**
  27347. * Gets a boolean indicating if specific vertex data is present
  27348. * @param kind defines the vertex data kind to use
  27349. * @returns true is data kind is present
  27350. */
  27351. isVerticesDataPresent(kind: string): boolean;
  27352. /**
  27353. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27354. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27355. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27356. * @returns a BoundingInfo
  27357. */
  27358. getBoundingInfo(): BoundingInfo;
  27359. /**
  27360. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27361. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27362. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27363. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27364. * @returns the current mesh
  27365. */
  27366. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27367. /**
  27368. * Overwrite the current bounding info
  27369. * @param boundingInfo defines the new bounding info
  27370. * @returns the current mesh
  27371. */
  27372. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27373. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27374. readonly useBones: boolean;
  27375. /** @hidden */
  27376. _preActivate(): void;
  27377. /** @hidden */
  27378. _preActivateForIntermediateRendering(renderId: number): void;
  27379. /** @hidden */
  27380. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27381. /** @hidden */
  27382. _postActivate(): void;
  27383. /** @hidden */
  27384. _freeze(): void;
  27385. /** @hidden */
  27386. _unFreeze(): void;
  27387. /**
  27388. * Gets the current world matrix
  27389. * @returns a Matrix
  27390. */
  27391. getWorldMatrix(): Matrix;
  27392. /** @hidden */
  27393. _getWorldMatrixDeterminant(): number;
  27394. /**
  27395. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27396. */
  27397. readonly isAnInstance: boolean;
  27398. /**
  27399. * Gets a boolean indicating if this mesh has instances
  27400. */
  27401. readonly hasInstances: boolean;
  27402. /**
  27403. * Perform relative position change from the point of view of behind the front of the mesh.
  27404. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27405. * Supports definition of mesh facing forward or backward
  27406. * @param amountRight defines the distance on the right axis
  27407. * @param amountUp defines the distance on the up axis
  27408. * @param amountForward defines the distance on the forward axis
  27409. * @returns the current mesh
  27410. */
  27411. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27412. /**
  27413. * Calculate relative position change from the point of view of behind the front of the mesh.
  27414. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27415. * Supports definition of mesh facing forward or backward
  27416. * @param amountRight defines the distance on the right axis
  27417. * @param amountUp defines the distance on the up axis
  27418. * @param amountForward defines the distance on the forward axis
  27419. * @returns the new displacement vector
  27420. */
  27421. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27422. /**
  27423. * Perform 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 current mesh
  27429. */
  27430. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27431. /**
  27432. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27433. * Supports definition of mesh facing forward or backward.
  27434. * @param flipBack defines the flip
  27435. * @param twirlClockwise defines the twirl
  27436. * @param tiltRight defines the tilt
  27437. * @returns the new rotation vector
  27438. */
  27439. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27440. /**
  27441. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27442. * This means the mesh underlying bounding box and sphere are recomputed.
  27443. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27444. * @returns the current mesh
  27445. */
  27446. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27447. /** @hidden */
  27448. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27449. /** @hidden */
  27450. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27451. /** @hidden */
  27452. _updateBoundingInfo(): AbstractMesh;
  27453. /** @hidden */
  27454. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27455. /** @hidden */
  27456. protected _afterComputeWorldMatrix(): void;
  27457. /** @hidden */
  27458. readonly _effectiveMesh: AbstractMesh;
  27459. /**
  27460. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27461. * A mesh is in the frustum if its bounding box intersects the frustum
  27462. * @param frustumPlanes defines the frustum to test
  27463. * @returns true if the mesh is in the frustum planes
  27464. */
  27465. isInFrustum(frustumPlanes: Plane[]): boolean;
  27466. /**
  27467. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27468. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27469. * @param frustumPlanes defines the frustum to test
  27470. * @returns true if the mesh is completely in the frustum planes
  27471. */
  27472. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27473. /**
  27474. * True if the mesh intersects another mesh or a SolidParticle object
  27475. * @param mesh defines a target mesh or SolidParticle to test
  27476. * @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)
  27477. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27478. * @returns true if there is an intersection
  27479. */
  27480. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27481. /**
  27482. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27483. * @param point defines the point to test
  27484. * @returns true if there is an intersection
  27485. */
  27486. intersectsPoint(point: Vector3): boolean;
  27487. /**
  27488. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27489. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27490. */
  27491. checkCollisions: boolean;
  27492. /**
  27493. * Gets Collider object used to compute collisions (not physics)
  27494. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27495. */
  27496. readonly collider: Nullable<Collider>;
  27497. /**
  27498. * Move the mesh using collision engine
  27499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27500. * @param displacement defines the requested displacement vector
  27501. * @returns the current mesh
  27502. */
  27503. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27504. private _onCollisionPositionChange;
  27505. /** @hidden */
  27506. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27507. /** @hidden */
  27508. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27509. /** @hidden */
  27510. _checkCollision(collider: Collider): AbstractMesh;
  27511. /** @hidden */
  27512. _generatePointsArray(): boolean;
  27513. /**
  27514. * Checks if the passed Ray intersects with the mesh
  27515. * @param ray defines the ray to use
  27516. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27517. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27518. * @returns the picking info
  27519. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27520. */
  27521. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27522. /**
  27523. * Clones the current mesh
  27524. * @param name defines the mesh name
  27525. * @param newParent defines the new mesh parent
  27526. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27527. * @returns the new mesh
  27528. */
  27529. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27530. /**
  27531. * Disposes all the submeshes of the current meshnp
  27532. * @returns the current mesh
  27533. */
  27534. releaseSubMeshes(): AbstractMesh;
  27535. /**
  27536. * Releases resources associated with this abstract mesh.
  27537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27539. */
  27540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27541. /**
  27542. * Adds the passed mesh as a child to the current mesh
  27543. * @param mesh defines the child mesh
  27544. * @returns the current mesh
  27545. */
  27546. addChild(mesh: AbstractMesh): AbstractMesh;
  27547. /**
  27548. * Removes the passed mesh from the current mesh children list
  27549. * @param mesh defines the child mesh
  27550. * @returns the current mesh
  27551. */
  27552. removeChild(mesh: AbstractMesh): AbstractMesh;
  27553. /** @hidden */
  27554. private _initFacetData;
  27555. /**
  27556. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27557. * This method can be called within the render loop.
  27558. * 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
  27559. * @returns the current mesh
  27560. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27561. */
  27562. updateFacetData(): AbstractMesh;
  27563. /**
  27564. * Returns the facetLocalNormals array.
  27565. * The normals are expressed in the mesh local spac
  27566. * @returns an array of Vector3
  27567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27568. */
  27569. getFacetLocalNormals(): Vector3[];
  27570. /**
  27571. * Returns the facetLocalPositions array.
  27572. * The facet positions are expressed in the mesh local space
  27573. * @returns an array of Vector3
  27574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27575. */
  27576. getFacetLocalPositions(): Vector3[];
  27577. /**
  27578. * Returns the facetLocalPartioning array
  27579. * @returns an array of array of numbers
  27580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27581. */
  27582. getFacetLocalPartitioning(): number[][];
  27583. /**
  27584. * Returns the i-th facet position in the world system.
  27585. * This method allocates a new Vector3 per call
  27586. * @param i defines the facet index
  27587. * @returns a new Vector3
  27588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27589. */
  27590. getFacetPosition(i: number): Vector3;
  27591. /**
  27592. * Sets the reference Vector3 with the i-th facet position in the world system
  27593. * @param i defines the facet index
  27594. * @param ref defines the target vector
  27595. * @returns the current mesh
  27596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27597. */
  27598. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27599. /**
  27600. * Returns the i-th facet normal in the world system.
  27601. * This method allocates a new Vector3 per call
  27602. * @param i defines the facet index
  27603. * @returns a new Vector3
  27604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27605. */
  27606. getFacetNormal(i: number): Vector3;
  27607. /**
  27608. * Sets the reference Vector3 with the i-th facet normal in the world system
  27609. * @param i defines the facet index
  27610. * @param ref defines the target vector
  27611. * @returns the current mesh
  27612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27613. */
  27614. getFacetNormalToRef(i: number, ref: Vector3): this;
  27615. /**
  27616. * 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)
  27617. * @param x defines x coordinate
  27618. * @param y defines y coordinate
  27619. * @param z defines z coordinate
  27620. * @returns the array of facet indexes
  27621. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27622. */
  27623. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27624. /**
  27625. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27626. * @param projected sets as the (x,y,z) world projection on the facet
  27627. * @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
  27628. * @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
  27629. * @param x defines x coordinate
  27630. * @param y defines y coordinate
  27631. * @param z defines z coordinate
  27632. * @returns the face index if found (or null instead)
  27633. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27634. */
  27635. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27636. /**
  27637. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27638. * @param projected sets as the (x,y,z) local projection on the facet
  27639. * @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
  27640. * @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
  27641. * @param x defines x coordinate
  27642. * @param y defines y coordinate
  27643. * @param z defines z coordinate
  27644. * @returns the face index if found (or null instead)
  27645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27646. */
  27647. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27648. /**
  27649. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27650. * @returns the parameters
  27651. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27652. */
  27653. getFacetDataParameters(): any;
  27654. /**
  27655. * Disables the feature FacetData and frees the related memory
  27656. * @returns the current mesh
  27657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27658. */
  27659. disableFacetData(): AbstractMesh;
  27660. /**
  27661. * Updates the AbstractMesh indices array
  27662. * @param indices defines the data source
  27663. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27664. * @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)
  27665. * @returns the current mesh
  27666. */
  27667. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27668. /**
  27669. * Creates new normals data for the mesh
  27670. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27671. * @returns the current mesh
  27672. */
  27673. createNormals(updatable: boolean): AbstractMesh;
  27674. /**
  27675. * Align the mesh with a normal
  27676. * @param normal defines the normal to use
  27677. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27678. * @returns the current mesh
  27679. */
  27680. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27681. /** @hidden */
  27682. _checkOcclusionQuery(): boolean;
  27683. /**
  27684. * Disables the mesh edge rendering mode
  27685. * @returns the currentAbstractMesh
  27686. */
  27687. disableEdgesRendering(): AbstractMesh;
  27688. /**
  27689. * Enables the edge rendering mode on the mesh.
  27690. * This mode makes the mesh edges visible
  27691. * @param epsilon defines the maximal distance between two angles to detect a face
  27692. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27693. * @returns the currentAbstractMesh
  27694. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27695. */
  27696. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27697. }
  27698. }
  27699. declare module "babylonjs/Actions/actionEvent" {
  27700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27701. import { Nullable } from "babylonjs/types";
  27702. import { Sprite } from "babylonjs/Sprites/sprite";
  27703. import { Scene } from "babylonjs/scene";
  27704. import { Vector2 } from "babylonjs/Maths/math.vector";
  27705. /**
  27706. * Interface used to define ActionEvent
  27707. */
  27708. export interface IActionEvent {
  27709. /** The mesh or sprite that triggered the action */
  27710. source: any;
  27711. /** The X mouse cursor position at the time of the event */
  27712. pointerX: number;
  27713. /** The Y mouse cursor position at the time of the event */
  27714. pointerY: number;
  27715. /** The mesh that is currently pointed at (can be null) */
  27716. meshUnderPointer: Nullable<AbstractMesh>;
  27717. /** the original (browser) event that triggered the ActionEvent */
  27718. sourceEvent?: any;
  27719. /** additional data for the event */
  27720. additionalData?: any;
  27721. }
  27722. /**
  27723. * ActionEvent is the event being sent when an action is triggered.
  27724. */
  27725. export class ActionEvent implements IActionEvent {
  27726. /** The mesh or sprite that triggered the action */
  27727. source: any;
  27728. /** The X mouse cursor position at the time of the event */
  27729. pointerX: number;
  27730. /** The Y mouse cursor position at the time of the event */
  27731. pointerY: number;
  27732. /** The mesh that is currently pointed at (can be null) */
  27733. meshUnderPointer: Nullable<AbstractMesh>;
  27734. /** the original (browser) event that triggered the ActionEvent */
  27735. sourceEvent?: any;
  27736. /** additional data for the event */
  27737. additionalData?: any;
  27738. /**
  27739. * Creates a new ActionEvent
  27740. * @param source The mesh or sprite that triggered the action
  27741. * @param pointerX The X mouse cursor position at the time of the event
  27742. * @param pointerY The Y mouse cursor position at the time of the event
  27743. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27744. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27745. * @param additionalData additional data for the event
  27746. */
  27747. constructor(
  27748. /** The mesh or sprite that triggered the action */
  27749. source: any,
  27750. /** The X mouse cursor position at the time of the event */
  27751. pointerX: number,
  27752. /** The Y mouse cursor position at the time of the event */
  27753. pointerY: number,
  27754. /** The mesh that is currently pointed at (can be null) */
  27755. meshUnderPointer: Nullable<AbstractMesh>,
  27756. /** the original (browser) event that triggered the ActionEvent */
  27757. sourceEvent?: any,
  27758. /** additional data for the event */
  27759. additionalData?: any);
  27760. /**
  27761. * Helper function to auto-create an ActionEvent from a source mesh.
  27762. * @param source The source mesh that triggered the event
  27763. * @param evt The original (browser) event
  27764. * @param additionalData additional data for the event
  27765. * @returns the new ActionEvent
  27766. */
  27767. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27768. /**
  27769. * Helper function to auto-create an ActionEvent from a source sprite
  27770. * @param source The source sprite that triggered the event
  27771. * @param scene Scene associated with the sprite
  27772. * @param evt The original (browser) event
  27773. * @param additionalData additional data for the event
  27774. * @returns the new ActionEvent
  27775. */
  27776. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27777. /**
  27778. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27779. * @param scene the scene where the event occurred
  27780. * @param evt The original (browser) event
  27781. * @returns the new ActionEvent
  27782. */
  27783. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27784. /**
  27785. * Helper function to auto-create an ActionEvent from a primitive
  27786. * @param prim defines the target primitive
  27787. * @param pointerPos defines the pointer position
  27788. * @param evt The original (browser) event
  27789. * @param additionalData additional data for the event
  27790. * @returns the new ActionEvent
  27791. */
  27792. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27793. }
  27794. }
  27795. declare module "babylonjs/Actions/abstractActionManager" {
  27796. import { IDisposable } from "babylonjs/scene";
  27797. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27798. import { IAction } from "babylonjs/Actions/action";
  27799. import { Nullable } from "babylonjs/types";
  27800. /**
  27801. * Abstract class used to decouple action Manager from scene and meshes.
  27802. * Do not instantiate.
  27803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27804. */
  27805. export abstract class AbstractActionManager implements IDisposable {
  27806. /** Gets the list of active triggers */
  27807. static Triggers: {
  27808. [key: string]: number;
  27809. };
  27810. /** Gets the cursor to use when hovering items */
  27811. hoverCursor: string;
  27812. /** Gets the list of actions */
  27813. actions: IAction[];
  27814. /**
  27815. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27816. */
  27817. isRecursive: boolean;
  27818. /**
  27819. * Releases all associated resources
  27820. */
  27821. abstract dispose(): void;
  27822. /**
  27823. * Does this action manager has pointer triggers
  27824. */
  27825. abstract readonly hasPointerTriggers: boolean;
  27826. /**
  27827. * Does this action manager has pick triggers
  27828. */
  27829. abstract readonly hasPickTriggers: boolean;
  27830. /**
  27831. * Process a specific trigger
  27832. * @param trigger defines the trigger to process
  27833. * @param evt defines the event details to be processed
  27834. */
  27835. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27836. /**
  27837. * Does this action manager handles actions of any of the given triggers
  27838. * @param triggers defines the triggers to be tested
  27839. * @return a boolean indicating whether one (or more) of the triggers is handled
  27840. */
  27841. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27842. /**
  27843. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27844. * speed.
  27845. * @param triggerA defines the trigger to be tested
  27846. * @param triggerB defines the trigger to be tested
  27847. * @return a boolean indicating whether one (or more) of the triggers is handled
  27848. */
  27849. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27850. /**
  27851. * Does this action manager handles actions of a given trigger
  27852. * @param trigger defines the trigger to be tested
  27853. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27854. * @return whether the trigger is handled
  27855. */
  27856. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27857. /**
  27858. * Serialize this manager to a JSON object
  27859. * @param name defines the property name to store this manager
  27860. * @returns a JSON representation of this manager
  27861. */
  27862. abstract serialize(name: string): any;
  27863. /**
  27864. * Registers an action to this action manager
  27865. * @param action defines the action to be registered
  27866. * @return the action amended (prepared) after registration
  27867. */
  27868. abstract registerAction(action: IAction): Nullable<IAction>;
  27869. /**
  27870. * Unregisters an action to this action manager
  27871. * @param action defines the action to be unregistered
  27872. * @return a boolean indicating whether the action has been unregistered
  27873. */
  27874. abstract unregisterAction(action: IAction): Boolean;
  27875. /**
  27876. * Does exist one action manager with at least one trigger
  27877. **/
  27878. static readonly HasTriggers: boolean;
  27879. /**
  27880. * Does exist one action manager with at least one pick trigger
  27881. **/
  27882. static readonly HasPickTriggers: boolean;
  27883. /**
  27884. * Does exist one action manager that handles actions of a given trigger
  27885. * @param trigger defines the trigger to be tested
  27886. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27887. **/
  27888. static HasSpecificTrigger(trigger: number): boolean;
  27889. }
  27890. }
  27891. declare module "babylonjs/node" {
  27892. import { Scene } from "babylonjs/scene";
  27893. import { Nullable } from "babylonjs/types";
  27894. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27895. import { Engine } from "babylonjs/Engines/engine";
  27896. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27897. import { Observable } from "babylonjs/Misc/observable";
  27898. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27899. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27900. import { Animatable } from "babylonjs/Animations/animatable";
  27901. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27902. import { Animation } from "babylonjs/Animations/animation";
  27903. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27905. /**
  27906. * Defines how a node can be built from a string name.
  27907. */
  27908. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27909. /**
  27910. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27911. */
  27912. export class Node implements IBehaviorAware<Node> {
  27913. /** @hidden */
  27914. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27915. private static _NodeConstructors;
  27916. /**
  27917. * Add a new node constructor
  27918. * @param type defines the type name of the node to construct
  27919. * @param constructorFunc defines the constructor function
  27920. */
  27921. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27922. /**
  27923. * Returns a node constructor based on type name
  27924. * @param type defines the type name
  27925. * @param name defines the new node name
  27926. * @param scene defines the hosting scene
  27927. * @param options defines optional options to transmit to constructors
  27928. * @returns the new constructor or null
  27929. */
  27930. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27931. /**
  27932. * Gets or sets the name of the node
  27933. */
  27934. name: string;
  27935. /**
  27936. * Gets or sets the id of the node
  27937. */
  27938. id: string;
  27939. /**
  27940. * Gets or sets the unique id of the node
  27941. */
  27942. uniqueId: number;
  27943. /**
  27944. * Gets or sets a string used to store user defined state for the node
  27945. */
  27946. state: string;
  27947. /**
  27948. * Gets or sets an object used to store user defined information for the node
  27949. */
  27950. metadata: any;
  27951. /**
  27952. * For internal use only. Please do not use.
  27953. */
  27954. reservedDataStore: any;
  27955. /**
  27956. * List of inspectable custom properties (used by the Inspector)
  27957. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27958. */
  27959. inspectableCustomProperties: IInspectable[];
  27960. private _doNotSerialize;
  27961. /**
  27962. * Gets or sets a boolean used to define if the node must be serialized
  27963. */
  27964. doNotSerialize: boolean;
  27965. /** @hidden */
  27966. _isDisposed: boolean;
  27967. /**
  27968. * Gets a list of Animations associated with the node
  27969. */
  27970. animations: import("babylonjs/Animations/animation").Animation[];
  27971. protected _ranges: {
  27972. [name: string]: Nullable<AnimationRange>;
  27973. };
  27974. /**
  27975. * Callback raised when the node is ready to be used
  27976. */
  27977. onReady: Nullable<(node: Node) => void>;
  27978. private _isEnabled;
  27979. private _isParentEnabled;
  27980. private _isReady;
  27981. /** @hidden */
  27982. _currentRenderId: number;
  27983. private _parentUpdateId;
  27984. /** @hidden */
  27985. _childUpdateId: number;
  27986. /** @hidden */
  27987. _waitingParentId: Nullable<string>;
  27988. /** @hidden */
  27989. _scene: Scene;
  27990. /** @hidden */
  27991. _cache: any;
  27992. private _parentNode;
  27993. private _children;
  27994. /** @hidden */
  27995. _worldMatrix: Matrix;
  27996. /** @hidden */
  27997. _worldMatrixDeterminant: number;
  27998. /** @hidden */
  27999. _worldMatrixDeterminantIsDirty: boolean;
  28000. /** @hidden */
  28001. private _sceneRootNodesIndex;
  28002. /**
  28003. * Gets a boolean indicating if the node has been disposed
  28004. * @returns true if the node was disposed
  28005. */
  28006. isDisposed(): boolean;
  28007. /**
  28008. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28009. * @see https://doc.babylonjs.com/how_to/parenting
  28010. */
  28011. parent: Nullable<Node>;
  28012. /** @hidden */
  28013. _addToSceneRootNodes(): void;
  28014. /** @hidden */
  28015. _removeFromSceneRootNodes(): void;
  28016. private _animationPropertiesOverride;
  28017. /**
  28018. * Gets or sets the animation properties override
  28019. */
  28020. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28021. /**
  28022. * Gets a string idenfifying the name of the class
  28023. * @returns "Node" string
  28024. */
  28025. getClassName(): string;
  28026. /** @hidden */
  28027. readonly _isNode: boolean;
  28028. /**
  28029. * An event triggered when the mesh is disposed
  28030. */
  28031. onDisposeObservable: Observable<Node>;
  28032. private _onDisposeObserver;
  28033. /**
  28034. * Sets a callback that will be raised when the node will be disposed
  28035. */
  28036. onDispose: () => void;
  28037. /**
  28038. * Creates a new Node
  28039. * @param name the name and id to be given to this node
  28040. * @param scene the scene this node will be added to
  28041. */
  28042. constructor(name: string, scene?: Nullable<Scene>);
  28043. /**
  28044. * Gets the scene of the node
  28045. * @returns a scene
  28046. */
  28047. getScene(): Scene;
  28048. /**
  28049. * Gets the engine of the node
  28050. * @returns a Engine
  28051. */
  28052. getEngine(): Engine;
  28053. private _behaviors;
  28054. /**
  28055. * Attach a behavior to the node
  28056. * @see http://doc.babylonjs.com/features/behaviour
  28057. * @param behavior defines the behavior to attach
  28058. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28059. * @returns the current Node
  28060. */
  28061. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28062. /**
  28063. * Remove an attached behavior
  28064. * @see http://doc.babylonjs.com/features/behaviour
  28065. * @param behavior defines the behavior to attach
  28066. * @returns the current Node
  28067. */
  28068. removeBehavior(behavior: Behavior<Node>): Node;
  28069. /**
  28070. * Gets the list of attached behaviors
  28071. * @see http://doc.babylonjs.com/features/behaviour
  28072. */
  28073. readonly behaviors: Behavior<Node>[];
  28074. /**
  28075. * Gets an attached behavior by name
  28076. * @param name defines the name of the behavior to look for
  28077. * @see http://doc.babylonjs.com/features/behaviour
  28078. * @returns null if behavior was not found else the requested behavior
  28079. */
  28080. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28081. /**
  28082. * Returns the latest update of the World matrix
  28083. * @returns a Matrix
  28084. */
  28085. getWorldMatrix(): Matrix;
  28086. /** @hidden */
  28087. _getWorldMatrixDeterminant(): number;
  28088. /**
  28089. * Returns directly the latest state of the mesh World matrix.
  28090. * A Matrix is returned.
  28091. */
  28092. readonly worldMatrixFromCache: Matrix;
  28093. /** @hidden */
  28094. _initCache(): void;
  28095. /** @hidden */
  28096. updateCache(force?: boolean): void;
  28097. /** @hidden */
  28098. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28099. /** @hidden */
  28100. _updateCache(ignoreParentClass?: boolean): void;
  28101. /** @hidden */
  28102. _isSynchronized(): boolean;
  28103. /** @hidden */
  28104. _markSyncedWithParent(): void;
  28105. /** @hidden */
  28106. isSynchronizedWithParent(): boolean;
  28107. /** @hidden */
  28108. isSynchronized(): boolean;
  28109. /**
  28110. * Is this node ready to be used/rendered
  28111. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28112. * @return true if the node is ready
  28113. */
  28114. isReady(completeCheck?: boolean): boolean;
  28115. /**
  28116. * Is this node enabled?
  28117. * 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
  28118. * @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
  28119. * @return whether this node (and its parent) is enabled
  28120. */
  28121. isEnabled(checkAncestors?: boolean): boolean;
  28122. /** @hidden */
  28123. protected _syncParentEnabledState(): void;
  28124. /**
  28125. * Set the enabled state of this node
  28126. * @param value defines the new enabled state
  28127. */
  28128. setEnabled(value: boolean): void;
  28129. /**
  28130. * Is this node a descendant of the given node?
  28131. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28132. * @param ancestor defines the parent node to inspect
  28133. * @returns a boolean indicating if this node is a descendant of the given node
  28134. */
  28135. isDescendantOf(ancestor: Node): boolean;
  28136. /** @hidden */
  28137. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28138. /**
  28139. * Will return all nodes that have this node as ascendant
  28140. * @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
  28141. * @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
  28142. * @return all children nodes of all types
  28143. */
  28144. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28145. /**
  28146. * Get all child-meshes of this node
  28147. * @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)
  28148. * @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
  28149. * @returns an array of AbstractMesh
  28150. */
  28151. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28152. /**
  28153. * Get all direct children of this node
  28154. * @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
  28155. * @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)
  28156. * @returns an array of Node
  28157. */
  28158. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28159. /** @hidden */
  28160. _setReady(state: boolean): void;
  28161. /**
  28162. * Get an animation by name
  28163. * @param name defines the name of the animation to look for
  28164. * @returns null if not found else the requested animation
  28165. */
  28166. getAnimationByName(name: string): Nullable<Animation>;
  28167. /**
  28168. * Creates an animation range for this node
  28169. * @param name defines the name of the range
  28170. * @param from defines the starting key
  28171. * @param to defines the end key
  28172. */
  28173. createAnimationRange(name: string, from: number, to: number): void;
  28174. /**
  28175. * Delete a specific animation range
  28176. * @param name defines the name of the range to delete
  28177. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28178. */
  28179. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28180. /**
  28181. * Get an animation range by name
  28182. * @param name defines the name of the animation range to look for
  28183. * @returns null if not found else the requested animation range
  28184. */
  28185. getAnimationRange(name: string): Nullable<AnimationRange>;
  28186. /**
  28187. * Gets the list of all animation ranges defined on this node
  28188. * @returns an array
  28189. */
  28190. getAnimationRanges(): Nullable<AnimationRange>[];
  28191. /**
  28192. * Will start the animation sequence
  28193. * @param name defines the range frames for animation sequence
  28194. * @param loop defines if the animation should loop (false by default)
  28195. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28196. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28197. * @returns the object created for this animation. If range does not exist, it will return null
  28198. */
  28199. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28200. /**
  28201. * Serialize animation ranges into a JSON compatible object
  28202. * @returns serialization object
  28203. */
  28204. serializeAnimationRanges(): any;
  28205. /**
  28206. * Computes the world matrix of the node
  28207. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28208. * @returns the world matrix
  28209. */
  28210. computeWorldMatrix(force?: boolean): Matrix;
  28211. /**
  28212. * Releases resources associated with this node.
  28213. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28214. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28215. */
  28216. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28217. /**
  28218. * Parse animation range data from a serialization object and store them into a given node
  28219. * @param node defines where to store the animation ranges
  28220. * @param parsedNode defines the serialization object to read data from
  28221. * @param scene defines the hosting scene
  28222. */
  28223. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28224. /**
  28225. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28226. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28227. * @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
  28228. * @returns the new bounding vectors
  28229. */
  28230. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28231. min: Vector3;
  28232. max: Vector3;
  28233. };
  28234. }
  28235. }
  28236. declare module "babylonjs/Animations/animation" {
  28237. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28238. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28239. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28240. import { Nullable } from "babylonjs/types";
  28241. import { Scene } from "babylonjs/scene";
  28242. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28243. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28244. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28245. import { Node } from "babylonjs/node";
  28246. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28247. import { Size } from "babylonjs/Maths/math.size";
  28248. import { Animatable } from "babylonjs/Animations/animatable";
  28249. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28250. /**
  28251. * @hidden
  28252. */
  28253. export class _IAnimationState {
  28254. key: number;
  28255. repeatCount: number;
  28256. workValue?: any;
  28257. loopMode?: number;
  28258. offsetValue?: any;
  28259. highLimitValue?: any;
  28260. }
  28261. /**
  28262. * Class used to store any kind of animation
  28263. */
  28264. export class Animation {
  28265. /**Name of the animation */
  28266. name: string;
  28267. /**Property to animate */
  28268. targetProperty: string;
  28269. /**The frames per second of the animation */
  28270. framePerSecond: number;
  28271. /**The data type of the animation */
  28272. dataType: number;
  28273. /**The loop mode of the animation */
  28274. loopMode?: number | undefined;
  28275. /**Specifies if blending should be enabled */
  28276. enableBlending?: boolean | undefined;
  28277. /**
  28278. * Use matrix interpolation instead of using direct key value when animating matrices
  28279. */
  28280. static AllowMatricesInterpolation: boolean;
  28281. /**
  28282. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28283. */
  28284. static AllowMatrixDecomposeForInterpolation: boolean;
  28285. /**
  28286. * Stores the key frames of the animation
  28287. */
  28288. private _keys;
  28289. /**
  28290. * Stores the easing function of the animation
  28291. */
  28292. private _easingFunction;
  28293. /**
  28294. * @hidden Internal use only
  28295. */
  28296. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28297. /**
  28298. * The set of event that will be linked to this animation
  28299. */
  28300. private _events;
  28301. /**
  28302. * Stores an array of target property paths
  28303. */
  28304. targetPropertyPath: string[];
  28305. /**
  28306. * Stores the blending speed of the animation
  28307. */
  28308. blendingSpeed: number;
  28309. /**
  28310. * Stores the animation ranges for the animation
  28311. */
  28312. private _ranges;
  28313. /**
  28314. * @hidden Internal use
  28315. */
  28316. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28317. /**
  28318. * Sets up an animation
  28319. * @param property The property to animate
  28320. * @param animationType The animation type to apply
  28321. * @param framePerSecond The frames per second of the animation
  28322. * @param easingFunction The easing function used in the animation
  28323. * @returns The created animation
  28324. */
  28325. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28326. /**
  28327. * Create and start an animation on a node
  28328. * @param name defines the name of the global animation that will be run on all nodes
  28329. * @param node defines the root node where the animation will take place
  28330. * @param targetProperty defines property to animate
  28331. * @param framePerSecond defines the number of frame per second yo use
  28332. * @param totalFrame defines the number of frames in total
  28333. * @param from defines the initial value
  28334. * @param to defines the final value
  28335. * @param loopMode defines which loop mode you want to use (off by default)
  28336. * @param easingFunction defines the easing function to use (linear by default)
  28337. * @param onAnimationEnd defines the callback to call when animation end
  28338. * @returns the animatable created for this animation
  28339. */
  28340. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28341. /**
  28342. * Create and start an animation on a node and its descendants
  28343. * @param name defines the name of the global animation that will be run on all nodes
  28344. * @param node defines the root node where the animation will take place
  28345. * @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
  28346. * @param targetProperty defines property to animate
  28347. * @param framePerSecond defines the number of frame per second to use
  28348. * @param totalFrame defines the number of frames in total
  28349. * @param from defines the initial value
  28350. * @param to defines the final value
  28351. * @param loopMode defines which loop mode you want to use (off by default)
  28352. * @param easingFunction defines the easing function to use (linear by default)
  28353. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28354. * @returns the list of animatables created for all nodes
  28355. * @example https://www.babylonjs-playground.com/#MH0VLI
  28356. */
  28357. 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[]>;
  28358. /**
  28359. * Creates a new animation, merges it with the existing animations and starts it
  28360. * @param name Name of the animation
  28361. * @param node Node which contains the scene that begins the animations
  28362. * @param targetProperty Specifies which property to animate
  28363. * @param framePerSecond The frames per second of the animation
  28364. * @param totalFrame The total number of frames
  28365. * @param from The frame at the beginning of the animation
  28366. * @param to The frame at the end of the animation
  28367. * @param loopMode Specifies the loop mode of the animation
  28368. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28369. * @param onAnimationEnd Callback to run once the animation is complete
  28370. * @returns Nullable animation
  28371. */
  28372. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28373. /**
  28374. * Transition property of an host to the target Value
  28375. * @param property The property to transition
  28376. * @param targetValue The target Value of the property
  28377. * @param host The object where the property to animate belongs
  28378. * @param scene Scene used to run the animation
  28379. * @param frameRate Framerate (in frame/s) to use
  28380. * @param transition The transition type we want to use
  28381. * @param duration The duration of the animation, in milliseconds
  28382. * @param onAnimationEnd Callback trigger at the end of the animation
  28383. * @returns Nullable animation
  28384. */
  28385. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28386. /**
  28387. * Return the array of runtime animations currently using this animation
  28388. */
  28389. readonly runtimeAnimations: RuntimeAnimation[];
  28390. /**
  28391. * Specifies if any of the runtime animations are currently running
  28392. */
  28393. readonly hasRunningRuntimeAnimations: boolean;
  28394. /**
  28395. * Initializes the animation
  28396. * @param name Name of the animation
  28397. * @param targetProperty Property to animate
  28398. * @param framePerSecond The frames per second of the animation
  28399. * @param dataType The data type of the animation
  28400. * @param loopMode The loop mode of the animation
  28401. * @param enableBlending Specifies if blending should be enabled
  28402. */
  28403. constructor(
  28404. /**Name of the animation */
  28405. name: string,
  28406. /**Property to animate */
  28407. targetProperty: string,
  28408. /**The frames per second of the animation */
  28409. framePerSecond: number,
  28410. /**The data type of the animation */
  28411. dataType: number,
  28412. /**The loop mode of the animation */
  28413. loopMode?: number | undefined,
  28414. /**Specifies if blending should be enabled */
  28415. enableBlending?: boolean | undefined);
  28416. /**
  28417. * Converts the animation to a string
  28418. * @param fullDetails support for multiple levels of logging within scene loading
  28419. * @returns String form of the animation
  28420. */
  28421. toString(fullDetails?: boolean): string;
  28422. /**
  28423. * Add an event to this animation
  28424. * @param event Event to add
  28425. */
  28426. addEvent(event: AnimationEvent): void;
  28427. /**
  28428. * Remove all events found at the given frame
  28429. * @param frame The frame to remove events from
  28430. */
  28431. removeEvents(frame: number): void;
  28432. /**
  28433. * Retrieves all the events from the animation
  28434. * @returns Events from the animation
  28435. */
  28436. getEvents(): AnimationEvent[];
  28437. /**
  28438. * Creates an animation range
  28439. * @param name Name of the animation range
  28440. * @param from Starting frame of the animation range
  28441. * @param to Ending frame of the animation
  28442. */
  28443. createRange(name: string, from: number, to: number): void;
  28444. /**
  28445. * Deletes an animation range by name
  28446. * @param name Name of the animation range to delete
  28447. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28448. */
  28449. deleteRange(name: string, deleteFrames?: boolean): void;
  28450. /**
  28451. * Gets the animation range by name, or null if not defined
  28452. * @param name Name of the animation range
  28453. * @returns Nullable animation range
  28454. */
  28455. getRange(name: string): Nullable<AnimationRange>;
  28456. /**
  28457. * Gets the key frames from the animation
  28458. * @returns The key frames of the animation
  28459. */
  28460. getKeys(): Array<IAnimationKey>;
  28461. /**
  28462. * Gets the highest frame rate of the animation
  28463. * @returns Highest frame rate of the animation
  28464. */
  28465. getHighestFrame(): number;
  28466. /**
  28467. * Gets the easing function of the animation
  28468. * @returns Easing function of the animation
  28469. */
  28470. getEasingFunction(): IEasingFunction;
  28471. /**
  28472. * Sets the easing function of the animation
  28473. * @param easingFunction A custom mathematical formula for animation
  28474. */
  28475. setEasingFunction(easingFunction: EasingFunction): void;
  28476. /**
  28477. * Interpolates a scalar linearly
  28478. * @param startValue Start value of the animation curve
  28479. * @param endValue End value of the animation curve
  28480. * @param gradient Scalar amount to interpolate
  28481. * @returns Interpolated scalar value
  28482. */
  28483. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28484. /**
  28485. * Interpolates a scalar cubically
  28486. * @param startValue Start value of the animation curve
  28487. * @param outTangent End tangent of the animation
  28488. * @param endValue End value of the animation curve
  28489. * @param inTangent Start tangent of the animation curve
  28490. * @param gradient Scalar amount to interpolate
  28491. * @returns Interpolated scalar value
  28492. */
  28493. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28494. /**
  28495. * Interpolates a quaternion using a spherical linear interpolation
  28496. * @param startValue Start value of the animation curve
  28497. * @param endValue End value of the animation curve
  28498. * @param gradient Scalar amount to interpolate
  28499. * @returns Interpolated quaternion value
  28500. */
  28501. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28502. /**
  28503. * Interpolates a quaternion cubically
  28504. * @param startValue Start value of the animation curve
  28505. * @param outTangent End tangent of the animation curve
  28506. * @param endValue End value of the animation curve
  28507. * @param inTangent Start tangent of the animation curve
  28508. * @param gradient Scalar amount to interpolate
  28509. * @returns Interpolated quaternion value
  28510. */
  28511. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28512. /**
  28513. * Interpolates a Vector3 linearl
  28514. * @param startValue Start value of the animation curve
  28515. * @param endValue End value of the animation curve
  28516. * @param gradient Scalar amount to interpolate
  28517. * @returns Interpolated scalar value
  28518. */
  28519. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28520. /**
  28521. * Interpolates a Vector3 cubically
  28522. * @param startValue Start value of the animation curve
  28523. * @param outTangent End tangent of the animation
  28524. * @param endValue End value of the animation curve
  28525. * @param inTangent Start tangent of the animation curve
  28526. * @param gradient Scalar amount to interpolate
  28527. * @returns InterpolatedVector3 value
  28528. */
  28529. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28530. /**
  28531. * Interpolates a Vector2 linearly
  28532. * @param startValue Start value of the animation curve
  28533. * @param endValue End value of the animation curve
  28534. * @param gradient Scalar amount to interpolate
  28535. * @returns Interpolated Vector2 value
  28536. */
  28537. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28538. /**
  28539. * Interpolates a Vector2 cubically
  28540. * @param startValue Start value of the animation curve
  28541. * @param outTangent End tangent of the animation
  28542. * @param endValue End value of the animation curve
  28543. * @param inTangent Start tangent of the animation curve
  28544. * @param gradient Scalar amount to interpolate
  28545. * @returns Interpolated Vector2 value
  28546. */
  28547. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28548. /**
  28549. * Interpolates a size linearly
  28550. * @param startValue Start value of the animation curve
  28551. * @param endValue End value of the animation curve
  28552. * @param gradient Scalar amount to interpolate
  28553. * @returns Interpolated Size value
  28554. */
  28555. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28556. /**
  28557. * Interpolates a Color3 linearly
  28558. * @param startValue Start value of the animation curve
  28559. * @param endValue End value of the animation curve
  28560. * @param gradient Scalar amount to interpolate
  28561. * @returns Interpolated Color3 value
  28562. */
  28563. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28564. /**
  28565. * Interpolates a Color4 linearly
  28566. * @param startValue Start value of the animation curve
  28567. * @param endValue End value of the animation curve
  28568. * @param gradient Scalar amount to interpolate
  28569. * @returns Interpolated Color3 value
  28570. */
  28571. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28572. /**
  28573. * @hidden Internal use only
  28574. */
  28575. _getKeyValue(value: any): any;
  28576. /**
  28577. * @hidden Internal use only
  28578. */
  28579. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28580. /**
  28581. * Defines the function to use to interpolate matrices
  28582. * @param startValue defines the start matrix
  28583. * @param endValue defines the end matrix
  28584. * @param gradient defines the gradient between both matrices
  28585. * @param result defines an optional target matrix where to store the interpolation
  28586. * @returns the interpolated matrix
  28587. */
  28588. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28589. /**
  28590. * Makes a copy of the animation
  28591. * @returns Cloned animation
  28592. */
  28593. clone(): Animation;
  28594. /**
  28595. * Sets the key frames of the animation
  28596. * @param values The animation key frames to set
  28597. */
  28598. setKeys(values: Array<IAnimationKey>): void;
  28599. /**
  28600. * Serializes the animation to an object
  28601. * @returns Serialized object
  28602. */
  28603. serialize(): any;
  28604. /**
  28605. * Float animation type
  28606. */
  28607. static readonly ANIMATIONTYPE_FLOAT: number;
  28608. /**
  28609. * Vector3 animation type
  28610. */
  28611. static readonly ANIMATIONTYPE_VECTOR3: number;
  28612. /**
  28613. * Quaternion animation type
  28614. */
  28615. static readonly ANIMATIONTYPE_QUATERNION: number;
  28616. /**
  28617. * Matrix animation type
  28618. */
  28619. static readonly ANIMATIONTYPE_MATRIX: number;
  28620. /**
  28621. * Color3 animation type
  28622. */
  28623. static readonly ANIMATIONTYPE_COLOR3: number;
  28624. /**
  28625. * Color3 animation type
  28626. */
  28627. static readonly ANIMATIONTYPE_COLOR4: number;
  28628. /**
  28629. * Vector2 animation type
  28630. */
  28631. static readonly ANIMATIONTYPE_VECTOR2: number;
  28632. /**
  28633. * Size animation type
  28634. */
  28635. static readonly ANIMATIONTYPE_SIZE: number;
  28636. /**
  28637. * Relative Loop Mode
  28638. */
  28639. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28640. /**
  28641. * Cycle Loop Mode
  28642. */
  28643. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28644. /**
  28645. * Constant Loop Mode
  28646. */
  28647. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28648. /** @hidden */
  28649. static _UniversalLerp(left: any, right: any, amount: number): any;
  28650. /**
  28651. * Parses an animation object and creates an animation
  28652. * @param parsedAnimation Parsed animation object
  28653. * @returns Animation object
  28654. */
  28655. static Parse(parsedAnimation: any): Animation;
  28656. /**
  28657. * Appends the serialized animations from the source animations
  28658. * @param source Source containing the animations
  28659. * @param destination Target to store the animations
  28660. */
  28661. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28662. }
  28663. }
  28664. declare module "babylonjs/Animations/animatable.interface" {
  28665. import { Nullable } from "babylonjs/types";
  28666. import { Animation } from "babylonjs/Animations/animation";
  28667. /**
  28668. * Interface containing an array of animations
  28669. */
  28670. export interface IAnimatable {
  28671. /**
  28672. * Array of animations
  28673. */
  28674. animations: Nullable<Array<Animation>>;
  28675. }
  28676. }
  28677. declare module "babylonjs/Materials/fresnelParameters" {
  28678. import { Color3 } from "babylonjs/Maths/math.color";
  28679. /**
  28680. * This represents all the required information to add a fresnel effect on a material:
  28681. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28682. */
  28683. export class FresnelParameters {
  28684. private _isEnabled;
  28685. /**
  28686. * Define if the fresnel effect is enable or not.
  28687. */
  28688. isEnabled: boolean;
  28689. /**
  28690. * Define the color used on edges (grazing angle)
  28691. */
  28692. leftColor: Color3;
  28693. /**
  28694. * Define the color used on center
  28695. */
  28696. rightColor: Color3;
  28697. /**
  28698. * Define bias applied to computed fresnel term
  28699. */
  28700. bias: number;
  28701. /**
  28702. * Defined the power exponent applied to fresnel term
  28703. */
  28704. power: number;
  28705. /**
  28706. * Clones the current fresnel and its valuues
  28707. * @returns a clone fresnel configuration
  28708. */
  28709. clone(): FresnelParameters;
  28710. /**
  28711. * Serializes the current fresnel parameters to a JSON representation.
  28712. * @return the JSON serialization
  28713. */
  28714. serialize(): any;
  28715. /**
  28716. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28717. * @param parsedFresnelParameters Define the JSON representation
  28718. * @returns the parsed parameters
  28719. */
  28720. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28721. }
  28722. }
  28723. declare module "babylonjs/Misc/decorators" {
  28724. import { Nullable } from "babylonjs/types";
  28725. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28726. import { Scene } from "babylonjs/scene";
  28727. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28728. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28729. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28730. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28731. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28732. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28733. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28734. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28735. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28736. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28737. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28738. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28739. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28740. /**
  28741. * Decorator used to define property that can be serialized as reference to a camera
  28742. * @param sourceName defines the name of the property to decorate
  28743. */
  28744. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28745. /**
  28746. * Class used to help serialization objects
  28747. */
  28748. export class SerializationHelper {
  28749. /** @hidden */
  28750. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28751. /** @hidden */
  28752. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28753. /** @hidden */
  28754. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28755. /** @hidden */
  28756. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28757. /**
  28758. * Appends the serialized animations from the source animations
  28759. * @param source Source containing the animations
  28760. * @param destination Target to store the animations
  28761. */
  28762. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28763. /**
  28764. * Static function used to serialized a specific entity
  28765. * @param entity defines the entity to serialize
  28766. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28767. * @returns a JSON compatible object representing the serialization of the entity
  28768. */
  28769. static Serialize<T>(entity: T, serializationObject?: any): any;
  28770. /**
  28771. * Creates a new entity from a serialization data object
  28772. * @param creationFunction defines a function used to instanciated the new entity
  28773. * @param source defines the source serialization data
  28774. * @param scene defines the hosting scene
  28775. * @param rootUrl defines the root url for resources
  28776. * @returns a new entity
  28777. */
  28778. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28779. /**
  28780. * Clones an object
  28781. * @param creationFunction defines the function used to instanciate the new object
  28782. * @param source defines the source object
  28783. * @returns the cloned object
  28784. */
  28785. static Clone<T>(creationFunction: () => T, source: T): T;
  28786. /**
  28787. * Instanciates a new object based on a source one (some data will be shared between both object)
  28788. * @param creationFunction defines the function used to instanciate the new object
  28789. * @param source defines the source object
  28790. * @returns the new object
  28791. */
  28792. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28793. }
  28794. }
  28795. declare module "babylonjs/Misc/guid" {
  28796. /**
  28797. * Class used to manipulate GUIDs
  28798. */
  28799. export class GUID {
  28800. /**
  28801. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28802. * Be aware Math.random() could cause collisions, but:
  28803. * "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"
  28804. * @returns a pseudo random id
  28805. */
  28806. static RandomId(): string;
  28807. }
  28808. }
  28809. declare module "babylonjs/Materials/Textures/baseTexture" {
  28810. import { Observable } from "babylonjs/Misc/observable";
  28811. import { Nullable } from "babylonjs/types";
  28812. import { Scene } from "babylonjs/scene";
  28813. import { Matrix } from "babylonjs/Maths/math.vector";
  28814. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28815. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28816. import { ISize } from "babylonjs/Maths/math.size";
  28817. /**
  28818. * Base class of all the textures in babylon.
  28819. * It groups all the common properties the materials, post process, lights... might need
  28820. * in order to make a correct use of the texture.
  28821. */
  28822. export class BaseTexture implements IAnimatable {
  28823. /**
  28824. * Default anisotropic filtering level for the application.
  28825. * It is set to 4 as a good tradeoff between perf and quality.
  28826. */
  28827. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28828. /**
  28829. * Gets or sets the unique id of the texture
  28830. */
  28831. uniqueId: number;
  28832. /**
  28833. * Define the name of the texture.
  28834. */
  28835. name: string;
  28836. /**
  28837. * Gets or sets an object used to store user defined information.
  28838. */
  28839. metadata: any;
  28840. /**
  28841. * For internal use only. Please do not use.
  28842. */
  28843. reservedDataStore: any;
  28844. private _hasAlpha;
  28845. /**
  28846. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28847. */
  28848. hasAlpha: boolean;
  28849. /**
  28850. * Defines if the alpha value should be determined via the rgb values.
  28851. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28852. */
  28853. getAlphaFromRGB: boolean;
  28854. /**
  28855. * Intensity or strength of the texture.
  28856. * It is commonly used by materials to fine tune the intensity of the texture
  28857. */
  28858. level: number;
  28859. /**
  28860. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28861. * This is part of the texture as textures usually maps to one uv set.
  28862. */
  28863. coordinatesIndex: number;
  28864. private _coordinatesMode;
  28865. /**
  28866. * How a texture is mapped.
  28867. *
  28868. * | Value | Type | Description |
  28869. * | ----- | ----------------------------------- | ----------- |
  28870. * | 0 | EXPLICIT_MODE | |
  28871. * | 1 | SPHERICAL_MODE | |
  28872. * | 2 | PLANAR_MODE | |
  28873. * | 3 | CUBIC_MODE | |
  28874. * | 4 | PROJECTION_MODE | |
  28875. * | 5 | SKYBOX_MODE | |
  28876. * | 6 | INVCUBIC_MODE | |
  28877. * | 7 | EQUIRECTANGULAR_MODE | |
  28878. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28879. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28880. */
  28881. coordinatesMode: number;
  28882. /**
  28883. * | Value | Type | Description |
  28884. * | ----- | ------------------ | ----------- |
  28885. * | 0 | CLAMP_ADDRESSMODE | |
  28886. * | 1 | WRAP_ADDRESSMODE | |
  28887. * | 2 | MIRROR_ADDRESSMODE | |
  28888. */
  28889. wrapU: number;
  28890. /**
  28891. * | Value | Type | Description |
  28892. * | ----- | ------------------ | ----------- |
  28893. * | 0 | CLAMP_ADDRESSMODE | |
  28894. * | 1 | WRAP_ADDRESSMODE | |
  28895. * | 2 | MIRROR_ADDRESSMODE | |
  28896. */
  28897. wrapV: number;
  28898. /**
  28899. * | Value | Type | Description |
  28900. * | ----- | ------------------ | ----------- |
  28901. * | 0 | CLAMP_ADDRESSMODE | |
  28902. * | 1 | WRAP_ADDRESSMODE | |
  28903. * | 2 | MIRROR_ADDRESSMODE | |
  28904. */
  28905. wrapR: number;
  28906. /**
  28907. * With compliant hardware and browser (supporting anisotropic filtering)
  28908. * this defines the level of anisotropic filtering in the texture.
  28909. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28910. */
  28911. anisotropicFilteringLevel: number;
  28912. /**
  28913. * Define if the texture is a cube texture or if false a 2d texture.
  28914. */
  28915. isCube: boolean;
  28916. /**
  28917. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28918. */
  28919. is3D: boolean;
  28920. /**
  28921. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  28922. */
  28923. is2DArray: boolean;
  28924. /**
  28925. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28926. * HDR texture are usually stored in linear space.
  28927. * This only impacts the PBR and Background materials
  28928. */
  28929. gammaSpace: boolean;
  28930. /**
  28931. * Gets or sets whether or not the texture contains RGBD data.
  28932. */
  28933. isRGBD: boolean;
  28934. /**
  28935. * Is Z inverted in the texture (useful in a cube texture).
  28936. */
  28937. invertZ: boolean;
  28938. /**
  28939. * Are mip maps generated for this texture or not.
  28940. */
  28941. readonly noMipmap: boolean;
  28942. /**
  28943. * @hidden
  28944. */
  28945. lodLevelInAlpha: boolean;
  28946. /**
  28947. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28948. */
  28949. lodGenerationOffset: number;
  28950. /**
  28951. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28952. */
  28953. lodGenerationScale: number;
  28954. /**
  28955. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28956. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28957. * average roughness values.
  28958. */
  28959. linearSpecularLOD: boolean;
  28960. /**
  28961. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28962. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28963. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28964. */
  28965. irradianceTexture: Nullable<BaseTexture>;
  28966. /**
  28967. * Define if the texture is a render target.
  28968. */
  28969. isRenderTarget: boolean;
  28970. /**
  28971. * Define the unique id of the texture in the scene.
  28972. */
  28973. readonly uid: string;
  28974. /**
  28975. * Return a string representation of the texture.
  28976. * @returns the texture as a string
  28977. */
  28978. toString(): string;
  28979. /**
  28980. * Get the class name of the texture.
  28981. * @returns "BaseTexture"
  28982. */
  28983. getClassName(): string;
  28984. /**
  28985. * Define the list of animation attached to the texture.
  28986. */
  28987. animations: import("babylonjs/Animations/animation").Animation[];
  28988. /**
  28989. * An event triggered when the texture is disposed.
  28990. */
  28991. onDisposeObservable: Observable<BaseTexture>;
  28992. private _onDisposeObserver;
  28993. /**
  28994. * Callback triggered when the texture has been disposed.
  28995. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28996. */
  28997. onDispose: () => void;
  28998. /**
  28999. * Define the current state of the loading sequence when in delayed load mode.
  29000. */
  29001. delayLoadState: number;
  29002. private _scene;
  29003. /** @hidden */
  29004. _texture: Nullable<InternalTexture>;
  29005. private _uid;
  29006. /**
  29007. * Define if the texture is preventinga material to render or not.
  29008. * If not and the texture is not ready, the engine will use a default black texture instead.
  29009. */
  29010. readonly isBlocking: boolean;
  29011. /**
  29012. * Instantiates a new BaseTexture.
  29013. * Base class of all the textures in babylon.
  29014. * It groups all the common properties the materials, post process, lights... might need
  29015. * in order to make a correct use of the texture.
  29016. * @param scene Define the scene the texture blongs to
  29017. */
  29018. constructor(scene: Nullable<Scene>);
  29019. /**
  29020. * Get the scene the texture belongs to.
  29021. * @returns the scene or null if undefined
  29022. */
  29023. getScene(): Nullable<Scene>;
  29024. /**
  29025. * Get the texture transform matrix used to offset tile the texture for istance.
  29026. * @returns the transformation matrix
  29027. */
  29028. getTextureMatrix(): Matrix;
  29029. /**
  29030. * Get the texture reflection matrix used to rotate/transform the reflection.
  29031. * @returns the reflection matrix
  29032. */
  29033. getReflectionTextureMatrix(): Matrix;
  29034. /**
  29035. * Get the underlying lower level texture from Babylon.
  29036. * @returns the insternal texture
  29037. */
  29038. getInternalTexture(): Nullable<InternalTexture>;
  29039. /**
  29040. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29041. * @returns true if ready or not blocking
  29042. */
  29043. isReadyOrNotBlocking(): boolean;
  29044. /**
  29045. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29046. * @returns true if fully ready
  29047. */
  29048. isReady(): boolean;
  29049. private _cachedSize;
  29050. /**
  29051. * Get the size of the texture.
  29052. * @returns the texture size.
  29053. */
  29054. getSize(): ISize;
  29055. /**
  29056. * Get the base size of the texture.
  29057. * It can be different from the size if the texture has been resized for POT for instance
  29058. * @returns the base size
  29059. */
  29060. getBaseSize(): ISize;
  29061. /**
  29062. * Update the sampling mode of the texture.
  29063. * Default is Trilinear mode.
  29064. *
  29065. * | Value | Type | Description |
  29066. * | ----- | ------------------ | ----------- |
  29067. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29068. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29069. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29070. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29071. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29072. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29073. * | 7 | NEAREST_LINEAR | |
  29074. * | 8 | NEAREST_NEAREST | |
  29075. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29076. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29077. * | 11 | LINEAR_LINEAR | |
  29078. * | 12 | LINEAR_NEAREST | |
  29079. *
  29080. * > _mag_: magnification filter (close to the viewer)
  29081. * > _min_: minification filter (far from the viewer)
  29082. * > _mip_: filter used between mip map levels
  29083. *@param samplingMode Define the new sampling mode of the texture
  29084. */
  29085. updateSamplingMode(samplingMode: number): void;
  29086. /**
  29087. * Scales the texture if is `canRescale()`
  29088. * @param ratio the resize factor we want to use to rescale
  29089. */
  29090. scale(ratio: number): void;
  29091. /**
  29092. * Get if the texture can rescale.
  29093. */
  29094. readonly canRescale: boolean;
  29095. /** @hidden */
  29096. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29097. /** @hidden */
  29098. _rebuild(): void;
  29099. /**
  29100. * Triggers the load sequence in delayed load mode.
  29101. */
  29102. delayLoad(): void;
  29103. /**
  29104. * Clones the texture.
  29105. * @returns the cloned texture
  29106. */
  29107. clone(): Nullable<BaseTexture>;
  29108. /**
  29109. * Get the texture underlying type (INT, FLOAT...)
  29110. */
  29111. readonly textureType: number;
  29112. /**
  29113. * Get the texture underlying format (RGB, RGBA...)
  29114. */
  29115. readonly textureFormat: number;
  29116. /**
  29117. * Indicates that textures need to be re-calculated for all materials
  29118. */
  29119. protected _markAllSubMeshesAsTexturesDirty(): void;
  29120. /**
  29121. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29122. * This will returns an RGBA array buffer containing either in values (0-255) or
  29123. * float values (0-1) depending of the underlying buffer type.
  29124. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29125. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29126. * @param buffer defines a user defined buffer to fill with data (can be null)
  29127. * @returns The Array buffer containing the pixels data.
  29128. */
  29129. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29130. /**
  29131. * Release and destroy the underlying lower level texture aka internalTexture.
  29132. */
  29133. releaseInternalTexture(): void;
  29134. /** @hidden */
  29135. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29136. /** @hidden */
  29137. readonly _lodTextureMid: Nullable<BaseTexture>;
  29138. /** @hidden */
  29139. readonly _lodTextureLow: Nullable<BaseTexture>;
  29140. /**
  29141. * Dispose the texture and release its associated resources.
  29142. */
  29143. dispose(): void;
  29144. /**
  29145. * Serialize the texture into a JSON representation that can be parsed later on.
  29146. * @returns the JSON representation of the texture
  29147. */
  29148. serialize(): any;
  29149. /**
  29150. * Helper function to be called back once a list of texture contains only ready textures.
  29151. * @param textures Define the list of textures to wait for
  29152. * @param callback Define the callback triggered once the entire list will be ready
  29153. */
  29154. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29155. }
  29156. }
  29157. declare module "babylonjs/Materials/effect" {
  29158. import { Observable } from "babylonjs/Misc/observable";
  29159. import { Nullable } from "babylonjs/types";
  29160. import { IDisposable } from "babylonjs/scene";
  29161. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29162. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29163. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29164. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29165. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29166. import { Engine } from "babylonjs/Engines/engine";
  29167. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29169. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29170. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29171. /**
  29172. * Options to be used when creating an effect.
  29173. */
  29174. export interface IEffectCreationOptions {
  29175. /**
  29176. * Atrributes that will be used in the shader.
  29177. */
  29178. attributes: string[];
  29179. /**
  29180. * Uniform varible names that will be set in the shader.
  29181. */
  29182. uniformsNames: string[];
  29183. /**
  29184. * Uniform buffer varible names that will be set in the shader.
  29185. */
  29186. uniformBuffersNames: string[];
  29187. /**
  29188. * Sampler texture variable names that will be set in the shader.
  29189. */
  29190. samplers: string[];
  29191. /**
  29192. * Define statements that will be set in the shader.
  29193. */
  29194. defines: any;
  29195. /**
  29196. * Possible fallbacks for this effect to improve performance when needed.
  29197. */
  29198. fallbacks: Nullable<IEffectFallbacks>;
  29199. /**
  29200. * Callback that will be called when the shader is compiled.
  29201. */
  29202. onCompiled: Nullable<(effect: Effect) => void>;
  29203. /**
  29204. * Callback that will be called if an error occurs during shader compilation.
  29205. */
  29206. onError: Nullable<(effect: Effect, errors: string) => void>;
  29207. /**
  29208. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29209. */
  29210. indexParameters?: any;
  29211. /**
  29212. * Max number of lights that can be used in the shader.
  29213. */
  29214. maxSimultaneousLights?: number;
  29215. /**
  29216. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29217. */
  29218. transformFeedbackVaryings?: Nullable<string[]>;
  29219. }
  29220. /**
  29221. * Effect containing vertex and fragment shader that can be executed on an object.
  29222. */
  29223. export class Effect implements IDisposable {
  29224. /**
  29225. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29226. */
  29227. static ShadersRepository: string;
  29228. /**
  29229. * Name of the effect.
  29230. */
  29231. name: any;
  29232. /**
  29233. * String container all the define statements that should be set on the shader.
  29234. */
  29235. defines: string;
  29236. /**
  29237. * Callback that will be called when the shader is compiled.
  29238. */
  29239. onCompiled: Nullable<(effect: Effect) => void>;
  29240. /**
  29241. * Callback that will be called if an error occurs during shader compilation.
  29242. */
  29243. onError: Nullable<(effect: Effect, errors: string) => void>;
  29244. /**
  29245. * Callback that will be called when effect is bound.
  29246. */
  29247. onBind: Nullable<(effect: Effect) => void>;
  29248. /**
  29249. * Unique ID of the effect.
  29250. */
  29251. uniqueId: number;
  29252. /**
  29253. * Observable that will be called when the shader is compiled.
  29254. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29255. */
  29256. onCompileObservable: Observable<Effect>;
  29257. /**
  29258. * Observable that will be called if an error occurs during shader compilation.
  29259. */
  29260. onErrorObservable: Observable<Effect>;
  29261. /** @hidden */
  29262. _onBindObservable: Nullable<Observable<Effect>>;
  29263. /**
  29264. * Observable that will be called when effect is bound.
  29265. */
  29266. readonly onBindObservable: Observable<Effect>;
  29267. /** @hidden */
  29268. _bonesComputationForcedToCPU: boolean;
  29269. private static _uniqueIdSeed;
  29270. private _engine;
  29271. private _uniformBuffersNames;
  29272. private _uniformsNames;
  29273. private _samplerList;
  29274. private _samplers;
  29275. private _isReady;
  29276. private _compilationError;
  29277. private _allFallbacksProcessed;
  29278. private _attributesNames;
  29279. private _attributes;
  29280. private _uniforms;
  29281. /**
  29282. * Key for the effect.
  29283. * @hidden
  29284. */
  29285. _key: string;
  29286. private _indexParameters;
  29287. private _fallbacks;
  29288. private _vertexSourceCode;
  29289. private _fragmentSourceCode;
  29290. private _vertexSourceCodeOverride;
  29291. private _fragmentSourceCodeOverride;
  29292. private _transformFeedbackVaryings;
  29293. /**
  29294. * Compiled shader to webGL program.
  29295. * @hidden
  29296. */
  29297. _pipelineContext: Nullable<IPipelineContext>;
  29298. private _valueCache;
  29299. private static _baseCache;
  29300. /**
  29301. * Instantiates an effect.
  29302. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29303. * @param baseName Name of the effect.
  29304. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29305. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29306. * @param samplers List of sampler variables that will be passed to the shader.
  29307. * @param engine Engine to be used to render the effect
  29308. * @param defines Define statements to be added to the shader.
  29309. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29310. * @param onCompiled Callback that will be called when the shader is compiled.
  29311. * @param onError Callback that will be called if an error occurs during shader compilation.
  29312. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29313. */
  29314. 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);
  29315. private _useFinalCode;
  29316. /**
  29317. * Unique key for this effect
  29318. */
  29319. readonly key: string;
  29320. /**
  29321. * If the effect has been compiled and prepared.
  29322. * @returns if the effect is compiled and prepared.
  29323. */
  29324. isReady(): boolean;
  29325. private _isReadyInternal;
  29326. /**
  29327. * The engine the effect was initialized with.
  29328. * @returns the engine.
  29329. */
  29330. getEngine(): Engine;
  29331. /**
  29332. * The pipeline context for this effect
  29333. * @returns the associated pipeline context
  29334. */
  29335. getPipelineContext(): Nullable<IPipelineContext>;
  29336. /**
  29337. * The set of names of attribute variables for the shader.
  29338. * @returns An array of attribute names.
  29339. */
  29340. getAttributesNames(): string[];
  29341. /**
  29342. * Returns the attribute at the given index.
  29343. * @param index The index of the attribute.
  29344. * @returns The location of the attribute.
  29345. */
  29346. getAttributeLocation(index: number): number;
  29347. /**
  29348. * Returns the attribute based on the name of the variable.
  29349. * @param name of the attribute to look up.
  29350. * @returns the attribute location.
  29351. */
  29352. getAttributeLocationByName(name: string): number;
  29353. /**
  29354. * The number of attributes.
  29355. * @returns the numnber of attributes.
  29356. */
  29357. getAttributesCount(): number;
  29358. /**
  29359. * Gets the index of a uniform variable.
  29360. * @param uniformName of the uniform to look up.
  29361. * @returns the index.
  29362. */
  29363. getUniformIndex(uniformName: string): number;
  29364. /**
  29365. * Returns the attribute based on the name of the variable.
  29366. * @param uniformName of the uniform to look up.
  29367. * @returns the location of the uniform.
  29368. */
  29369. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29370. /**
  29371. * Returns an array of sampler variable names
  29372. * @returns The array of sampler variable neames.
  29373. */
  29374. getSamplers(): string[];
  29375. /**
  29376. * The error from the last compilation.
  29377. * @returns the error string.
  29378. */
  29379. getCompilationError(): string;
  29380. /**
  29381. * Gets a boolean indicating that all fallbacks were used during compilation
  29382. * @returns true if all fallbacks were used
  29383. */
  29384. allFallbacksProcessed(): boolean;
  29385. /**
  29386. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29387. * @param func The callback to be used.
  29388. */
  29389. executeWhenCompiled(func: (effect: Effect) => void): void;
  29390. private _checkIsReady;
  29391. private _loadShader;
  29392. /**
  29393. * Recompiles the webGL program
  29394. * @param vertexSourceCode The source code for the vertex shader.
  29395. * @param fragmentSourceCode The source code for the fragment shader.
  29396. * @param onCompiled Callback called when completed.
  29397. * @param onError Callback called on error.
  29398. * @hidden
  29399. */
  29400. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29401. /**
  29402. * Prepares the effect
  29403. * @hidden
  29404. */
  29405. _prepareEffect(): void;
  29406. private _processCompilationErrors;
  29407. /**
  29408. * Checks if the effect is supported. (Must be called after compilation)
  29409. */
  29410. readonly isSupported: boolean;
  29411. /**
  29412. * Binds a texture to the engine to be used as output of the shader.
  29413. * @param channel Name of the output variable.
  29414. * @param texture Texture to bind.
  29415. * @hidden
  29416. */
  29417. _bindTexture(channel: string, texture: InternalTexture): void;
  29418. /**
  29419. * Sets a texture on the engine to be used in the shader.
  29420. * @param channel Name of the sampler variable.
  29421. * @param texture Texture to set.
  29422. */
  29423. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29424. /**
  29425. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29426. * @param channel Name of the sampler variable.
  29427. * @param texture Texture to set.
  29428. */
  29429. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29430. /**
  29431. * Sets an array of textures on the engine to be used in the shader.
  29432. * @param channel Name of the variable.
  29433. * @param textures Textures to set.
  29434. */
  29435. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29436. /**
  29437. * 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)
  29438. * @param channel Name of the sampler variable.
  29439. * @param postProcess Post process to get the input texture from.
  29440. */
  29441. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29442. /**
  29443. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29444. * 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)
  29445. * @param channel Name of the sampler variable.
  29446. * @param postProcess Post process to get the output texture from.
  29447. */
  29448. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29449. /** @hidden */
  29450. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29451. /** @hidden */
  29452. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29453. /** @hidden */
  29454. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29455. /** @hidden */
  29456. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29457. /**
  29458. * Binds a buffer to a uniform.
  29459. * @param buffer Buffer to bind.
  29460. * @param name Name of the uniform variable to bind to.
  29461. */
  29462. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29463. /**
  29464. * Binds block to a uniform.
  29465. * @param blockName Name of the block to bind.
  29466. * @param index Index to bind.
  29467. */
  29468. bindUniformBlock(blockName: string, index: number): void;
  29469. /**
  29470. * Sets an interger value on a uniform variable.
  29471. * @param uniformName Name of the variable.
  29472. * @param value Value to be set.
  29473. * @returns this effect.
  29474. */
  29475. setInt(uniformName: string, value: number): Effect;
  29476. /**
  29477. * Sets an int array on a uniform variable.
  29478. * @param uniformName Name of the variable.
  29479. * @param array array to be set.
  29480. * @returns this effect.
  29481. */
  29482. setIntArray(uniformName: string, array: Int32Array): Effect;
  29483. /**
  29484. * 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)
  29485. * @param uniformName Name of the variable.
  29486. * @param array array to be set.
  29487. * @returns this effect.
  29488. */
  29489. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29490. /**
  29491. * 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)
  29492. * @param uniformName Name of the variable.
  29493. * @param array array to be set.
  29494. * @returns this effect.
  29495. */
  29496. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29497. /**
  29498. * 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)
  29499. * @param uniformName Name of the variable.
  29500. * @param array array to be set.
  29501. * @returns this effect.
  29502. */
  29503. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29504. /**
  29505. * Sets an float array on a uniform variable.
  29506. * @param uniformName Name of the variable.
  29507. * @param array array to be set.
  29508. * @returns this effect.
  29509. */
  29510. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29511. /**
  29512. * 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)
  29513. * @param uniformName Name of the variable.
  29514. * @param array array to be set.
  29515. * @returns this effect.
  29516. */
  29517. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29518. /**
  29519. * 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)
  29520. * @param uniformName Name of the variable.
  29521. * @param array array to be set.
  29522. * @returns this effect.
  29523. */
  29524. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29525. /**
  29526. * 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)
  29527. * @param uniformName Name of the variable.
  29528. * @param array array to be set.
  29529. * @returns this effect.
  29530. */
  29531. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29532. /**
  29533. * Sets an array on a uniform variable.
  29534. * @param uniformName Name of the variable.
  29535. * @param array array to be set.
  29536. * @returns this effect.
  29537. */
  29538. setArray(uniformName: string, array: number[]): Effect;
  29539. /**
  29540. * 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)
  29541. * @param uniformName Name of the variable.
  29542. * @param array array to be set.
  29543. * @returns this effect.
  29544. */
  29545. setArray2(uniformName: string, array: number[]): Effect;
  29546. /**
  29547. * 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)
  29548. * @param uniformName Name of the variable.
  29549. * @param array array to be set.
  29550. * @returns this effect.
  29551. */
  29552. setArray3(uniformName: string, array: number[]): Effect;
  29553. /**
  29554. * 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)
  29555. * @param uniformName Name of the variable.
  29556. * @param array array to be set.
  29557. * @returns this effect.
  29558. */
  29559. setArray4(uniformName: string, array: number[]): Effect;
  29560. /**
  29561. * Sets matrices on a uniform variable.
  29562. * @param uniformName Name of the variable.
  29563. * @param matrices matrices to be set.
  29564. * @returns this effect.
  29565. */
  29566. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29567. /**
  29568. * Sets matrix on a uniform variable.
  29569. * @param uniformName Name of the variable.
  29570. * @param matrix matrix to be set.
  29571. * @returns this effect.
  29572. */
  29573. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29574. /**
  29575. * 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)
  29576. * @param uniformName Name of the variable.
  29577. * @param matrix matrix to be set.
  29578. * @returns this effect.
  29579. */
  29580. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29581. /**
  29582. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29583. * @param uniformName Name of the variable.
  29584. * @param matrix matrix to be set.
  29585. * @returns this effect.
  29586. */
  29587. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29588. /**
  29589. * Sets a float on a uniform variable.
  29590. * @param uniformName Name of the variable.
  29591. * @param value value to be set.
  29592. * @returns this effect.
  29593. */
  29594. setFloat(uniformName: string, value: number): Effect;
  29595. /**
  29596. * Sets a boolean on a uniform variable.
  29597. * @param uniformName Name of the variable.
  29598. * @param bool value to be set.
  29599. * @returns this effect.
  29600. */
  29601. setBool(uniformName: string, bool: boolean): Effect;
  29602. /**
  29603. * Sets a Vector2 on a uniform variable.
  29604. * @param uniformName Name of the variable.
  29605. * @param vector2 vector2 to be set.
  29606. * @returns this effect.
  29607. */
  29608. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29609. /**
  29610. * Sets a float2 on a uniform variable.
  29611. * @param uniformName Name of the variable.
  29612. * @param x First float in float2.
  29613. * @param y Second float in float2.
  29614. * @returns this effect.
  29615. */
  29616. setFloat2(uniformName: string, x: number, y: number): Effect;
  29617. /**
  29618. * Sets a Vector3 on a uniform variable.
  29619. * @param uniformName Name of the variable.
  29620. * @param vector3 Value to be set.
  29621. * @returns this effect.
  29622. */
  29623. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29624. /**
  29625. * Sets a float3 on a uniform variable.
  29626. * @param uniformName Name of the variable.
  29627. * @param x First float in float3.
  29628. * @param y Second float in float3.
  29629. * @param z Third float in float3.
  29630. * @returns this effect.
  29631. */
  29632. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29633. /**
  29634. * Sets a Vector4 on a uniform variable.
  29635. * @param uniformName Name of the variable.
  29636. * @param vector4 Value to be set.
  29637. * @returns this effect.
  29638. */
  29639. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29640. /**
  29641. * Sets a float4 on a uniform variable.
  29642. * @param uniformName Name of the variable.
  29643. * @param x First float in float4.
  29644. * @param y Second float in float4.
  29645. * @param z Third float in float4.
  29646. * @param w Fourth float in float4.
  29647. * @returns this effect.
  29648. */
  29649. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29650. /**
  29651. * Sets a Color3 on a uniform variable.
  29652. * @param uniformName Name of the variable.
  29653. * @param color3 Value to be set.
  29654. * @returns this effect.
  29655. */
  29656. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29657. /**
  29658. * Sets a Color4 on a uniform variable.
  29659. * @param uniformName Name of the variable.
  29660. * @param color3 Value to be set.
  29661. * @param alpha Alpha value to be set.
  29662. * @returns this effect.
  29663. */
  29664. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29665. /**
  29666. * Sets a Color4 on a uniform variable
  29667. * @param uniformName defines the name of the variable
  29668. * @param color4 defines the value to be set
  29669. * @returns this effect.
  29670. */
  29671. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29672. /** Release all associated resources */
  29673. dispose(): void;
  29674. /**
  29675. * This function will add a new shader to the shader store
  29676. * @param name the name of the shader
  29677. * @param pixelShader optional pixel shader content
  29678. * @param vertexShader optional vertex shader content
  29679. */
  29680. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29681. /**
  29682. * Store of each shader (The can be looked up using effect.key)
  29683. */
  29684. static ShadersStore: {
  29685. [key: string]: string;
  29686. };
  29687. /**
  29688. * Store of each included file for a shader (The can be looked up using effect.key)
  29689. */
  29690. static IncludesShadersStore: {
  29691. [key: string]: string;
  29692. };
  29693. /**
  29694. * Resets the cache of effects.
  29695. */
  29696. static ResetCache(): void;
  29697. }
  29698. }
  29699. declare module "babylonjs/Engines/engineCapabilities" {
  29700. /**
  29701. * Interface used to describe the capabilities of the engine relatively to the current browser
  29702. */
  29703. export interface EngineCapabilities {
  29704. /** Maximum textures units per fragment shader */
  29705. maxTexturesImageUnits: number;
  29706. /** Maximum texture units per vertex shader */
  29707. maxVertexTextureImageUnits: number;
  29708. /** Maximum textures units in the entire pipeline */
  29709. maxCombinedTexturesImageUnits: number;
  29710. /** Maximum texture size */
  29711. maxTextureSize: number;
  29712. /** Maximum cube texture size */
  29713. maxCubemapTextureSize: number;
  29714. /** Maximum render texture size */
  29715. maxRenderTextureSize: number;
  29716. /** Maximum number of vertex attributes */
  29717. maxVertexAttribs: number;
  29718. /** Maximum number of varyings */
  29719. maxVaryingVectors: number;
  29720. /** Maximum number of uniforms per vertex shader */
  29721. maxVertexUniformVectors: number;
  29722. /** Maximum number of uniforms per fragment shader */
  29723. maxFragmentUniformVectors: number;
  29724. /** Defines if standard derivates (dx/dy) are supported */
  29725. standardDerivatives: boolean;
  29726. /** Defines if s3tc texture compression is supported */
  29727. s3tc?: WEBGL_compressed_texture_s3tc;
  29728. /** Defines if pvrtc texture compression is supported */
  29729. pvrtc: any;
  29730. /** Defines if etc1 texture compression is supported */
  29731. etc1: any;
  29732. /** Defines if etc2 texture compression is supported */
  29733. etc2: any;
  29734. /** Defines if astc texture compression is supported */
  29735. astc: any;
  29736. /** Defines if float textures are supported */
  29737. textureFloat: boolean;
  29738. /** Defines if vertex array objects are supported */
  29739. vertexArrayObject: boolean;
  29740. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29741. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29742. /** Gets the maximum level of anisotropy supported */
  29743. maxAnisotropy: number;
  29744. /** Defines if instancing is supported */
  29745. instancedArrays: boolean;
  29746. /** Defines if 32 bits indices are supported */
  29747. uintIndices: boolean;
  29748. /** Defines if high precision shaders are supported */
  29749. highPrecisionShaderSupported: boolean;
  29750. /** Defines if depth reading in the fragment shader is supported */
  29751. fragmentDepthSupported: boolean;
  29752. /** Defines if float texture linear filtering is supported*/
  29753. textureFloatLinearFiltering: boolean;
  29754. /** Defines if rendering to float textures is supported */
  29755. textureFloatRender: boolean;
  29756. /** Defines if half float textures are supported*/
  29757. textureHalfFloat: boolean;
  29758. /** Defines if half float texture linear filtering is supported*/
  29759. textureHalfFloatLinearFiltering: boolean;
  29760. /** Defines if rendering to half float textures is supported */
  29761. textureHalfFloatRender: boolean;
  29762. /** Defines if textureLOD shader command is supported */
  29763. textureLOD: boolean;
  29764. /** Defines if draw buffers extension is supported */
  29765. drawBuffersExtension: boolean;
  29766. /** Defines if depth textures are supported */
  29767. depthTextureExtension: boolean;
  29768. /** Defines if float color buffer are supported */
  29769. colorBufferFloat: boolean;
  29770. /** Gets disjoint timer query extension (null if not supported) */
  29771. timerQuery?: EXT_disjoint_timer_query;
  29772. /** Defines if timestamp can be used with timer query */
  29773. canUseTimestampForTimerQuery: boolean;
  29774. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29775. multiview?: any;
  29776. /** Function used to let the system compiles shaders in background */
  29777. parallelShaderCompile?: {
  29778. COMPLETION_STATUS_KHR: number;
  29779. };
  29780. /** Max number of texture samples for MSAA */
  29781. maxMSAASamples: number;
  29782. /** Defines if the blend min max extension is supported */
  29783. blendMinMax: boolean;
  29784. }
  29785. }
  29786. declare module "babylonjs/States/depthCullingState" {
  29787. import { Nullable } from "babylonjs/types";
  29788. /**
  29789. * @hidden
  29790. **/
  29791. export class DepthCullingState {
  29792. private _isDepthTestDirty;
  29793. private _isDepthMaskDirty;
  29794. private _isDepthFuncDirty;
  29795. private _isCullFaceDirty;
  29796. private _isCullDirty;
  29797. private _isZOffsetDirty;
  29798. private _isFrontFaceDirty;
  29799. private _depthTest;
  29800. private _depthMask;
  29801. private _depthFunc;
  29802. private _cull;
  29803. private _cullFace;
  29804. private _zOffset;
  29805. private _frontFace;
  29806. /**
  29807. * Initializes the state.
  29808. */
  29809. constructor();
  29810. readonly isDirty: boolean;
  29811. zOffset: number;
  29812. cullFace: Nullable<number>;
  29813. cull: Nullable<boolean>;
  29814. depthFunc: Nullable<number>;
  29815. depthMask: boolean;
  29816. depthTest: boolean;
  29817. frontFace: Nullable<number>;
  29818. reset(): void;
  29819. apply(gl: WebGLRenderingContext): void;
  29820. }
  29821. }
  29822. declare module "babylonjs/States/stencilState" {
  29823. /**
  29824. * @hidden
  29825. **/
  29826. export class StencilState {
  29827. /** 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 */
  29828. static readonly ALWAYS: number;
  29829. /** Passed to stencilOperation to specify that stencil value must be kept */
  29830. static readonly KEEP: number;
  29831. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29832. static readonly REPLACE: number;
  29833. private _isStencilTestDirty;
  29834. private _isStencilMaskDirty;
  29835. private _isStencilFuncDirty;
  29836. private _isStencilOpDirty;
  29837. private _stencilTest;
  29838. private _stencilMask;
  29839. private _stencilFunc;
  29840. private _stencilFuncRef;
  29841. private _stencilFuncMask;
  29842. private _stencilOpStencilFail;
  29843. private _stencilOpDepthFail;
  29844. private _stencilOpStencilDepthPass;
  29845. readonly isDirty: boolean;
  29846. stencilFunc: number;
  29847. stencilFuncRef: number;
  29848. stencilFuncMask: number;
  29849. stencilOpStencilFail: number;
  29850. stencilOpDepthFail: number;
  29851. stencilOpStencilDepthPass: number;
  29852. stencilMask: number;
  29853. stencilTest: boolean;
  29854. constructor();
  29855. reset(): void;
  29856. apply(gl: WebGLRenderingContext): void;
  29857. }
  29858. }
  29859. declare module "babylonjs/States/alphaCullingState" {
  29860. /**
  29861. * @hidden
  29862. **/
  29863. export class AlphaState {
  29864. private _isAlphaBlendDirty;
  29865. private _isBlendFunctionParametersDirty;
  29866. private _isBlendEquationParametersDirty;
  29867. private _isBlendConstantsDirty;
  29868. private _alphaBlend;
  29869. private _blendFunctionParameters;
  29870. private _blendEquationParameters;
  29871. private _blendConstants;
  29872. /**
  29873. * Initializes the state.
  29874. */
  29875. constructor();
  29876. readonly isDirty: boolean;
  29877. alphaBlend: boolean;
  29878. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29879. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29880. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29881. reset(): void;
  29882. apply(gl: WebGLRenderingContext): void;
  29883. }
  29884. }
  29885. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29886. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29887. /** @hidden */
  29888. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29889. attributeProcessor(attribute: string): string;
  29890. varyingProcessor(varying: string, isFragment: boolean): string;
  29891. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29892. }
  29893. }
  29894. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29895. /**
  29896. * Interface for attribute information associated with buffer instanciation
  29897. */
  29898. export interface InstancingAttributeInfo {
  29899. /**
  29900. * Index/offset of the attribute in the vertex shader
  29901. */
  29902. index: number;
  29903. /**
  29904. * size of the attribute, 1, 2, 3 or 4
  29905. */
  29906. attributeSize: number;
  29907. /**
  29908. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29909. * default is FLOAT
  29910. */
  29911. attributeType: number;
  29912. /**
  29913. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29914. */
  29915. normalized: boolean;
  29916. /**
  29917. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29918. */
  29919. offset: number;
  29920. /**
  29921. * Name of the GLSL attribute, for debugging purpose only
  29922. */
  29923. attributeName: string;
  29924. }
  29925. }
  29926. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29928. import { Nullable } from "babylonjs/types";
  29929. module "babylonjs/Engines/thinEngine" {
  29930. interface ThinEngine {
  29931. /**
  29932. * Update a video texture
  29933. * @param texture defines the texture to update
  29934. * @param video defines the video element to use
  29935. * @param invertY defines if data must be stored with Y axis inverted
  29936. */
  29937. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29938. }
  29939. }
  29940. }
  29941. declare module "babylonjs/Materials/Textures/videoTexture" {
  29942. import { Observable } from "babylonjs/Misc/observable";
  29943. import { Nullable } from "babylonjs/types";
  29944. import { Scene } from "babylonjs/scene";
  29945. import { Texture } from "babylonjs/Materials/Textures/texture";
  29946. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29947. /**
  29948. * Settings for finer control over video usage
  29949. */
  29950. export interface VideoTextureSettings {
  29951. /**
  29952. * Applies `autoplay` to video, if specified
  29953. */
  29954. autoPlay?: boolean;
  29955. /**
  29956. * Applies `loop` to video, if specified
  29957. */
  29958. loop?: boolean;
  29959. /**
  29960. * Automatically updates internal texture from video at every frame in the render loop
  29961. */
  29962. autoUpdateTexture: boolean;
  29963. /**
  29964. * Image src displayed during the video loading or until the user interacts with the video.
  29965. */
  29966. poster?: string;
  29967. }
  29968. /**
  29969. * If you want to display a video in your scene, this is the special texture for that.
  29970. * This special texture works similar to other textures, with the exception of a few parameters.
  29971. * @see https://doc.babylonjs.com/how_to/video_texture
  29972. */
  29973. export class VideoTexture extends Texture {
  29974. /**
  29975. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29976. */
  29977. readonly autoUpdateTexture: boolean;
  29978. /**
  29979. * The video instance used by the texture internally
  29980. */
  29981. readonly video: HTMLVideoElement;
  29982. private _onUserActionRequestedObservable;
  29983. /**
  29984. * Event triggerd when a dom action is required by the user to play the video.
  29985. * This happens due to recent changes in browser policies preventing video to auto start.
  29986. */
  29987. readonly onUserActionRequestedObservable: Observable<Texture>;
  29988. private _generateMipMaps;
  29989. private _engine;
  29990. private _stillImageCaptured;
  29991. private _displayingPosterTexture;
  29992. private _settings;
  29993. private _createInternalTextureOnEvent;
  29994. private _frameId;
  29995. /**
  29996. * Creates a video texture.
  29997. * If you want to display a video in your scene, this is the special texture for that.
  29998. * This special texture works similar to other textures, with the exception of a few parameters.
  29999. * @see https://doc.babylonjs.com/how_to/video_texture
  30000. * @param name optional name, will detect from video source, if not defined
  30001. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30002. * @param scene is obviously the current scene.
  30003. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30004. * @param invertY is false by default but can be used to invert video on Y axis
  30005. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30006. * @param settings allows finer control over video usage
  30007. */
  30008. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30009. private _getName;
  30010. private _getVideo;
  30011. private _createInternalTexture;
  30012. private reset;
  30013. /**
  30014. * @hidden Internal method to initiate `update`.
  30015. */
  30016. _rebuild(): void;
  30017. /**
  30018. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30019. */
  30020. update(): void;
  30021. /**
  30022. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30023. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30024. */
  30025. updateTexture(isVisible: boolean): void;
  30026. protected _updateInternalTexture: () => void;
  30027. /**
  30028. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30029. * @param url New url.
  30030. */
  30031. updateURL(url: string): void;
  30032. /**
  30033. * Dispose the texture and release its associated resources.
  30034. */
  30035. dispose(): void;
  30036. /**
  30037. * Creates a video texture straight from a stream.
  30038. * @param scene Define the scene the texture should be created in
  30039. * @param stream Define the stream the texture should be created from
  30040. * @returns The created video texture as a promise
  30041. */
  30042. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30043. /**
  30044. * Creates a video texture straight from your WebCam video feed.
  30045. * @param scene Define the scene the texture should be created in
  30046. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30047. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30048. * @returns The created video texture as a promise
  30049. */
  30050. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30051. minWidth: number;
  30052. maxWidth: number;
  30053. minHeight: number;
  30054. maxHeight: number;
  30055. deviceId: string;
  30056. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30057. /**
  30058. * Creates a video texture straight from your WebCam video feed.
  30059. * @param scene Define the scene the texture should be created in
  30060. * @param onReady Define a callback to triggered once the texture will be ready
  30061. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30062. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30063. */
  30064. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30065. minWidth: number;
  30066. maxWidth: number;
  30067. minHeight: number;
  30068. maxHeight: number;
  30069. deviceId: string;
  30070. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30071. }
  30072. }
  30073. declare module "babylonjs/Engines/thinEngine" {
  30074. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30075. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30076. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30077. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30078. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30079. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30080. import { Observable } from "babylonjs/Misc/observable";
  30081. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30082. import { StencilState } from "babylonjs/States/stencilState";
  30083. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30085. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30086. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30087. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30088. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30089. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30090. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30091. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30093. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30094. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30095. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30096. /**
  30097. * Defines the interface used by objects working like Scene
  30098. * @hidden
  30099. */
  30100. interface ISceneLike {
  30101. _addPendingData(data: any): void;
  30102. _removePendingData(data: any): void;
  30103. offlineProvider: IOfflineProvider;
  30104. }
  30105. /** Interface defining initialization parameters for Engine class */
  30106. export interface EngineOptions extends WebGLContextAttributes {
  30107. /**
  30108. * Defines if the engine should no exceed a specified device ratio
  30109. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30110. */
  30111. limitDeviceRatio?: number;
  30112. /**
  30113. * Defines if webvr should be enabled automatically
  30114. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30115. */
  30116. autoEnableWebVR?: boolean;
  30117. /**
  30118. * Defines if webgl2 should be turned off even if supported
  30119. * @see http://doc.babylonjs.com/features/webgl2
  30120. */
  30121. disableWebGL2Support?: boolean;
  30122. /**
  30123. * Defines if webaudio should be initialized as well
  30124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30125. */
  30126. audioEngine?: boolean;
  30127. /**
  30128. * Defines if animations should run using a deterministic lock step
  30129. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30130. */
  30131. deterministicLockstep?: boolean;
  30132. /** Defines the maximum steps to use with deterministic lock step mode */
  30133. lockstepMaxSteps?: number;
  30134. /**
  30135. * Defines that engine should ignore context lost events
  30136. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30137. */
  30138. doNotHandleContextLost?: boolean;
  30139. /**
  30140. * Defines that engine should ignore modifying touch action attribute and style
  30141. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30142. */
  30143. doNotHandleTouchAction?: boolean;
  30144. /**
  30145. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30146. */
  30147. useHighPrecisionFloats?: boolean;
  30148. }
  30149. /**
  30150. * The base engine class (root of all engines)
  30151. */
  30152. export class ThinEngine {
  30153. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30154. static ExceptionList: ({
  30155. key: string;
  30156. capture: string;
  30157. captureConstraint: number;
  30158. targets: string[];
  30159. } | {
  30160. key: string;
  30161. capture: null;
  30162. captureConstraint: null;
  30163. targets: string[];
  30164. })[];
  30165. /** @hidden */
  30166. static _TextureLoaders: IInternalTextureLoader[];
  30167. /**
  30168. * Returns the current npm package of the sdk
  30169. */
  30170. static readonly NpmPackage: string;
  30171. /**
  30172. * Returns the current version of the framework
  30173. */
  30174. static readonly Version: string;
  30175. /**
  30176. * Returns a string describing the current engine
  30177. */
  30178. readonly description: string;
  30179. /**
  30180. * Gets or sets the epsilon value used by collision engine
  30181. */
  30182. static CollisionsEpsilon: number;
  30183. /**
  30184. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30185. */
  30186. static ShadersRepository: string;
  30187. /** @hidden */
  30188. _shaderProcessor: IShaderProcessor;
  30189. /**
  30190. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30191. */
  30192. forcePOTTextures: boolean;
  30193. /**
  30194. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30195. */
  30196. isFullscreen: boolean;
  30197. /**
  30198. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30199. */
  30200. cullBackFaces: boolean;
  30201. /**
  30202. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30203. */
  30204. renderEvenInBackground: boolean;
  30205. /**
  30206. * Gets or sets a boolean indicating that cache can be kept between frames
  30207. */
  30208. preventCacheWipeBetweenFrames: boolean;
  30209. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30210. validateShaderPrograms: boolean;
  30211. /**
  30212. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30213. */
  30214. disableUniformBuffers: boolean;
  30215. /** @hidden */
  30216. _uniformBuffers: UniformBuffer[];
  30217. /**
  30218. * Gets a boolean indicating that the engine supports uniform buffers
  30219. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30220. */
  30221. readonly supportsUniformBuffers: boolean;
  30222. /** @hidden */
  30223. _gl: WebGLRenderingContext;
  30224. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30225. protected _windowIsBackground: boolean;
  30226. protected _webGLVersion: number;
  30227. protected _creationOptions: EngineOptions;
  30228. protected _highPrecisionShadersAllowed: boolean;
  30229. /** @hidden */
  30230. readonly _shouldUseHighPrecisionShader: boolean;
  30231. /**
  30232. * Gets a boolean indicating that only power of 2 textures are supported
  30233. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30234. */
  30235. readonly needPOTTextures: boolean;
  30236. /** @hidden */
  30237. _badOS: boolean;
  30238. /** @hidden */
  30239. _badDesktopOS: boolean;
  30240. private _hardwareScalingLevel;
  30241. /** @hidden */
  30242. _caps: EngineCapabilities;
  30243. private _isStencilEnable;
  30244. protected _colorWrite: boolean;
  30245. private _glVersion;
  30246. private _glRenderer;
  30247. private _glVendor;
  30248. /** @hidden */
  30249. _videoTextureSupported: boolean;
  30250. protected _renderingQueueLaunched: boolean;
  30251. protected _activeRenderLoops: (() => void)[];
  30252. /**
  30253. * Observable signaled when a context lost event is raised
  30254. */
  30255. onContextLostObservable: Observable<ThinEngine>;
  30256. /**
  30257. * Observable signaled when a context restored event is raised
  30258. */
  30259. onContextRestoredObservable: Observable<ThinEngine>;
  30260. private _onContextLost;
  30261. private _onContextRestored;
  30262. protected _contextWasLost: boolean;
  30263. /** @hidden */
  30264. _doNotHandleContextLost: boolean;
  30265. /**
  30266. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30268. */
  30269. doNotHandleContextLost: boolean;
  30270. /**
  30271. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30272. */
  30273. disableVertexArrayObjects: boolean;
  30274. /** @hidden */
  30275. protected _depthCullingState: DepthCullingState;
  30276. /** @hidden */
  30277. protected _stencilState: StencilState;
  30278. /** @hidden */
  30279. protected _alphaState: AlphaState;
  30280. /** @hidden */
  30281. _internalTexturesCache: InternalTexture[];
  30282. /** @hidden */
  30283. protected _activeChannel: number;
  30284. private _currentTextureChannel;
  30285. /** @hidden */
  30286. protected _boundTexturesCache: {
  30287. [key: string]: Nullable<InternalTexture>;
  30288. };
  30289. /** @hidden */
  30290. protected _currentEffect: Nullable<Effect>;
  30291. /** @hidden */
  30292. protected _currentProgram: Nullable<WebGLProgram>;
  30293. private _compiledEffects;
  30294. private _vertexAttribArraysEnabled;
  30295. /** @hidden */
  30296. protected _cachedViewport: Nullable<IViewportLike>;
  30297. private _cachedVertexArrayObject;
  30298. /** @hidden */
  30299. protected _cachedVertexBuffers: any;
  30300. /** @hidden */
  30301. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30302. /** @hidden */
  30303. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30304. /** @hidden */
  30305. _currentRenderTarget: Nullable<InternalTexture>;
  30306. private _uintIndicesCurrentlySet;
  30307. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30308. /** @hidden */
  30309. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30310. private _currentBufferPointers;
  30311. private _currentInstanceLocations;
  30312. private _currentInstanceBuffers;
  30313. private _textureUnits;
  30314. /** @hidden */
  30315. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30316. /** @hidden */
  30317. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30318. /** @hidden */
  30319. _boundRenderFunction: any;
  30320. private _vaoRecordInProgress;
  30321. private _mustWipeVertexAttributes;
  30322. private _emptyTexture;
  30323. private _emptyCubeTexture;
  30324. private _emptyTexture3D;
  30325. private _emptyTexture2DArray;
  30326. /** @hidden */
  30327. _frameHandler: number;
  30328. private _nextFreeTextureSlots;
  30329. private _maxSimultaneousTextures;
  30330. private _activeRequests;
  30331. protected _texturesSupported: string[];
  30332. /** @hidden */
  30333. _textureFormatInUse: Nullable<string>;
  30334. protected readonly _supportsHardwareTextureRescaling: boolean;
  30335. /**
  30336. * Gets the list of texture formats supported
  30337. */
  30338. readonly texturesSupported: Array<string>;
  30339. /**
  30340. * Gets the list of texture formats in use
  30341. */
  30342. readonly textureFormatInUse: Nullable<string>;
  30343. /**
  30344. * Gets the current viewport
  30345. */
  30346. readonly currentViewport: Nullable<IViewportLike>;
  30347. /**
  30348. * Gets the default empty texture
  30349. */
  30350. readonly emptyTexture: InternalTexture;
  30351. /**
  30352. * Gets the default empty 3D texture
  30353. */
  30354. readonly emptyTexture3D: InternalTexture;
  30355. /**
  30356. * Gets the default empty 2D array texture
  30357. */
  30358. readonly emptyTexture2DArray: InternalTexture;
  30359. /**
  30360. * Gets the default empty cube texture
  30361. */
  30362. readonly emptyCubeTexture: InternalTexture;
  30363. /**
  30364. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30365. */
  30366. readonly premultipliedAlpha: boolean;
  30367. /**
  30368. * Observable event triggered before each texture is initialized
  30369. */
  30370. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30371. /**
  30372. * Creates a new engine
  30373. * @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
  30374. * @param antialias defines enable antialiasing (default: false)
  30375. * @param options defines further options to be sent to the getContext() function
  30376. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30377. */
  30378. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30379. private _rebuildInternalTextures;
  30380. private _rebuildEffects;
  30381. /**
  30382. * Gets a boolean indicating if all created effects are ready
  30383. * @returns true if all effects are ready
  30384. */
  30385. areAllEffectsReady(): boolean;
  30386. protected _rebuildBuffers(): void;
  30387. private _initGLContext;
  30388. /**
  30389. * Gets version of the current webGL context
  30390. */
  30391. readonly webGLVersion: number;
  30392. /**
  30393. * Gets a string idenfifying the name of the class
  30394. * @returns "Engine" string
  30395. */
  30396. getClassName(): string;
  30397. /**
  30398. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30399. */
  30400. readonly isStencilEnable: boolean;
  30401. /** @hidden */
  30402. _prepareWorkingCanvas(): void;
  30403. /**
  30404. * Reset the texture cache to empty state
  30405. */
  30406. resetTextureCache(): void;
  30407. /**
  30408. * Gets an object containing information about the current webGL context
  30409. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30410. */
  30411. getGlInfo(): {
  30412. vendor: string;
  30413. renderer: string;
  30414. version: string;
  30415. };
  30416. /**
  30417. * Defines the hardware scaling level.
  30418. * By default the hardware scaling level is computed from the window device ratio.
  30419. * 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.
  30420. * @param level defines the level to use
  30421. */
  30422. setHardwareScalingLevel(level: number): void;
  30423. /**
  30424. * Gets the current hardware scaling level.
  30425. * By default the hardware scaling level is computed from the window device ratio.
  30426. * 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.
  30427. * @returns a number indicating the current hardware scaling level
  30428. */
  30429. getHardwareScalingLevel(): number;
  30430. /**
  30431. * Gets the list of loaded textures
  30432. * @returns an array containing all loaded textures
  30433. */
  30434. getLoadedTexturesCache(): InternalTexture[];
  30435. /**
  30436. * Gets the object containing all engine capabilities
  30437. * @returns the EngineCapabilities object
  30438. */
  30439. getCaps(): EngineCapabilities;
  30440. /**
  30441. * stop executing a render loop function and remove it from the execution array
  30442. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30443. */
  30444. stopRenderLoop(renderFunction?: () => void): void;
  30445. /** @hidden */
  30446. _renderLoop(): void;
  30447. /**
  30448. * Gets the HTML canvas attached with the current webGL context
  30449. * @returns a HTML canvas
  30450. */
  30451. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30452. /**
  30453. * Gets host window
  30454. * @returns the host window object
  30455. */
  30456. getHostWindow(): Nullable<Window>;
  30457. /**
  30458. * Gets the current render width
  30459. * @param useScreen defines if screen size must be used (or the current render target if any)
  30460. * @returns a number defining the current render width
  30461. */
  30462. getRenderWidth(useScreen?: boolean): number;
  30463. /**
  30464. * Gets the current render height
  30465. * @param useScreen defines if screen size must be used (or the current render target if any)
  30466. * @returns a number defining the current render height
  30467. */
  30468. getRenderHeight(useScreen?: boolean): number;
  30469. /**
  30470. * Can be used to override the current requestAnimationFrame requester.
  30471. * @hidden
  30472. */
  30473. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30474. /**
  30475. * Register and execute a render loop. The engine can have more than one render function
  30476. * @param renderFunction defines the function to continuously execute
  30477. */
  30478. runRenderLoop(renderFunction: () => void): void;
  30479. /**
  30480. * Clear the current render buffer or the current render target (if any is set up)
  30481. * @param color defines the color to use
  30482. * @param backBuffer defines if the back buffer must be cleared
  30483. * @param depth defines if the depth buffer must be cleared
  30484. * @param stencil defines if the stencil buffer must be cleared
  30485. */
  30486. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30487. private _viewportCached;
  30488. /** @hidden */
  30489. _viewport(x: number, y: number, width: number, height: number): void;
  30490. /**
  30491. * Set the WebGL's viewport
  30492. * @param viewport defines the viewport element to be used
  30493. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30494. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30495. */
  30496. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30497. /**
  30498. * Begin a new frame
  30499. */
  30500. beginFrame(): void;
  30501. /**
  30502. * Enf the current frame
  30503. */
  30504. endFrame(): void;
  30505. /**
  30506. * Resize the view according to the canvas' size
  30507. */
  30508. resize(): void;
  30509. /**
  30510. * Force a specific size of the canvas
  30511. * @param width defines the new canvas' width
  30512. * @param height defines the new canvas' height
  30513. */
  30514. setSize(width: number, height: number): void;
  30515. /**
  30516. * Binds the frame buffer to the specified texture.
  30517. * @param texture The texture to render to or null for the default canvas
  30518. * @param faceIndex The face of the texture to render to in case of cube texture
  30519. * @param requiredWidth The width of the target to render to
  30520. * @param requiredHeight The height of the target to render to
  30521. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30522. * @param depthStencilTexture The depth stencil texture to use to render
  30523. * @param lodLevel defines le lod level to bind to the frame buffer
  30524. */
  30525. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30526. /** @hidden */
  30527. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30528. /**
  30529. * Unbind the current render target texture from the webGL context
  30530. * @param texture defines the render target texture to unbind
  30531. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30532. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30533. */
  30534. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30535. /**
  30536. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30537. */
  30538. flushFramebuffer(): void;
  30539. /**
  30540. * Unbind the current render target and bind the default framebuffer
  30541. */
  30542. restoreDefaultFramebuffer(): void;
  30543. /** @hidden */
  30544. protected _resetVertexBufferBinding(): void;
  30545. /**
  30546. * Creates a vertex buffer
  30547. * @param data the data for the vertex buffer
  30548. * @returns the new WebGL static buffer
  30549. */
  30550. createVertexBuffer(data: DataArray): DataBuffer;
  30551. private _createVertexBuffer;
  30552. /**
  30553. * Creates a dynamic vertex buffer
  30554. * @param data the data for the dynamic vertex buffer
  30555. * @returns the new WebGL dynamic buffer
  30556. */
  30557. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30558. protected _resetIndexBufferBinding(): void;
  30559. /**
  30560. * Creates a new index buffer
  30561. * @param indices defines the content of the index buffer
  30562. * @param updatable defines if the index buffer must be updatable
  30563. * @returns a new webGL buffer
  30564. */
  30565. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30566. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30567. /**
  30568. * Bind a webGL buffer to the webGL context
  30569. * @param buffer defines the buffer to bind
  30570. */
  30571. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30572. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30573. private bindBuffer;
  30574. /**
  30575. * update the bound buffer with the given data
  30576. * @param data defines the data to update
  30577. */
  30578. updateArrayBuffer(data: Float32Array): void;
  30579. private _vertexAttribPointer;
  30580. private _bindIndexBufferWithCache;
  30581. private _bindVertexBuffersAttributes;
  30582. /**
  30583. * Records a vertex array object
  30584. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30585. * @param vertexBuffers defines the list of vertex buffers to store
  30586. * @param indexBuffer defines the index buffer to store
  30587. * @param effect defines the effect to store
  30588. * @returns the new vertex array object
  30589. */
  30590. recordVertexArrayObject(vertexBuffers: {
  30591. [key: string]: VertexBuffer;
  30592. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30593. /**
  30594. * Bind a specific vertex array object
  30595. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30596. * @param vertexArrayObject defines the vertex array object to bind
  30597. * @param indexBuffer defines the index buffer to bind
  30598. */
  30599. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30600. /**
  30601. * Bind webGl buffers directly to the webGL context
  30602. * @param vertexBuffer defines the vertex buffer to bind
  30603. * @param indexBuffer defines the index buffer to bind
  30604. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30605. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30606. * @param effect defines the effect associated with the vertex buffer
  30607. */
  30608. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30609. private _unbindVertexArrayObject;
  30610. /**
  30611. * Bind a list of vertex buffers to the webGL context
  30612. * @param vertexBuffers defines the list of vertex buffers to bind
  30613. * @param indexBuffer defines the index buffer to bind
  30614. * @param effect defines the effect associated with the vertex buffers
  30615. */
  30616. bindBuffers(vertexBuffers: {
  30617. [key: string]: Nullable<VertexBuffer>;
  30618. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30619. /**
  30620. * Unbind all instance attributes
  30621. */
  30622. unbindInstanceAttributes(): void;
  30623. /**
  30624. * Release and free the memory of a vertex array object
  30625. * @param vao defines the vertex array object to delete
  30626. */
  30627. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30628. /** @hidden */
  30629. _releaseBuffer(buffer: DataBuffer): boolean;
  30630. protected _deleteBuffer(buffer: DataBuffer): void;
  30631. /**
  30632. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30633. * @param instancesBuffer defines the webGL buffer to update and bind
  30634. * @param data defines the data to store in the buffer
  30635. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30636. */
  30637. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30638. /**
  30639. * Apply all cached states (depth, culling, stencil and alpha)
  30640. */
  30641. applyStates(): void;
  30642. /**
  30643. * Send a draw order
  30644. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30645. * @param indexStart defines the starting index
  30646. * @param indexCount defines the number of index to draw
  30647. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30648. */
  30649. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30650. /**
  30651. * Draw a list of points
  30652. * @param verticesStart defines the index of first vertex to draw
  30653. * @param verticesCount defines the count of vertices to draw
  30654. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30655. */
  30656. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30657. /**
  30658. * Draw a list of unindexed primitives
  30659. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30660. * @param verticesStart defines the index of first vertex to draw
  30661. * @param verticesCount defines the count of vertices to draw
  30662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30663. */
  30664. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30665. /**
  30666. * Draw a list of indexed primitives
  30667. * @param fillMode defines the primitive to use
  30668. * @param indexStart defines the starting index
  30669. * @param indexCount defines the number of index to draw
  30670. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30671. */
  30672. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30673. /**
  30674. * Draw a list of unindexed primitives
  30675. * @param fillMode defines the primitive to use
  30676. * @param verticesStart defines the index of first vertex to draw
  30677. * @param verticesCount defines the count of vertices to draw
  30678. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30679. */
  30680. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30681. private _drawMode;
  30682. /** @hidden */
  30683. protected _reportDrawCall(): void;
  30684. /** @hidden */
  30685. _releaseEffect(effect: Effect): void;
  30686. /** @hidden */
  30687. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30688. /**
  30689. * Create a new effect (used to store vertex/fragment shaders)
  30690. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30691. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30692. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30693. * @param samplers defines an array of string used to represent textures
  30694. * @param defines defines the string containing the defines to use to compile the shaders
  30695. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30696. * @param onCompiled defines a function to call when the effect creation is successful
  30697. * @param onError defines a function to call when the effect creation has failed
  30698. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30699. * @returns the new Effect
  30700. */
  30701. 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;
  30702. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30703. private _compileShader;
  30704. private _compileRawShader;
  30705. /**
  30706. * Directly creates a webGL program
  30707. * @param pipelineContext defines the pipeline context to attach to
  30708. * @param vertexCode defines the vertex shader code to use
  30709. * @param fragmentCode defines the fragment shader code to use
  30710. * @param context defines the webGL context to use (if not set, the current one will be used)
  30711. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30712. * @returns the new webGL program
  30713. */
  30714. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30715. /**
  30716. * Creates a webGL program
  30717. * @param pipelineContext defines the pipeline context to attach to
  30718. * @param vertexCode defines the vertex shader code to use
  30719. * @param fragmentCode defines the fragment shader code to use
  30720. * @param defines defines the string containing the defines to use to compile the shaders
  30721. * @param context defines the webGL context to use (if not set, the current one will be used)
  30722. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30723. * @returns the new webGL program
  30724. */
  30725. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30726. /**
  30727. * Creates a new pipeline context
  30728. * @returns the new pipeline
  30729. */
  30730. createPipelineContext(): IPipelineContext;
  30731. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30732. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30733. /** @hidden */
  30734. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30735. /** @hidden */
  30736. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30737. /** @hidden */
  30738. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30739. /**
  30740. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30741. * @param pipelineContext defines the pipeline context to use
  30742. * @param uniformsNames defines the list of uniform names
  30743. * @returns an array of webGL uniform locations
  30744. */
  30745. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30746. /**
  30747. * Gets the lsit of active attributes for a given webGL program
  30748. * @param pipelineContext defines the pipeline context to use
  30749. * @param attributesNames defines the list of attribute names to get
  30750. * @returns an array of indices indicating the offset of each attribute
  30751. */
  30752. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30753. /**
  30754. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30755. * @param effect defines the effect to activate
  30756. */
  30757. enableEffect(effect: Nullable<Effect>): void;
  30758. /**
  30759. * Set the value of an uniform to a number (int)
  30760. * @param uniform defines the webGL uniform location where to store the value
  30761. * @param value defines the int number to store
  30762. */
  30763. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30764. /**
  30765. * Set the value of an uniform to an array of int32
  30766. * @param uniform defines the webGL uniform location where to store the value
  30767. * @param array defines the array of int32 to store
  30768. */
  30769. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30770. /**
  30771. * Set the value of an uniform to an array of int32 (stored as vec2)
  30772. * @param uniform defines the webGL uniform location where to store the value
  30773. * @param array defines the array of int32 to store
  30774. */
  30775. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30776. /**
  30777. * Set the value of an uniform to an array of int32 (stored as vec3)
  30778. * @param uniform defines the webGL uniform location where to store the value
  30779. * @param array defines the array of int32 to store
  30780. */
  30781. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30782. /**
  30783. * Set the value of an uniform to an array of int32 (stored as vec4)
  30784. * @param uniform defines the webGL uniform location where to store the value
  30785. * @param array defines the array of int32 to store
  30786. */
  30787. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30788. /**
  30789. * Set the value of an uniform to an array of number
  30790. * @param uniform defines the webGL uniform location where to store the value
  30791. * @param array defines the array of number to store
  30792. */
  30793. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30794. /**
  30795. * Set the value of an uniform to an array of number (stored as vec2)
  30796. * @param uniform defines the webGL uniform location where to store the value
  30797. * @param array defines the array of number to store
  30798. */
  30799. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30800. /**
  30801. * Set the value of an uniform to an array of number (stored as vec3)
  30802. * @param uniform defines the webGL uniform location where to store the value
  30803. * @param array defines the array of number to store
  30804. */
  30805. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30806. /**
  30807. * Set the value of an uniform to an array of number (stored as vec4)
  30808. * @param uniform defines the webGL uniform location where to store the value
  30809. * @param array defines the array of number to store
  30810. */
  30811. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30812. /**
  30813. * Set the value of an uniform to an array of float32 (stored as matrices)
  30814. * @param uniform defines the webGL uniform location where to store the value
  30815. * @param matrices defines the array of float32 to store
  30816. */
  30817. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30818. /**
  30819. * Set the value of an uniform to a matrix (3x3)
  30820. * @param uniform defines the webGL uniform location where to store the value
  30821. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30822. */
  30823. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30824. /**
  30825. * Set the value of an uniform to a matrix (2x2)
  30826. * @param uniform defines the webGL uniform location where to store the value
  30827. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30828. */
  30829. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30830. /**
  30831. * Set the value of an uniform to a number (float)
  30832. * @param uniform defines the webGL uniform location where to store the value
  30833. * @param value defines the float number to store
  30834. */
  30835. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30836. /**
  30837. * Set the value of an uniform to a vec2
  30838. * @param uniform defines the webGL uniform location where to store the value
  30839. * @param x defines the 1st component of the value
  30840. * @param y defines the 2nd component of the value
  30841. */
  30842. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30843. /**
  30844. * Set the value of an uniform to a vec3
  30845. * @param uniform defines the webGL uniform location where to store the value
  30846. * @param x defines the 1st component of the value
  30847. * @param y defines the 2nd component of the value
  30848. * @param z defines the 3rd component of the value
  30849. */
  30850. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30851. /**
  30852. * Set the value of an uniform to a vec4
  30853. * @param uniform defines the webGL uniform location where to store the value
  30854. * @param x defines the 1st component of the value
  30855. * @param y defines the 2nd component of the value
  30856. * @param z defines the 3rd component of the value
  30857. * @param w defines the 4th component of the value
  30858. */
  30859. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30860. /**
  30861. * Gets the depth culling state manager
  30862. */
  30863. readonly depthCullingState: DepthCullingState;
  30864. /**
  30865. * Gets the alpha state manager
  30866. */
  30867. readonly alphaState: AlphaState;
  30868. /**
  30869. * Gets the stencil state manager
  30870. */
  30871. readonly stencilState: StencilState;
  30872. /**
  30873. * Clears the list of texture accessible through engine.
  30874. * This can help preventing texture load conflict due to name collision.
  30875. */
  30876. clearInternalTexturesCache(): void;
  30877. /**
  30878. * Force the entire cache to be cleared
  30879. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30880. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30881. */
  30882. wipeCaches(bruteForce?: boolean): void;
  30883. /** @hidden */
  30884. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30885. min: number;
  30886. mag: number;
  30887. };
  30888. /** @hidden */
  30889. _createTexture(): WebGLTexture;
  30890. /**
  30891. * Usually called from Texture.ts.
  30892. * Passed information to create a WebGLTexture
  30893. * @param urlArg defines a value which contains one of the following:
  30894. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30895. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30896. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30897. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30898. * @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)
  30899. * @param scene needed for loading to the correct scene
  30900. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30901. * @param onLoad optional callback to be called upon successful completion
  30902. * @param onError optional callback to be called upon failure
  30903. * @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
  30904. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30905. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30906. * @param forcedExtension defines the extension to use to pick the right loader
  30907. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30908. * @param mimeType defines an optional mime type
  30909. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30910. */
  30911. 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;
  30912. /**
  30913. * @hidden
  30914. */
  30915. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30916. /**
  30917. * Creates a raw texture
  30918. * @param data defines the data to store in the texture
  30919. * @param width defines the width of the texture
  30920. * @param height defines the height of the texture
  30921. * @param format defines the format of the data
  30922. * @param generateMipMaps defines if the engine should generate the mip levels
  30923. * @param invertY defines if data must be stored with Y axis inverted
  30924. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30925. * @param compression defines the compression used (null by default)
  30926. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30927. * @returns the raw texture inside an InternalTexture
  30928. */
  30929. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30930. /**
  30931. * Creates a new raw cube texture
  30932. * @param data defines the array of data to use to create each face
  30933. * @param size defines the size of the textures
  30934. * @param format defines the format of the data
  30935. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30936. * @param generateMipMaps defines if the engine should generate the mip levels
  30937. * @param invertY defines if data must be stored with Y axis inverted
  30938. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30939. * @param compression defines the compression used (null by default)
  30940. * @returns the cube texture as an InternalTexture
  30941. */
  30942. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30943. /**
  30944. * Creates a new raw 3D texture
  30945. * @param data defines the data used to create the texture
  30946. * @param width defines the width of the texture
  30947. * @param height defines the height of the texture
  30948. * @param depth defines the depth of the texture
  30949. * @param format defines the format of the texture
  30950. * @param generateMipMaps defines if the engine must generate mip levels
  30951. * @param invertY defines if data must be stored with Y axis inverted
  30952. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30953. * @param compression defines the compressed used (can be null)
  30954. * @param textureType defines the compressed used (can be null)
  30955. * @returns a new raw 3D texture (stored in an InternalTexture)
  30956. */
  30957. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30958. /**
  30959. * Creates a new raw 2D array texture
  30960. * @param data defines the data used to create the texture
  30961. * @param width defines the width of the texture
  30962. * @param height defines the height of the texture
  30963. * @param depth defines the number of layers of the texture
  30964. * @param format defines the format of the texture
  30965. * @param generateMipMaps defines if the engine must generate mip levels
  30966. * @param invertY defines if data must be stored with Y axis inverted
  30967. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30968. * @param compression defines the compressed used (can be null)
  30969. * @param textureType defines the compressed used (can be null)
  30970. * @returns a new raw 2D array texture (stored in an InternalTexture)
  30971. */
  30972. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30973. private _unpackFlipYCached;
  30974. /**
  30975. * In case you are sharing the context with other applications, it might
  30976. * be interested to not cache the unpack flip y state to ensure a consistent
  30977. * value would be set.
  30978. */
  30979. enableUnpackFlipYCached: boolean;
  30980. /** @hidden */
  30981. _unpackFlipY(value: boolean): void;
  30982. /** @hidden */
  30983. _getUnpackAlignement(): number;
  30984. /**
  30985. * Update the sampling mode of a given texture
  30986. * @param samplingMode defines the required sampling mode
  30987. * @param texture defines the texture to update
  30988. */
  30989. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30990. /** @hidden */
  30991. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30992. width: number;
  30993. height: number;
  30994. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30995. /** @hidden */
  30996. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30997. /** @hidden */
  30998. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30999. /** @hidden */
  31000. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31001. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31002. private _prepareWebGLTexture;
  31003. /** @hidden */
  31004. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31005. /** @hidden */
  31006. _releaseFramebufferObjects(texture: InternalTexture): void;
  31007. /** @hidden */
  31008. _releaseTexture(texture: InternalTexture): void;
  31009. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31010. protected _setProgram(program: WebGLProgram): void;
  31011. protected _boundUniforms: {
  31012. [key: number]: WebGLUniformLocation;
  31013. };
  31014. /**
  31015. * Binds an effect to the webGL context
  31016. * @param effect defines the effect to bind
  31017. */
  31018. bindSamplers(effect: Effect): void;
  31019. private _activateCurrentTexture;
  31020. /** @hidden */
  31021. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31022. /** @hidden */
  31023. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31024. /**
  31025. * Unbind all textures from the webGL context
  31026. */
  31027. unbindAllTextures(): void;
  31028. /**
  31029. * Sets a texture to the according uniform.
  31030. * @param channel The texture channel
  31031. * @param uniform The uniform to set
  31032. * @param texture The texture to apply
  31033. */
  31034. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31035. private _bindSamplerUniformToChannel;
  31036. private _getTextureWrapMode;
  31037. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31038. /**
  31039. * Sets an array of texture to the webGL context
  31040. * @param channel defines the channel where the texture array must be set
  31041. * @param uniform defines the associated uniform location
  31042. * @param textures defines the array of textures to bind
  31043. */
  31044. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31045. /** @hidden */
  31046. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31047. private _setTextureParameterFloat;
  31048. private _setTextureParameterInteger;
  31049. /**
  31050. * Unbind all vertex attributes from the webGL context
  31051. */
  31052. unbindAllAttributes(): void;
  31053. /**
  31054. * 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
  31055. */
  31056. releaseEffects(): void;
  31057. /**
  31058. * Dispose and release all associated resources
  31059. */
  31060. dispose(): void;
  31061. /**
  31062. * Attach a new callback raised when context lost event is fired
  31063. * @param callback defines the callback to call
  31064. */
  31065. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31066. /**
  31067. * Attach a new callback raised when context restored event is fired
  31068. * @param callback defines the callback to call
  31069. */
  31070. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31071. /**
  31072. * Get the current error code of the webGL context
  31073. * @returns the error code
  31074. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31075. */
  31076. getError(): number;
  31077. private _canRenderToFloatFramebuffer;
  31078. private _canRenderToHalfFloatFramebuffer;
  31079. private _canRenderToFramebuffer;
  31080. /** @hidden */
  31081. _getWebGLTextureType(type: number): number;
  31082. /** @hidden */
  31083. _getInternalFormat(format: number): number;
  31084. /** @hidden */
  31085. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31086. /** @hidden */
  31087. _getRGBAMultiSampleBufferFormat(type: number): number;
  31088. /** @hidden */
  31089. _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;
  31090. /**
  31091. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31092. * @returns true if the engine can be created
  31093. * @ignorenaming
  31094. */
  31095. static isSupported(): boolean;
  31096. /**
  31097. * Find the next highest power of two.
  31098. * @param x Number to start search from.
  31099. * @return Next highest power of two.
  31100. */
  31101. static CeilingPOT(x: number): number;
  31102. /**
  31103. * Find the next lowest power of two.
  31104. * @param x Number to start search from.
  31105. * @return Next lowest power of two.
  31106. */
  31107. static FloorPOT(x: number): number;
  31108. /**
  31109. * Find the nearest power of two.
  31110. * @param x Number to start search from.
  31111. * @return Next nearest power of two.
  31112. */
  31113. static NearestPOT(x: number): number;
  31114. /**
  31115. * Get the closest exponent of two
  31116. * @param value defines the value to approximate
  31117. * @param max defines the maximum value to return
  31118. * @param mode defines how to define the closest value
  31119. * @returns closest exponent of two of the given value
  31120. */
  31121. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31122. /**
  31123. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31124. * @param func - the function to be called
  31125. * @param requester - the object that will request the next frame. Falls back to window.
  31126. * @returns frame number
  31127. */
  31128. static QueueNewFrame(func: () => void, requester?: any): number;
  31129. }
  31130. }
  31131. declare module "babylonjs/Maths/sphericalPolynomial" {
  31132. import { Vector3 } from "babylonjs/Maths/math.vector";
  31133. import { Color3 } from "babylonjs/Maths/math.color";
  31134. /**
  31135. * Class representing spherical harmonics coefficients to the 3rd degree
  31136. */
  31137. export class SphericalHarmonics {
  31138. /**
  31139. * Defines whether or not the harmonics have been prescaled for rendering.
  31140. */
  31141. preScaled: boolean;
  31142. /**
  31143. * The l0,0 coefficients of the spherical harmonics
  31144. */
  31145. l00: Vector3;
  31146. /**
  31147. * The l1,-1 coefficients of the spherical harmonics
  31148. */
  31149. l1_1: Vector3;
  31150. /**
  31151. * The l1,0 coefficients of the spherical harmonics
  31152. */
  31153. l10: Vector3;
  31154. /**
  31155. * The l1,1 coefficients of the spherical harmonics
  31156. */
  31157. l11: Vector3;
  31158. /**
  31159. * The l2,-2 coefficients of the spherical harmonics
  31160. */
  31161. l2_2: Vector3;
  31162. /**
  31163. * The l2,-1 coefficients of the spherical harmonics
  31164. */
  31165. l2_1: Vector3;
  31166. /**
  31167. * The l2,0 coefficients of the spherical harmonics
  31168. */
  31169. l20: Vector3;
  31170. /**
  31171. * The l2,1 coefficients of the spherical harmonics
  31172. */
  31173. l21: Vector3;
  31174. /**
  31175. * The l2,2 coefficients of the spherical harmonics
  31176. */
  31177. l22: Vector3;
  31178. /**
  31179. * Adds a light to the spherical harmonics
  31180. * @param direction the direction of the light
  31181. * @param color the color of the light
  31182. * @param deltaSolidAngle the delta solid angle of the light
  31183. */
  31184. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31185. /**
  31186. * Scales the spherical harmonics by the given amount
  31187. * @param scale the amount to scale
  31188. */
  31189. scaleInPlace(scale: number): void;
  31190. /**
  31191. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31192. *
  31193. * ```
  31194. * E_lm = A_l * L_lm
  31195. * ```
  31196. *
  31197. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31198. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31199. * the scaling factors are given in equation 9.
  31200. */
  31201. convertIncidentRadianceToIrradiance(): void;
  31202. /**
  31203. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31204. *
  31205. * ```
  31206. * L = (1/pi) * E * rho
  31207. * ```
  31208. *
  31209. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31210. */
  31211. convertIrradianceToLambertianRadiance(): void;
  31212. /**
  31213. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31214. * required operations at run time.
  31215. *
  31216. * This is simply done by scaling back the SH with Ylm constants parameter.
  31217. * The trigonometric part being applied by the shader at run time.
  31218. */
  31219. preScaleForRendering(): void;
  31220. /**
  31221. * Constructs a spherical harmonics from an array.
  31222. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31223. * @returns the spherical harmonics
  31224. */
  31225. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31226. /**
  31227. * Gets the spherical harmonics from polynomial
  31228. * @param polynomial the spherical polynomial
  31229. * @returns the spherical harmonics
  31230. */
  31231. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31232. }
  31233. /**
  31234. * Class representing spherical polynomial coefficients to the 3rd degree
  31235. */
  31236. export class SphericalPolynomial {
  31237. private _harmonics;
  31238. /**
  31239. * The spherical harmonics used to create the polynomials.
  31240. */
  31241. readonly preScaledHarmonics: SphericalHarmonics;
  31242. /**
  31243. * The x coefficients of the spherical polynomial
  31244. */
  31245. x: Vector3;
  31246. /**
  31247. * The y coefficients of the spherical polynomial
  31248. */
  31249. y: Vector3;
  31250. /**
  31251. * The z coefficients of the spherical polynomial
  31252. */
  31253. z: Vector3;
  31254. /**
  31255. * The xx coefficients of the spherical polynomial
  31256. */
  31257. xx: Vector3;
  31258. /**
  31259. * The yy coefficients of the spherical polynomial
  31260. */
  31261. yy: Vector3;
  31262. /**
  31263. * The zz coefficients of the spherical polynomial
  31264. */
  31265. zz: Vector3;
  31266. /**
  31267. * The xy coefficients of the spherical polynomial
  31268. */
  31269. xy: Vector3;
  31270. /**
  31271. * The yz coefficients of the spherical polynomial
  31272. */
  31273. yz: Vector3;
  31274. /**
  31275. * The zx coefficients of the spherical polynomial
  31276. */
  31277. zx: Vector3;
  31278. /**
  31279. * Adds an ambient color to the spherical polynomial
  31280. * @param color the color to add
  31281. */
  31282. addAmbient(color: Color3): void;
  31283. /**
  31284. * Scales the spherical polynomial by the given amount
  31285. * @param scale the amount to scale
  31286. */
  31287. scaleInPlace(scale: number): void;
  31288. /**
  31289. * Gets the spherical polynomial from harmonics
  31290. * @param harmonics the spherical harmonics
  31291. * @returns the spherical polynomial
  31292. */
  31293. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31294. /**
  31295. * Constructs a spherical polynomial from an array.
  31296. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31297. * @returns the spherical polynomial
  31298. */
  31299. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31300. }
  31301. }
  31302. declare module "babylonjs/Materials/Textures/internalTexture" {
  31303. import { Observable } from "babylonjs/Misc/observable";
  31304. import { Nullable, int } from "babylonjs/types";
  31305. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31306. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31307. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31308. /**
  31309. * Defines the source of the internal texture
  31310. */
  31311. export enum InternalTextureSource {
  31312. /**
  31313. * The source of the texture data is unknown
  31314. */
  31315. Unknown = 0,
  31316. /**
  31317. * Texture data comes from an URL
  31318. */
  31319. Url = 1,
  31320. /**
  31321. * Texture data is only used for temporary storage
  31322. */
  31323. Temp = 2,
  31324. /**
  31325. * Texture data comes from raw data (ArrayBuffer)
  31326. */
  31327. Raw = 3,
  31328. /**
  31329. * Texture content is dynamic (video or dynamic texture)
  31330. */
  31331. Dynamic = 4,
  31332. /**
  31333. * Texture content is generated by rendering to it
  31334. */
  31335. RenderTarget = 5,
  31336. /**
  31337. * Texture content is part of a multi render target process
  31338. */
  31339. MultiRenderTarget = 6,
  31340. /**
  31341. * Texture data comes from a cube data file
  31342. */
  31343. Cube = 7,
  31344. /**
  31345. * Texture data comes from a raw cube data
  31346. */
  31347. CubeRaw = 8,
  31348. /**
  31349. * Texture data come from a prefiltered cube data file
  31350. */
  31351. CubePrefiltered = 9,
  31352. /**
  31353. * Texture content is raw 3D data
  31354. */
  31355. Raw3D = 10,
  31356. /**
  31357. * Texture content is raw 2D array data
  31358. */
  31359. Raw2DArray = 11,
  31360. /**
  31361. * Texture content is a depth texture
  31362. */
  31363. Depth = 12,
  31364. /**
  31365. * Texture data comes from a raw cube data encoded with RGBD
  31366. */
  31367. CubeRawRGBD = 13
  31368. }
  31369. /**
  31370. * Class used to store data associated with WebGL texture data for the engine
  31371. * This class should not be used directly
  31372. */
  31373. export class InternalTexture {
  31374. /** @hidden */
  31375. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31376. /**
  31377. * Defines if the texture is ready
  31378. */
  31379. isReady: boolean;
  31380. /**
  31381. * Defines if the texture is a cube texture
  31382. */
  31383. isCube: boolean;
  31384. /**
  31385. * Defines if the texture contains 3D data
  31386. */
  31387. is3D: boolean;
  31388. /**
  31389. * Defines if the texture contains 2D array data
  31390. */
  31391. is2DArray: boolean;
  31392. /**
  31393. * Defines if the texture contains multiview data
  31394. */
  31395. isMultiview: boolean;
  31396. /**
  31397. * Gets the URL used to load this texture
  31398. */
  31399. url: string;
  31400. /**
  31401. * Gets the sampling mode of the texture
  31402. */
  31403. samplingMode: number;
  31404. /**
  31405. * Gets a boolean indicating if the texture needs mipmaps generation
  31406. */
  31407. generateMipMaps: boolean;
  31408. /**
  31409. * Gets the number of samples used by the texture (WebGL2+ only)
  31410. */
  31411. samples: number;
  31412. /**
  31413. * Gets the type of the texture (int, float...)
  31414. */
  31415. type: number;
  31416. /**
  31417. * Gets the format of the texture (RGB, RGBA...)
  31418. */
  31419. format: number;
  31420. /**
  31421. * Observable called when the texture is loaded
  31422. */
  31423. onLoadedObservable: Observable<InternalTexture>;
  31424. /**
  31425. * Gets the width of the texture
  31426. */
  31427. width: number;
  31428. /**
  31429. * Gets the height of the texture
  31430. */
  31431. height: number;
  31432. /**
  31433. * Gets the depth of the texture
  31434. */
  31435. depth: number;
  31436. /**
  31437. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31438. */
  31439. baseWidth: number;
  31440. /**
  31441. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31442. */
  31443. baseHeight: number;
  31444. /**
  31445. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31446. */
  31447. baseDepth: number;
  31448. /**
  31449. * Gets a boolean indicating if the texture is inverted on Y axis
  31450. */
  31451. invertY: boolean;
  31452. /** @hidden */
  31453. _invertVScale: boolean;
  31454. /** @hidden */
  31455. _associatedChannel: number;
  31456. /** @hidden */
  31457. _source: InternalTextureSource;
  31458. /** @hidden */
  31459. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31460. /** @hidden */
  31461. _bufferView: Nullable<ArrayBufferView>;
  31462. /** @hidden */
  31463. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31464. /** @hidden */
  31465. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31466. /** @hidden */
  31467. _size: number;
  31468. /** @hidden */
  31469. _extension: string;
  31470. /** @hidden */
  31471. _files: Nullable<string[]>;
  31472. /** @hidden */
  31473. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31474. /** @hidden */
  31475. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31476. /** @hidden */
  31477. _framebuffer: Nullable<WebGLFramebuffer>;
  31478. /** @hidden */
  31479. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31480. /** @hidden */
  31481. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31482. /** @hidden */
  31483. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31484. /** @hidden */
  31485. _attachments: Nullable<number[]>;
  31486. /** @hidden */
  31487. _cachedCoordinatesMode: Nullable<number>;
  31488. /** @hidden */
  31489. _cachedWrapU: Nullable<number>;
  31490. /** @hidden */
  31491. _cachedWrapV: Nullable<number>;
  31492. /** @hidden */
  31493. _cachedWrapR: Nullable<number>;
  31494. /** @hidden */
  31495. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31496. /** @hidden */
  31497. _isDisabled: boolean;
  31498. /** @hidden */
  31499. _compression: Nullable<string>;
  31500. /** @hidden */
  31501. _generateStencilBuffer: boolean;
  31502. /** @hidden */
  31503. _generateDepthBuffer: boolean;
  31504. /** @hidden */
  31505. _comparisonFunction: number;
  31506. /** @hidden */
  31507. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31508. /** @hidden */
  31509. _lodGenerationScale: number;
  31510. /** @hidden */
  31511. _lodGenerationOffset: number;
  31512. /** @hidden */
  31513. _colorTextureArray: Nullable<WebGLTexture>;
  31514. /** @hidden */
  31515. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31516. /** @hidden */
  31517. _lodTextureHigh: Nullable<BaseTexture>;
  31518. /** @hidden */
  31519. _lodTextureMid: Nullable<BaseTexture>;
  31520. /** @hidden */
  31521. _lodTextureLow: Nullable<BaseTexture>;
  31522. /** @hidden */
  31523. _isRGBD: boolean;
  31524. /** @hidden */
  31525. _linearSpecularLOD: boolean;
  31526. /** @hidden */
  31527. _irradianceTexture: Nullable<BaseTexture>;
  31528. /** @hidden */
  31529. _webGLTexture: Nullable<WebGLTexture>;
  31530. /** @hidden */
  31531. _references: number;
  31532. private _engine;
  31533. /**
  31534. * Gets the Engine the texture belongs to.
  31535. * @returns The babylon engine
  31536. */
  31537. getEngine(): ThinEngine;
  31538. /**
  31539. * Gets the data source type of the texture
  31540. */
  31541. readonly source: InternalTextureSource;
  31542. /**
  31543. * Creates a new InternalTexture
  31544. * @param engine defines the engine to use
  31545. * @param source defines the type of data that will be used
  31546. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31547. */
  31548. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31549. /**
  31550. * Increments the number of references (ie. the number of Texture that point to it)
  31551. */
  31552. incrementReferences(): void;
  31553. /**
  31554. * Change the size of the texture (not the size of the content)
  31555. * @param width defines the new width
  31556. * @param height defines the new height
  31557. * @param depth defines the new depth (1 by default)
  31558. */
  31559. updateSize(width: int, height: int, depth?: int): void;
  31560. /** @hidden */
  31561. _rebuild(): void;
  31562. /** @hidden */
  31563. _swapAndDie(target: InternalTexture): void;
  31564. /**
  31565. * Dispose the current allocated resources
  31566. */
  31567. dispose(): void;
  31568. }
  31569. }
  31570. declare module "babylonjs/Audio/analyser" {
  31571. import { Scene } from "babylonjs/scene";
  31572. /**
  31573. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31575. */
  31576. export class Analyser {
  31577. /**
  31578. * Gets or sets the smoothing
  31579. * @ignorenaming
  31580. */
  31581. SMOOTHING: number;
  31582. /**
  31583. * Gets or sets the FFT table size
  31584. * @ignorenaming
  31585. */
  31586. FFT_SIZE: number;
  31587. /**
  31588. * Gets or sets the bar graph amplitude
  31589. * @ignorenaming
  31590. */
  31591. BARGRAPHAMPLITUDE: number;
  31592. /**
  31593. * Gets or sets the position of the debug canvas
  31594. * @ignorenaming
  31595. */
  31596. DEBUGCANVASPOS: {
  31597. x: number;
  31598. y: number;
  31599. };
  31600. /**
  31601. * Gets or sets the debug canvas size
  31602. * @ignorenaming
  31603. */
  31604. DEBUGCANVASSIZE: {
  31605. width: number;
  31606. height: number;
  31607. };
  31608. private _byteFreqs;
  31609. private _byteTime;
  31610. private _floatFreqs;
  31611. private _webAudioAnalyser;
  31612. private _debugCanvas;
  31613. private _debugCanvasContext;
  31614. private _scene;
  31615. private _registerFunc;
  31616. private _audioEngine;
  31617. /**
  31618. * Creates a new analyser
  31619. * @param scene defines hosting scene
  31620. */
  31621. constructor(scene: Scene);
  31622. /**
  31623. * Get the number of data values you will have to play with for the visualization
  31624. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31625. * @returns a number
  31626. */
  31627. getFrequencyBinCount(): number;
  31628. /**
  31629. * Gets the current frequency data as a byte array
  31630. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31631. * @returns a Uint8Array
  31632. */
  31633. getByteFrequencyData(): Uint8Array;
  31634. /**
  31635. * Gets the current waveform as a byte array
  31636. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31637. * @returns a Uint8Array
  31638. */
  31639. getByteTimeDomainData(): Uint8Array;
  31640. /**
  31641. * Gets the current frequency data as a float array
  31642. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31643. * @returns a Float32Array
  31644. */
  31645. getFloatFrequencyData(): Float32Array;
  31646. /**
  31647. * Renders the debug canvas
  31648. */
  31649. drawDebugCanvas(): void;
  31650. /**
  31651. * Stops rendering the debug canvas and removes it
  31652. */
  31653. stopDebugCanvas(): void;
  31654. /**
  31655. * Connects two audio nodes
  31656. * @param inputAudioNode defines first node to connect
  31657. * @param outputAudioNode defines second node to connect
  31658. */
  31659. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31660. /**
  31661. * Releases all associated resources
  31662. */
  31663. dispose(): void;
  31664. }
  31665. }
  31666. declare module "babylonjs/Audio/audioEngine" {
  31667. import { IDisposable } from "babylonjs/scene";
  31668. import { Analyser } from "babylonjs/Audio/analyser";
  31669. import { Nullable } from "babylonjs/types";
  31670. import { Observable } from "babylonjs/Misc/observable";
  31671. /**
  31672. * This represents an audio engine and it is responsible
  31673. * to play, synchronize and analyse sounds throughout the application.
  31674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31675. */
  31676. export interface IAudioEngine extends IDisposable {
  31677. /**
  31678. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31679. */
  31680. readonly canUseWebAudio: boolean;
  31681. /**
  31682. * Gets the current AudioContext if available.
  31683. */
  31684. readonly audioContext: Nullable<AudioContext>;
  31685. /**
  31686. * The master gain node defines the global audio volume of your audio engine.
  31687. */
  31688. readonly masterGain: GainNode;
  31689. /**
  31690. * Gets whether or not mp3 are supported by your browser.
  31691. */
  31692. readonly isMP3supported: boolean;
  31693. /**
  31694. * Gets whether or not ogg are supported by your browser.
  31695. */
  31696. readonly isOGGsupported: boolean;
  31697. /**
  31698. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31699. * @ignoreNaming
  31700. */
  31701. WarnedWebAudioUnsupported: boolean;
  31702. /**
  31703. * Defines if the audio engine relies on a custom unlocked button.
  31704. * In this case, the embedded button will not be displayed.
  31705. */
  31706. useCustomUnlockedButton: boolean;
  31707. /**
  31708. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31709. */
  31710. readonly unlocked: boolean;
  31711. /**
  31712. * Event raised when audio has been unlocked on the browser.
  31713. */
  31714. onAudioUnlockedObservable: Observable<AudioEngine>;
  31715. /**
  31716. * Event raised when audio has been locked on the browser.
  31717. */
  31718. onAudioLockedObservable: Observable<AudioEngine>;
  31719. /**
  31720. * Flags the audio engine in Locked state.
  31721. * This happens due to new browser policies preventing audio to autoplay.
  31722. */
  31723. lock(): void;
  31724. /**
  31725. * Unlocks the audio engine once a user action has been done on the dom.
  31726. * This is helpful to resume play once browser policies have been satisfied.
  31727. */
  31728. unlock(): void;
  31729. }
  31730. /**
  31731. * This represents the default audio engine used in babylon.
  31732. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31734. */
  31735. export class AudioEngine implements IAudioEngine {
  31736. private _audioContext;
  31737. private _audioContextInitialized;
  31738. private _muteButton;
  31739. private _hostElement;
  31740. /**
  31741. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31742. */
  31743. canUseWebAudio: boolean;
  31744. /**
  31745. * The master gain node defines the global audio volume of your audio engine.
  31746. */
  31747. masterGain: GainNode;
  31748. /**
  31749. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31750. * @ignoreNaming
  31751. */
  31752. WarnedWebAudioUnsupported: boolean;
  31753. /**
  31754. * Gets whether or not mp3 are supported by your browser.
  31755. */
  31756. isMP3supported: boolean;
  31757. /**
  31758. * Gets whether or not ogg are supported by your browser.
  31759. */
  31760. isOGGsupported: boolean;
  31761. /**
  31762. * Gets whether audio has been unlocked on the device.
  31763. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31764. * a user interaction has happened.
  31765. */
  31766. unlocked: boolean;
  31767. /**
  31768. * Defines if the audio engine relies on a custom unlocked button.
  31769. * In this case, the embedded button will not be displayed.
  31770. */
  31771. useCustomUnlockedButton: boolean;
  31772. /**
  31773. * Event raised when audio has been unlocked on the browser.
  31774. */
  31775. onAudioUnlockedObservable: Observable<AudioEngine>;
  31776. /**
  31777. * Event raised when audio has been locked on the browser.
  31778. */
  31779. onAudioLockedObservable: Observable<AudioEngine>;
  31780. /**
  31781. * Gets the current AudioContext if available.
  31782. */
  31783. readonly audioContext: Nullable<AudioContext>;
  31784. private _connectedAnalyser;
  31785. /**
  31786. * Instantiates a new audio engine.
  31787. *
  31788. * There should be only one per page as some browsers restrict the number
  31789. * of audio contexts you can create.
  31790. * @param hostElement defines the host element where to display the mute icon if necessary
  31791. */
  31792. constructor(hostElement?: Nullable<HTMLElement>);
  31793. /**
  31794. * Flags the audio engine in Locked state.
  31795. * This happens due to new browser policies preventing audio to autoplay.
  31796. */
  31797. lock(): void;
  31798. /**
  31799. * Unlocks the audio engine once a user action has been done on the dom.
  31800. * This is helpful to resume play once browser policies have been satisfied.
  31801. */
  31802. unlock(): void;
  31803. private _resumeAudioContext;
  31804. private _initializeAudioContext;
  31805. private _tryToRun;
  31806. private _triggerRunningState;
  31807. private _triggerSuspendedState;
  31808. private _displayMuteButton;
  31809. private _moveButtonToTopLeft;
  31810. private _onResize;
  31811. private _hideMuteButton;
  31812. /**
  31813. * Destroy and release the resources associated with the audio ccontext.
  31814. */
  31815. dispose(): void;
  31816. /**
  31817. * Gets the global volume sets on the master gain.
  31818. * @returns the global volume if set or -1 otherwise
  31819. */
  31820. getGlobalVolume(): number;
  31821. /**
  31822. * Sets the global volume of your experience (sets on the master gain).
  31823. * @param newVolume Defines the new global volume of the application
  31824. */
  31825. setGlobalVolume(newVolume: number): void;
  31826. /**
  31827. * Connect the audio engine to an audio analyser allowing some amazing
  31828. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31830. * @param analyser The analyser to connect to the engine
  31831. */
  31832. connectToAnalyser(analyser: Analyser): void;
  31833. }
  31834. }
  31835. declare module "babylonjs/Loading/loadingScreen" {
  31836. /**
  31837. * Interface used to present a loading screen while loading a scene
  31838. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31839. */
  31840. export interface ILoadingScreen {
  31841. /**
  31842. * Function called to display the loading screen
  31843. */
  31844. displayLoadingUI: () => void;
  31845. /**
  31846. * Function called to hide the loading screen
  31847. */
  31848. hideLoadingUI: () => void;
  31849. /**
  31850. * Gets or sets the color to use for the background
  31851. */
  31852. loadingUIBackgroundColor: string;
  31853. /**
  31854. * Gets or sets the text to display while loading
  31855. */
  31856. loadingUIText: string;
  31857. }
  31858. /**
  31859. * Class used for the default loading screen
  31860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31861. */
  31862. export class DefaultLoadingScreen implements ILoadingScreen {
  31863. private _renderingCanvas;
  31864. private _loadingText;
  31865. private _loadingDivBackgroundColor;
  31866. private _loadingDiv;
  31867. private _loadingTextDiv;
  31868. /** Gets or sets the logo url to use for the default loading screen */
  31869. static DefaultLogoUrl: string;
  31870. /** Gets or sets the spinner url to use for the default loading screen */
  31871. static DefaultSpinnerUrl: string;
  31872. /**
  31873. * Creates a new default loading screen
  31874. * @param _renderingCanvas defines the canvas used to render the scene
  31875. * @param _loadingText defines the default text to display
  31876. * @param _loadingDivBackgroundColor defines the default background color
  31877. */
  31878. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31879. /**
  31880. * Function called to display the loading screen
  31881. */
  31882. displayLoadingUI(): void;
  31883. /**
  31884. * Function called to hide the loading screen
  31885. */
  31886. hideLoadingUI(): void;
  31887. /**
  31888. * Gets or sets the text to display while loading
  31889. */
  31890. loadingUIText: string;
  31891. /**
  31892. * Gets or sets the color to use for the background
  31893. */
  31894. loadingUIBackgroundColor: string;
  31895. private _resizeLoadingUI;
  31896. }
  31897. }
  31898. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31899. /**
  31900. * Interface for any object that can request an animation frame
  31901. */
  31902. export interface ICustomAnimationFrameRequester {
  31903. /**
  31904. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31905. */
  31906. renderFunction?: Function;
  31907. /**
  31908. * Called to request the next frame to render to
  31909. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31910. */
  31911. requestAnimationFrame: Function;
  31912. /**
  31913. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31914. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31915. */
  31916. requestID?: number;
  31917. }
  31918. }
  31919. declare module "babylonjs/Misc/performanceMonitor" {
  31920. /**
  31921. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31922. */
  31923. export class PerformanceMonitor {
  31924. private _enabled;
  31925. private _rollingFrameTime;
  31926. private _lastFrameTimeMs;
  31927. /**
  31928. * constructor
  31929. * @param frameSampleSize The number of samples required to saturate the sliding window
  31930. */
  31931. constructor(frameSampleSize?: number);
  31932. /**
  31933. * Samples current frame
  31934. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31935. */
  31936. sampleFrame(timeMs?: number): void;
  31937. /**
  31938. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31939. */
  31940. readonly averageFrameTime: number;
  31941. /**
  31942. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31943. */
  31944. readonly averageFrameTimeVariance: number;
  31945. /**
  31946. * Returns the frame time of the most recent frame
  31947. */
  31948. readonly instantaneousFrameTime: number;
  31949. /**
  31950. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31951. */
  31952. readonly averageFPS: number;
  31953. /**
  31954. * Returns the average framerate in frames per second using the most recent frame time
  31955. */
  31956. readonly instantaneousFPS: number;
  31957. /**
  31958. * Returns true if enough samples have been taken to completely fill the sliding window
  31959. */
  31960. readonly isSaturated: boolean;
  31961. /**
  31962. * Enables contributions to the sliding window sample set
  31963. */
  31964. enable(): void;
  31965. /**
  31966. * Disables contributions to the sliding window sample set
  31967. * Samples will not be interpolated over the disabled period
  31968. */
  31969. disable(): void;
  31970. /**
  31971. * Returns true if sampling is enabled
  31972. */
  31973. readonly isEnabled: boolean;
  31974. /**
  31975. * Resets performance monitor
  31976. */
  31977. reset(): void;
  31978. }
  31979. /**
  31980. * RollingAverage
  31981. *
  31982. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31983. */
  31984. export class RollingAverage {
  31985. /**
  31986. * Current average
  31987. */
  31988. average: number;
  31989. /**
  31990. * Current variance
  31991. */
  31992. variance: number;
  31993. protected _samples: Array<number>;
  31994. protected _sampleCount: number;
  31995. protected _pos: number;
  31996. protected _m2: number;
  31997. /**
  31998. * constructor
  31999. * @param length The number of samples required to saturate the sliding window
  32000. */
  32001. constructor(length: number);
  32002. /**
  32003. * Adds a sample to the sample set
  32004. * @param v The sample value
  32005. */
  32006. add(v: number): void;
  32007. /**
  32008. * Returns previously added values or null if outside of history or outside the sliding window domain
  32009. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32010. * @return Value previously recorded with add() or null if outside of range
  32011. */
  32012. history(i: number): number;
  32013. /**
  32014. * Returns true if enough samples have been taken to completely fill the sliding window
  32015. * @return true if sample-set saturated
  32016. */
  32017. isSaturated(): boolean;
  32018. /**
  32019. * Resets the rolling average (equivalent to 0 samples taken so far)
  32020. */
  32021. reset(): void;
  32022. /**
  32023. * Wraps a value around the sample range boundaries
  32024. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32025. * @return Wrapped position in sample range
  32026. */
  32027. protected _wrapPosition(i: number): number;
  32028. }
  32029. }
  32030. declare module "babylonjs/Misc/perfCounter" {
  32031. /**
  32032. * This class is used to track a performance counter which is number based.
  32033. * The user has access to many properties which give statistics of different nature.
  32034. *
  32035. * The implementer can track two kinds of Performance Counter: time and count.
  32036. * 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.
  32037. * 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.
  32038. */
  32039. export class PerfCounter {
  32040. /**
  32041. * Gets or sets a global boolean to turn on and off all the counters
  32042. */
  32043. static Enabled: boolean;
  32044. /**
  32045. * Returns the smallest value ever
  32046. */
  32047. readonly min: number;
  32048. /**
  32049. * Returns the biggest value ever
  32050. */
  32051. readonly max: number;
  32052. /**
  32053. * Returns the average value since the performance counter is running
  32054. */
  32055. readonly average: number;
  32056. /**
  32057. * Returns the average value of the last second the counter was monitored
  32058. */
  32059. readonly lastSecAverage: number;
  32060. /**
  32061. * Returns the current value
  32062. */
  32063. readonly current: number;
  32064. /**
  32065. * Gets the accumulated total
  32066. */
  32067. readonly total: number;
  32068. /**
  32069. * Gets the total value count
  32070. */
  32071. readonly count: number;
  32072. /**
  32073. * Creates a new counter
  32074. */
  32075. constructor();
  32076. /**
  32077. * Call this method to start monitoring a new frame.
  32078. * 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.
  32079. */
  32080. fetchNewFrame(): void;
  32081. /**
  32082. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32083. * @param newCount the count value to add to the monitored count
  32084. * @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.
  32085. */
  32086. addCount(newCount: number, fetchResult: boolean): void;
  32087. /**
  32088. * Start monitoring this performance counter
  32089. */
  32090. beginMonitoring(): void;
  32091. /**
  32092. * Compute the time lapsed since the previous beginMonitoring() call.
  32093. * @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
  32094. */
  32095. endMonitoring(newFrame?: boolean): void;
  32096. private _fetchResult;
  32097. private _startMonitoringTime;
  32098. private _min;
  32099. private _max;
  32100. private _average;
  32101. private _current;
  32102. private _totalValueCount;
  32103. private _totalAccumulated;
  32104. private _lastSecAverage;
  32105. private _lastSecAccumulated;
  32106. private _lastSecTime;
  32107. private _lastSecValueCount;
  32108. }
  32109. }
  32110. declare module "babylonjs/Engines/engine" {
  32111. import { Observable } from "babylonjs/Misc/observable";
  32112. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32113. import { Scene } from "babylonjs/scene";
  32114. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32115. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32116. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32117. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32118. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32119. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32120. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32121. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32122. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32123. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32124. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32125. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32126. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32127. import { Material } from "babylonjs/Materials/material";
  32128. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32129. /**
  32130. * Defines the interface used by display changed events
  32131. */
  32132. export interface IDisplayChangedEventArgs {
  32133. /** Gets the vrDisplay object (if any) */
  32134. vrDisplay: Nullable<any>;
  32135. /** Gets a boolean indicating if webVR is supported */
  32136. vrSupported: boolean;
  32137. }
  32138. /**
  32139. * Defines the interface used by objects containing a viewport (like a camera)
  32140. */
  32141. interface IViewportOwnerLike {
  32142. /**
  32143. * Gets or sets the viewport
  32144. */
  32145. viewport: IViewportLike;
  32146. }
  32147. /**
  32148. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32149. */
  32150. export class Engine extends ThinEngine {
  32151. /** Defines that alpha blending is disabled */
  32152. static readonly ALPHA_DISABLE: number;
  32153. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32154. static readonly ALPHA_ADD: number;
  32155. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32156. static readonly ALPHA_COMBINE: number;
  32157. /** Defines that alpha blending to DEST - SRC * DEST */
  32158. static readonly ALPHA_SUBTRACT: number;
  32159. /** Defines that alpha blending to SRC * DEST */
  32160. static readonly ALPHA_MULTIPLY: number;
  32161. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32162. static readonly ALPHA_MAXIMIZED: number;
  32163. /** Defines that alpha blending to SRC + DEST */
  32164. static readonly ALPHA_ONEONE: number;
  32165. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32166. static readonly ALPHA_PREMULTIPLIED: number;
  32167. /**
  32168. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32169. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32170. */
  32171. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32172. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32173. static readonly ALPHA_INTERPOLATE: number;
  32174. /**
  32175. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32176. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32177. */
  32178. static readonly ALPHA_SCREENMODE: number;
  32179. /** Defines that the ressource is not delayed*/
  32180. static readonly DELAYLOADSTATE_NONE: number;
  32181. /** Defines that the ressource was successfully delay loaded */
  32182. static readonly DELAYLOADSTATE_LOADED: number;
  32183. /** Defines that the ressource is currently delay loading */
  32184. static readonly DELAYLOADSTATE_LOADING: number;
  32185. /** Defines that the ressource is delayed and has not started loading */
  32186. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32187. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32188. static readonly NEVER: number;
  32189. /** 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 */
  32190. static readonly ALWAYS: number;
  32191. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32192. static readonly LESS: number;
  32193. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32194. static readonly EQUAL: number;
  32195. /** 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 */
  32196. static readonly LEQUAL: number;
  32197. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32198. static readonly GREATER: number;
  32199. /** 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 */
  32200. static readonly GEQUAL: number;
  32201. /** 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 */
  32202. static readonly NOTEQUAL: number;
  32203. /** Passed to stencilOperation to specify that stencil value must be kept */
  32204. static readonly KEEP: number;
  32205. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32206. static readonly REPLACE: number;
  32207. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32208. static readonly INCR: number;
  32209. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32210. static readonly DECR: number;
  32211. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32212. static readonly INVERT: number;
  32213. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32214. static readonly INCR_WRAP: number;
  32215. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32216. static readonly DECR_WRAP: number;
  32217. /** Texture is not repeating outside of 0..1 UVs */
  32218. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32219. /** Texture is repeating outside of 0..1 UVs */
  32220. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32221. /** Texture is repeating and mirrored */
  32222. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32223. /** ALPHA */
  32224. static readonly TEXTUREFORMAT_ALPHA: number;
  32225. /** LUMINANCE */
  32226. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32227. /** LUMINANCE_ALPHA */
  32228. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32229. /** RGB */
  32230. static readonly TEXTUREFORMAT_RGB: number;
  32231. /** RGBA */
  32232. static readonly TEXTUREFORMAT_RGBA: number;
  32233. /** RED */
  32234. static readonly TEXTUREFORMAT_RED: number;
  32235. /** RED (2nd reference) */
  32236. static readonly TEXTUREFORMAT_R: number;
  32237. /** RG */
  32238. static readonly TEXTUREFORMAT_RG: number;
  32239. /** RED_INTEGER */
  32240. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32241. /** RED_INTEGER (2nd reference) */
  32242. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32243. /** RG_INTEGER */
  32244. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32245. /** RGB_INTEGER */
  32246. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32247. /** RGBA_INTEGER */
  32248. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32249. /** UNSIGNED_BYTE */
  32250. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32251. /** UNSIGNED_BYTE (2nd reference) */
  32252. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32253. /** FLOAT */
  32254. static readonly TEXTURETYPE_FLOAT: number;
  32255. /** HALF_FLOAT */
  32256. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32257. /** BYTE */
  32258. static readonly TEXTURETYPE_BYTE: number;
  32259. /** SHORT */
  32260. static readonly TEXTURETYPE_SHORT: number;
  32261. /** UNSIGNED_SHORT */
  32262. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32263. /** INT */
  32264. static readonly TEXTURETYPE_INT: number;
  32265. /** UNSIGNED_INT */
  32266. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32267. /** UNSIGNED_SHORT_4_4_4_4 */
  32268. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32269. /** UNSIGNED_SHORT_5_5_5_1 */
  32270. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32271. /** UNSIGNED_SHORT_5_6_5 */
  32272. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32273. /** UNSIGNED_INT_2_10_10_10_REV */
  32274. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32275. /** UNSIGNED_INT_24_8 */
  32276. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32277. /** UNSIGNED_INT_10F_11F_11F_REV */
  32278. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32279. /** UNSIGNED_INT_5_9_9_9_REV */
  32280. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32281. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32282. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32283. /** nearest is mag = nearest and min = nearest and mip = linear */
  32284. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32285. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32286. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32287. /** Trilinear is mag = linear and min = linear and mip = linear */
  32288. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32289. /** nearest is mag = nearest and min = nearest and mip = linear */
  32290. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32291. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32292. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32293. /** Trilinear is mag = linear and min = linear and mip = linear */
  32294. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32295. /** mag = nearest and min = nearest and mip = nearest */
  32296. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32297. /** mag = nearest and min = linear and mip = nearest */
  32298. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32299. /** mag = nearest and min = linear and mip = linear */
  32300. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32301. /** mag = nearest and min = linear and mip = none */
  32302. static readonly TEXTURE_NEAREST_LINEAR: number;
  32303. /** mag = nearest and min = nearest and mip = none */
  32304. static readonly TEXTURE_NEAREST_NEAREST: number;
  32305. /** mag = linear and min = nearest and mip = nearest */
  32306. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32307. /** mag = linear and min = nearest and mip = linear */
  32308. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32309. /** mag = linear and min = linear and mip = none */
  32310. static readonly TEXTURE_LINEAR_LINEAR: number;
  32311. /** mag = linear and min = nearest and mip = none */
  32312. static readonly TEXTURE_LINEAR_NEAREST: number;
  32313. /** Explicit coordinates mode */
  32314. static readonly TEXTURE_EXPLICIT_MODE: number;
  32315. /** Spherical coordinates mode */
  32316. static readonly TEXTURE_SPHERICAL_MODE: number;
  32317. /** Planar coordinates mode */
  32318. static readonly TEXTURE_PLANAR_MODE: number;
  32319. /** Cubic coordinates mode */
  32320. static readonly TEXTURE_CUBIC_MODE: number;
  32321. /** Projection coordinates mode */
  32322. static readonly TEXTURE_PROJECTION_MODE: number;
  32323. /** Skybox coordinates mode */
  32324. static readonly TEXTURE_SKYBOX_MODE: number;
  32325. /** Inverse Cubic coordinates mode */
  32326. static readonly TEXTURE_INVCUBIC_MODE: number;
  32327. /** Equirectangular coordinates mode */
  32328. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32329. /** Equirectangular Fixed coordinates mode */
  32330. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32331. /** Equirectangular Fixed Mirrored coordinates mode */
  32332. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32333. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32334. static readonly SCALEMODE_FLOOR: number;
  32335. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32336. static readonly SCALEMODE_NEAREST: number;
  32337. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32338. static readonly SCALEMODE_CEILING: number;
  32339. /**
  32340. * Returns the current npm package of the sdk
  32341. */
  32342. static readonly NpmPackage: string;
  32343. /**
  32344. * Returns the current version of the framework
  32345. */
  32346. static readonly Version: string;
  32347. /** Gets the list of created engines */
  32348. static readonly Instances: Engine[];
  32349. /**
  32350. * Gets the latest created engine
  32351. */
  32352. static readonly LastCreatedEngine: Nullable<Engine>;
  32353. /**
  32354. * Gets the latest created scene
  32355. */
  32356. static readonly LastCreatedScene: Nullable<Scene>;
  32357. /**
  32358. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32359. * @param flag defines which part of the materials must be marked as dirty
  32360. * @param predicate defines a predicate used to filter which materials should be affected
  32361. */
  32362. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32363. /**
  32364. * Method called to create the default loading screen.
  32365. * This can be overriden in your own app.
  32366. * @param canvas The rendering canvas element
  32367. * @returns The loading screen
  32368. */
  32369. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32370. /**
  32371. * Method called to create the default rescale post process on each engine.
  32372. */
  32373. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32374. /**
  32375. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32376. **/
  32377. enableOfflineSupport: boolean;
  32378. /**
  32379. * 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)
  32380. **/
  32381. disableManifestCheck: boolean;
  32382. /**
  32383. * Gets the list of created scenes
  32384. */
  32385. scenes: Scene[];
  32386. /**
  32387. * Event raised when a new scene is created
  32388. */
  32389. onNewSceneAddedObservable: Observable<Scene>;
  32390. /**
  32391. * Gets the list of created postprocesses
  32392. */
  32393. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32394. /**
  32395. * Gets a boolean indicating if the pointer is currently locked
  32396. */
  32397. isPointerLock: boolean;
  32398. /**
  32399. * Observable event triggered each time the rendering canvas is resized
  32400. */
  32401. onResizeObservable: Observable<Engine>;
  32402. /**
  32403. * Observable event triggered each time the canvas loses focus
  32404. */
  32405. onCanvasBlurObservable: Observable<Engine>;
  32406. /**
  32407. * Observable event triggered each time the canvas gains focus
  32408. */
  32409. onCanvasFocusObservable: Observable<Engine>;
  32410. /**
  32411. * Observable event triggered each time the canvas receives pointerout event
  32412. */
  32413. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32414. /**
  32415. * Observable raised when the engine begins a new frame
  32416. */
  32417. onBeginFrameObservable: Observable<Engine>;
  32418. /**
  32419. * If set, will be used to request the next animation frame for the render loop
  32420. */
  32421. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32422. /**
  32423. * Observable raised when the engine ends the current frame
  32424. */
  32425. onEndFrameObservable: Observable<Engine>;
  32426. /**
  32427. * Observable raised when the engine is about to compile a shader
  32428. */
  32429. onBeforeShaderCompilationObservable: Observable<Engine>;
  32430. /**
  32431. * Observable raised when the engine has jsut compiled a shader
  32432. */
  32433. onAfterShaderCompilationObservable: Observable<Engine>;
  32434. /**
  32435. * Gets the audio engine
  32436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32437. * @ignorenaming
  32438. */
  32439. static audioEngine: IAudioEngine;
  32440. /**
  32441. * Default AudioEngine factory responsible of creating the Audio Engine.
  32442. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32443. */
  32444. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32445. /**
  32446. * Default offline support factory responsible of creating a tool used to store data locally.
  32447. * By default, this will create a Database object if the workload has been embedded.
  32448. */
  32449. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32450. private _loadingScreen;
  32451. private _pointerLockRequested;
  32452. private _dummyFramebuffer;
  32453. private _rescalePostProcess;
  32454. /** @hidden */
  32455. protected _alphaMode: number;
  32456. /** @hidden */
  32457. protected _alphaEquation: number;
  32458. private _deterministicLockstep;
  32459. private _lockstepMaxSteps;
  32460. protected readonly _supportsHardwareTextureRescaling: boolean;
  32461. private _fps;
  32462. private _deltaTime;
  32463. /** @hidden */
  32464. _drawCalls: PerfCounter;
  32465. /**
  32466. * Turn this value on if you want to pause FPS computation when in background
  32467. */
  32468. disablePerformanceMonitorInBackground: boolean;
  32469. private _performanceMonitor;
  32470. /**
  32471. * Gets the performance monitor attached to this engine
  32472. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32473. */
  32474. readonly performanceMonitor: PerformanceMonitor;
  32475. private _onFocus;
  32476. private _onBlur;
  32477. private _onCanvasPointerOut;
  32478. private _onCanvasBlur;
  32479. private _onCanvasFocus;
  32480. private _onFullscreenChange;
  32481. private _onPointerLockChange;
  32482. /**
  32483. * Gets the HTML element used to attach event listeners
  32484. * @returns a HTML element
  32485. */
  32486. getInputElement(): Nullable<HTMLElement>;
  32487. /**
  32488. * Creates a new engine
  32489. * @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
  32490. * @param antialias defines enable antialiasing (default: false)
  32491. * @param options defines further options to be sent to the getContext() function
  32492. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32493. */
  32494. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32495. /**
  32496. * Gets current aspect ratio
  32497. * @param viewportOwner defines the camera to use to get the aspect ratio
  32498. * @param useScreen defines if screen size must be used (or the current render target if any)
  32499. * @returns a number defining the aspect ratio
  32500. */
  32501. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32502. /**
  32503. * Gets current screen aspect ratio
  32504. * @returns a number defining the aspect ratio
  32505. */
  32506. getScreenAspectRatio(): number;
  32507. /**
  32508. * Gets host document
  32509. * @returns the host document object
  32510. */
  32511. getHostDocument(): Document;
  32512. /**
  32513. * Gets the client rect of the HTML canvas attached with the current webGL context
  32514. * @returns a client rectanglee
  32515. */
  32516. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32517. /**
  32518. * Gets the client rect of the HTML element used for events
  32519. * @returns a client rectanglee
  32520. */
  32521. getInputElementClientRect(): Nullable<ClientRect>;
  32522. /**
  32523. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32525. * @returns true if engine is in deterministic lock step mode
  32526. */
  32527. isDeterministicLockStep(): boolean;
  32528. /**
  32529. * Gets the max steps when engine is running in deterministic lock step
  32530. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32531. * @returns the max steps
  32532. */
  32533. getLockstepMaxSteps(): number;
  32534. /**
  32535. * Force the mipmap generation for the given render target texture
  32536. * @param texture defines the render target texture to use
  32537. */
  32538. generateMipMapsForCubemap(texture: InternalTexture): void;
  32539. /** States */
  32540. /**
  32541. * Set various states to the webGL context
  32542. * @param culling defines backface culling state
  32543. * @param zOffset defines the value to apply to zOffset (0 by default)
  32544. * @param force defines if states must be applied even if cache is up to date
  32545. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32546. */
  32547. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32548. /**
  32549. * Set the z offset to apply to current rendering
  32550. * @param value defines the offset to apply
  32551. */
  32552. setZOffset(value: number): void;
  32553. /**
  32554. * Gets the current value of the zOffset
  32555. * @returns the current zOffset state
  32556. */
  32557. getZOffset(): number;
  32558. /**
  32559. * Enable or disable depth buffering
  32560. * @param enable defines the state to set
  32561. */
  32562. setDepthBuffer(enable: boolean): void;
  32563. /**
  32564. * Gets a boolean indicating if depth writing is enabled
  32565. * @returns the current depth writing state
  32566. */
  32567. getDepthWrite(): boolean;
  32568. /**
  32569. * Enable or disable depth writing
  32570. * @param enable defines the state to set
  32571. */
  32572. setDepthWrite(enable: boolean): void;
  32573. /**
  32574. * Enable or disable color writing
  32575. * @param enable defines the state to set
  32576. */
  32577. setColorWrite(enable: boolean): void;
  32578. /**
  32579. * Gets a boolean indicating if color writing is enabled
  32580. * @returns the current color writing state
  32581. */
  32582. getColorWrite(): boolean;
  32583. /**
  32584. * Sets alpha constants used by some alpha blending modes
  32585. * @param r defines the red component
  32586. * @param g defines the green component
  32587. * @param b defines the blue component
  32588. * @param a defines the alpha component
  32589. */
  32590. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32591. /**
  32592. * Sets the current alpha mode
  32593. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32594. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32595. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32596. */
  32597. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32598. /**
  32599. * Gets the current alpha mode
  32600. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32601. * @returns the current alpha mode
  32602. */
  32603. getAlphaMode(): number;
  32604. /**
  32605. * Sets the current alpha equation
  32606. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32607. */
  32608. setAlphaEquation(equation: number): void;
  32609. /**
  32610. * Gets the current alpha equation.
  32611. * @returns the current alpha equation
  32612. */
  32613. getAlphaEquation(): number;
  32614. /**
  32615. * Gets a boolean indicating if stencil buffer is enabled
  32616. * @returns the current stencil buffer state
  32617. */
  32618. getStencilBuffer(): boolean;
  32619. /**
  32620. * Enable or disable the stencil buffer
  32621. * @param enable defines if the stencil buffer must be enabled or disabled
  32622. */
  32623. setStencilBuffer(enable: boolean): void;
  32624. /**
  32625. * Gets the current stencil mask
  32626. * @returns a number defining the new stencil mask to use
  32627. */
  32628. getStencilMask(): number;
  32629. /**
  32630. * Sets the current stencil mask
  32631. * @param mask defines the new stencil mask to use
  32632. */
  32633. setStencilMask(mask: number): void;
  32634. /**
  32635. * Gets the current stencil function
  32636. * @returns a number defining the stencil function to use
  32637. */
  32638. getStencilFunction(): number;
  32639. /**
  32640. * Gets the current stencil reference value
  32641. * @returns a number defining the stencil reference value to use
  32642. */
  32643. getStencilFunctionReference(): number;
  32644. /**
  32645. * Gets the current stencil mask
  32646. * @returns a number defining the stencil mask to use
  32647. */
  32648. getStencilFunctionMask(): number;
  32649. /**
  32650. * Sets the current stencil function
  32651. * @param stencilFunc defines the new stencil function to use
  32652. */
  32653. setStencilFunction(stencilFunc: number): void;
  32654. /**
  32655. * Sets the current stencil reference
  32656. * @param reference defines the new stencil reference to use
  32657. */
  32658. setStencilFunctionReference(reference: number): void;
  32659. /**
  32660. * Sets the current stencil mask
  32661. * @param mask defines the new stencil mask to use
  32662. */
  32663. setStencilFunctionMask(mask: number): void;
  32664. /**
  32665. * Gets the current stencil operation when stencil fails
  32666. * @returns a number defining stencil operation to use when stencil fails
  32667. */
  32668. getStencilOperationFail(): number;
  32669. /**
  32670. * Gets the current stencil operation when depth fails
  32671. * @returns a number defining stencil operation to use when depth fails
  32672. */
  32673. getStencilOperationDepthFail(): number;
  32674. /**
  32675. * Gets the current stencil operation when stencil passes
  32676. * @returns a number defining stencil operation to use when stencil passes
  32677. */
  32678. getStencilOperationPass(): number;
  32679. /**
  32680. * Sets the stencil operation to use when stencil fails
  32681. * @param operation defines the stencil operation to use when stencil fails
  32682. */
  32683. setStencilOperationFail(operation: number): void;
  32684. /**
  32685. * Sets the stencil operation to use when depth fails
  32686. * @param operation defines the stencil operation to use when depth fails
  32687. */
  32688. setStencilOperationDepthFail(operation: number): void;
  32689. /**
  32690. * Sets the stencil operation to use when stencil passes
  32691. * @param operation defines the stencil operation to use when stencil passes
  32692. */
  32693. setStencilOperationPass(operation: number): void;
  32694. /**
  32695. * Sets a boolean indicating if the dithering state is enabled or disabled
  32696. * @param value defines the dithering state
  32697. */
  32698. setDitheringState(value: boolean): void;
  32699. /**
  32700. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32701. * @param value defines the rasterizer state
  32702. */
  32703. setRasterizerState(value: boolean): void;
  32704. /**
  32705. * Gets the current depth function
  32706. * @returns a number defining the depth function
  32707. */
  32708. getDepthFunction(): Nullable<number>;
  32709. /**
  32710. * Sets the current depth function
  32711. * @param depthFunc defines the function to use
  32712. */
  32713. setDepthFunction(depthFunc: number): void;
  32714. /**
  32715. * Sets the current depth function to GREATER
  32716. */
  32717. setDepthFunctionToGreater(): void;
  32718. /**
  32719. * Sets the current depth function to GEQUAL
  32720. */
  32721. setDepthFunctionToGreaterOrEqual(): void;
  32722. /**
  32723. * Sets the current depth function to LESS
  32724. */
  32725. setDepthFunctionToLess(): void;
  32726. /**
  32727. * Sets the current depth function to LEQUAL
  32728. */
  32729. setDepthFunctionToLessOrEqual(): void;
  32730. private _cachedStencilBuffer;
  32731. private _cachedStencilFunction;
  32732. private _cachedStencilMask;
  32733. private _cachedStencilOperationPass;
  32734. private _cachedStencilOperationFail;
  32735. private _cachedStencilOperationDepthFail;
  32736. private _cachedStencilReference;
  32737. /**
  32738. * Caches the the state of the stencil buffer
  32739. */
  32740. cacheStencilState(): void;
  32741. /**
  32742. * Restores the state of the stencil buffer
  32743. */
  32744. restoreStencilState(): void;
  32745. /**
  32746. * Directly set the WebGL Viewport
  32747. * @param x defines the x coordinate of the viewport (in screen space)
  32748. * @param y defines the y coordinate of the viewport (in screen space)
  32749. * @param width defines the width of the viewport (in screen space)
  32750. * @param height defines the height of the viewport (in screen space)
  32751. * @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
  32752. */
  32753. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32754. /**
  32755. * Executes a scissor clear (ie. a clear 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. * @param clearColor defines the clear color
  32761. */
  32762. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32763. /**
  32764. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32765. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32766. * @param y defines the y-coordinate of the corner of the clear rectangle
  32767. * @param width defines the width of the clear rectangle
  32768. * @param height defines the height of the clear rectangle
  32769. */
  32770. enableScissor(x: number, y: number, width: number, height: number): void;
  32771. /**
  32772. * Disable previously set scissor test rectangle
  32773. */
  32774. disableScissor(): void;
  32775. protected _reportDrawCall(): void;
  32776. /**
  32777. * Initializes a webVR display and starts listening to display change events
  32778. * The onVRDisplayChangedObservable will be notified upon these changes
  32779. * @returns The onVRDisplayChangedObservable
  32780. */
  32781. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32782. /** @hidden */
  32783. _prepareVRComponent(): void;
  32784. /** @hidden */
  32785. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32786. /** @hidden */
  32787. _submitVRFrame(): void;
  32788. /**
  32789. * Call this function to leave webVR mode
  32790. * Will do nothing if webVR is not supported or if there is no webVR device
  32791. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32792. */
  32793. disableVR(): void;
  32794. /**
  32795. * Gets a boolean indicating that the system is in VR mode and is presenting
  32796. * @returns true if VR mode is engaged
  32797. */
  32798. isVRPresenting(): boolean;
  32799. /** @hidden */
  32800. _requestVRFrame(): void;
  32801. /** @hidden */
  32802. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32803. /**
  32804. * Gets the source code of the vertex shader associated with a specific webGL program
  32805. * @param program defines the program to use
  32806. * @returns a string containing the source code of the vertex shader associated with the program
  32807. */
  32808. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32809. /**
  32810. * Gets the source code of the fragment shader associated with a specific webGL program
  32811. * @param program defines the program to use
  32812. * @returns a string containing the source code of the fragment shader associated with the program
  32813. */
  32814. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32815. /**
  32816. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32817. * @param x defines the x coordinate of the rectangle where pixels must be read
  32818. * @param y defines the y coordinate of the rectangle where pixels must be read
  32819. * @param width defines the width of the rectangle where pixels must be read
  32820. * @param height defines the height of the rectangle where pixels must be read
  32821. * @returns a Uint8Array containing RGBA colors
  32822. */
  32823. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32824. /**
  32825. * Sets a depth stencil texture from a render target to the according uniform.
  32826. * @param channel The texture channel
  32827. * @param uniform The uniform to set
  32828. * @param texture The render target texture containing the depth stencil texture to apply
  32829. */
  32830. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32831. /**
  32832. * Sets a texture to the webGL context from a postprocess
  32833. * @param channel defines the channel to use
  32834. * @param postProcess defines the source postprocess
  32835. */
  32836. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32837. /**
  32838. * Binds the output of the passed in post process to the texture channel specified
  32839. * @param channel The channel the texture should be bound to
  32840. * @param postProcess The post process which's output should be bound
  32841. */
  32842. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32843. /** @hidden */
  32844. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32845. protected _rebuildBuffers(): void;
  32846. /** @hidden */
  32847. _renderFrame(): void;
  32848. _renderLoop(): void;
  32849. /** @hidden */
  32850. _renderViews(): boolean;
  32851. /**
  32852. * Toggle full screen mode
  32853. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32854. */
  32855. switchFullscreen(requestPointerLock: boolean): void;
  32856. /**
  32857. * Enters full screen mode
  32858. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32859. */
  32860. enterFullscreen(requestPointerLock: boolean): void;
  32861. /**
  32862. * Exits full screen mode
  32863. */
  32864. exitFullscreen(): void;
  32865. /**
  32866. * Enters Pointerlock mode
  32867. */
  32868. enterPointerlock(): void;
  32869. /**
  32870. * Exits Pointerlock mode
  32871. */
  32872. exitPointerlock(): void;
  32873. /**
  32874. * Begin a new frame
  32875. */
  32876. beginFrame(): void;
  32877. /**
  32878. * Enf the current frame
  32879. */
  32880. endFrame(): void;
  32881. resize(): void;
  32882. /**
  32883. * Set the compressed texture format to use, based on the formats you have, and the formats
  32884. * supported by the hardware / browser.
  32885. *
  32886. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32887. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32888. * to API arguments needed to compressed textures. This puts the burden on the container
  32889. * generator to house the arcane code for determining these for current & future formats.
  32890. *
  32891. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32892. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32893. *
  32894. * Note: The result of this call is not taken into account when a texture is base64.
  32895. *
  32896. * @param formatsAvailable defines the list of those format families you have created
  32897. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32898. *
  32899. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32900. * @returns The extension selected.
  32901. */
  32902. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32903. /**
  32904. * Force a specific size of the canvas
  32905. * @param width defines the new canvas' width
  32906. * @param height defines the new canvas' height
  32907. */
  32908. setSize(width: number, height: number): void;
  32909. /**
  32910. * Updates a dynamic vertex buffer.
  32911. * @param vertexBuffer the vertex buffer to update
  32912. * @param data the data used to update the vertex buffer
  32913. * @param byteOffset the byte offset of the data
  32914. * @param byteLength the byte length of the data
  32915. */
  32916. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32917. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32918. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32919. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32920. _releaseTexture(texture: InternalTexture): void;
  32921. /**
  32922. * @hidden
  32923. * Rescales a texture
  32924. * @param source input texutre
  32925. * @param destination destination texture
  32926. * @param scene scene to use to render the resize
  32927. * @param internalFormat format to use when resizing
  32928. * @param onComplete callback to be called when resize has completed
  32929. */
  32930. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32931. /**
  32932. * Gets the current framerate
  32933. * @returns a number representing the framerate
  32934. */
  32935. getFps(): number;
  32936. /**
  32937. * Gets the time spent between current and previous frame
  32938. * @returns a number representing the delta time in ms
  32939. */
  32940. getDeltaTime(): number;
  32941. private _measureFps;
  32942. /** @hidden */
  32943. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32944. /**
  32945. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32946. * @param renderTarget The render target to set the frame buffer for
  32947. */
  32948. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32949. /**
  32950. * Update a dynamic index buffer
  32951. * @param indexBuffer defines the target index buffer
  32952. * @param indices defines the data to update
  32953. * @param offset defines the offset in the target index buffer where update should start
  32954. */
  32955. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32956. /**
  32957. * Updates the sample count of a render target texture
  32958. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32959. * @param texture defines the texture to update
  32960. * @param samples defines the sample count to set
  32961. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32962. */
  32963. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32964. /**
  32965. * Updates a depth texture Comparison Mode and Function.
  32966. * If the comparison Function is equal to 0, the mode will be set to none.
  32967. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32968. * @param texture The texture to set the comparison function for
  32969. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32970. */
  32971. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32972. /**
  32973. * Creates a webGL buffer to use with instanciation
  32974. * @param capacity defines the size of the buffer
  32975. * @returns the webGL buffer
  32976. */
  32977. createInstancesBuffer(capacity: number): DataBuffer;
  32978. /**
  32979. * Delete a webGL buffer used with instanciation
  32980. * @param buffer defines the webGL buffer to delete
  32981. */
  32982. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32983. /** @hidden */
  32984. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32985. dispose(): void;
  32986. private _disableTouchAction;
  32987. /**
  32988. * Display the loading screen
  32989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32990. */
  32991. displayLoadingUI(): void;
  32992. /**
  32993. * Hide the loading screen
  32994. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32995. */
  32996. hideLoadingUI(): void;
  32997. /**
  32998. * Gets the current loading screen object
  32999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33000. */
  33001. /**
  33002. * Sets the current loading screen object
  33003. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33004. */
  33005. loadingScreen: ILoadingScreen;
  33006. /**
  33007. * Sets the current loading screen text
  33008. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33009. */
  33010. loadingUIText: string;
  33011. /**
  33012. * Sets the current loading screen background color
  33013. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33014. */
  33015. loadingUIBackgroundColor: string;
  33016. /** Pointerlock and fullscreen */
  33017. /**
  33018. * Ask the browser to promote the current element to pointerlock mode
  33019. * @param element defines the DOM element to promote
  33020. */
  33021. static _RequestPointerlock(element: HTMLElement): void;
  33022. /**
  33023. * Asks the browser to exit pointerlock mode
  33024. */
  33025. static _ExitPointerlock(): void;
  33026. /**
  33027. * Ask the browser to promote the current element to fullscreen rendering mode
  33028. * @param element defines the DOM element to promote
  33029. */
  33030. static _RequestFullscreen(element: HTMLElement): void;
  33031. /**
  33032. * Asks the browser to exit fullscreen mode
  33033. */
  33034. static _ExitFullscreen(): void;
  33035. }
  33036. }
  33037. declare module "babylonjs/Engines/engineStore" {
  33038. import { Nullable } from "babylonjs/types";
  33039. import { Engine } from "babylonjs/Engines/engine";
  33040. import { Scene } from "babylonjs/scene";
  33041. /**
  33042. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33043. * during the life time of the application.
  33044. */
  33045. export class EngineStore {
  33046. /** Gets the list of created engines */
  33047. static Instances: import("babylonjs/Engines/engine").Engine[];
  33048. /** @hidden */
  33049. static _LastCreatedScene: Nullable<Scene>;
  33050. /**
  33051. * Gets the latest created engine
  33052. */
  33053. static readonly LastCreatedEngine: Nullable<Engine>;
  33054. /**
  33055. * Gets the latest created scene
  33056. */
  33057. static readonly LastCreatedScene: Nullable<Scene>;
  33058. /**
  33059. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33060. * @ignorenaming
  33061. */
  33062. static UseFallbackTexture: boolean;
  33063. /**
  33064. * Texture content used if a texture cannot loaded
  33065. * @ignorenaming
  33066. */
  33067. static FallbackTexture: string;
  33068. }
  33069. }
  33070. declare module "babylonjs/Misc/promise" {
  33071. /**
  33072. * Helper class that provides a small promise polyfill
  33073. */
  33074. export class PromisePolyfill {
  33075. /**
  33076. * Static function used to check if the polyfill is required
  33077. * If this is the case then the function will inject the polyfill to window.Promise
  33078. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33079. */
  33080. static Apply(force?: boolean): void;
  33081. }
  33082. }
  33083. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33084. /**
  33085. * Interface for screenshot methods with describe argument called `size` as object with options
  33086. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33087. */
  33088. export interface IScreenshotSize {
  33089. /**
  33090. * number in pixels for canvas height
  33091. */
  33092. height?: number;
  33093. /**
  33094. * multiplier allowing render at a higher or lower resolution
  33095. * If value is defined then height and width will be ignored and taken from camera
  33096. */
  33097. precision?: number;
  33098. /**
  33099. * number in pixels for canvas width
  33100. */
  33101. width?: number;
  33102. }
  33103. }
  33104. declare module "babylonjs/Misc/tools" {
  33105. import { Nullable, float } from "babylonjs/types";
  33106. import { DomManagement } from "babylonjs/Misc/domManagement";
  33107. import { WebRequest } from "babylonjs/Misc/webRequest";
  33108. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33109. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33110. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33111. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33112. import { Camera } from "babylonjs/Cameras/camera";
  33113. import { Engine } from "babylonjs/Engines/engine";
  33114. interface IColor4Like {
  33115. r: float;
  33116. g: float;
  33117. b: float;
  33118. a: float;
  33119. }
  33120. /**
  33121. * Class containing a set of static utilities functions
  33122. */
  33123. export class Tools {
  33124. /**
  33125. * Gets or sets the base URL to use to load assets
  33126. */
  33127. static BaseUrl: string;
  33128. /**
  33129. * Enable/Disable Custom HTTP Request Headers globally.
  33130. * default = false
  33131. * @see CustomRequestHeaders
  33132. */
  33133. static UseCustomRequestHeaders: boolean;
  33134. /**
  33135. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33136. * i.e. when loading files, where the server/service expects an Authorization header
  33137. */
  33138. static CustomRequestHeaders: {
  33139. [key: string]: string;
  33140. };
  33141. /**
  33142. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33143. */
  33144. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33145. /**
  33146. * Default behaviour for cors in the application.
  33147. * It can be a string if the expected behavior is identical in the entire app.
  33148. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33149. */
  33150. static CorsBehavior: string | ((url: string | string[]) => string);
  33151. /**
  33152. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33153. * @ignorenaming
  33154. */
  33155. static UseFallbackTexture: boolean;
  33156. /**
  33157. * Use this object to register external classes like custom textures or material
  33158. * to allow the laoders to instantiate them
  33159. */
  33160. static RegisteredExternalClasses: {
  33161. [key: string]: Object;
  33162. };
  33163. /**
  33164. * Texture content used if a texture cannot loaded
  33165. * @ignorenaming
  33166. */
  33167. static fallbackTexture: string;
  33168. /**
  33169. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33170. * @param u defines the coordinate on X axis
  33171. * @param v defines the coordinate on Y axis
  33172. * @param width defines the width of the source data
  33173. * @param height defines the height of the source data
  33174. * @param pixels defines the source byte array
  33175. * @param color defines the output color
  33176. */
  33177. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33178. /**
  33179. * Interpolates between a and b via alpha
  33180. * @param a The lower value (returned when alpha = 0)
  33181. * @param b The upper value (returned when alpha = 1)
  33182. * @param alpha The interpolation-factor
  33183. * @return The mixed value
  33184. */
  33185. static Mix(a: number, b: number, alpha: number): number;
  33186. /**
  33187. * Tries to instantiate a new object from a given class name
  33188. * @param className defines the class name to instantiate
  33189. * @returns the new object or null if the system was not able to do the instantiation
  33190. */
  33191. static Instantiate(className: string): any;
  33192. /**
  33193. * Provides a slice function that will work even on IE
  33194. * @param data defines the array to slice
  33195. * @param start defines the start of the data (optional)
  33196. * @param end defines the end of the data (optional)
  33197. * @returns the new sliced array
  33198. */
  33199. static Slice<T>(data: T, start?: number, end?: number): T;
  33200. /**
  33201. * Polyfill for setImmediate
  33202. * @param action defines the action to execute after the current execution block
  33203. */
  33204. static SetImmediate(action: () => void): void;
  33205. /**
  33206. * Function indicating if a number is an exponent of 2
  33207. * @param value defines the value to test
  33208. * @returns true if the value is an exponent of 2
  33209. */
  33210. static IsExponentOfTwo(value: number): boolean;
  33211. private static _tmpFloatArray;
  33212. /**
  33213. * Returns the nearest 32-bit single precision float representation of a Number
  33214. * @param value A Number. If the parameter is of a different type, it will get converted
  33215. * to a number or to NaN if it cannot be converted
  33216. * @returns number
  33217. */
  33218. static FloatRound(value: number): number;
  33219. /**
  33220. * Extracts the filename from a path
  33221. * @param path defines the path to use
  33222. * @returns the filename
  33223. */
  33224. static GetFilename(path: string): string;
  33225. /**
  33226. * Extracts the "folder" part of a path (everything before the filename).
  33227. * @param uri The URI to extract the info from
  33228. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33229. * @returns The "folder" part of the path
  33230. */
  33231. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33232. /**
  33233. * Extracts text content from a DOM element hierarchy
  33234. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33235. */
  33236. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33237. /**
  33238. * Convert an angle in radians to degrees
  33239. * @param angle defines the angle to convert
  33240. * @returns the angle in degrees
  33241. */
  33242. static ToDegrees(angle: number): number;
  33243. /**
  33244. * Convert an angle in degrees to radians
  33245. * @param angle defines the angle to convert
  33246. * @returns the angle in radians
  33247. */
  33248. static ToRadians(angle: number): number;
  33249. /**
  33250. * Returns an array if obj is not an array
  33251. * @param obj defines the object to evaluate as an array
  33252. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33253. * @returns either obj directly if obj is an array or a new array containing obj
  33254. */
  33255. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33256. /**
  33257. * Gets the pointer prefix to use
  33258. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33259. */
  33260. static GetPointerPrefix(): string;
  33261. /**
  33262. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33263. * @param url define the url we are trying
  33264. * @param element define the dom element where to configure the cors policy
  33265. */
  33266. static SetCorsBehavior(url: string | string[], element: {
  33267. crossOrigin: string | null;
  33268. }): void;
  33269. /**
  33270. * Removes unwanted characters from an url
  33271. * @param url defines the url to clean
  33272. * @returns the cleaned url
  33273. */
  33274. static CleanUrl(url: string): string;
  33275. /**
  33276. * Gets or sets a function used to pre-process url before using them to load assets
  33277. */
  33278. static PreprocessUrl: (url: string) => string;
  33279. /**
  33280. * Loads an image as an HTMLImageElement.
  33281. * @param input url string, ArrayBuffer, or Blob to load
  33282. * @param onLoad callback called when the image successfully loads
  33283. * @param onError callback called when the image fails to load
  33284. * @param offlineProvider offline provider for caching
  33285. * @param mimeType optional mime type
  33286. * @returns the HTMLImageElement of the loaded image
  33287. */
  33288. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33289. /**
  33290. * Loads a file from a url
  33291. * @param url url string, ArrayBuffer, or Blob to load
  33292. * @param onSuccess callback called when the file successfully loads
  33293. * @param onProgress callback called while file is loading (if the server supports this mode)
  33294. * @param offlineProvider defines the offline provider for caching
  33295. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33296. * @param onError callback called when the file fails to load
  33297. * @returns a file request object
  33298. */
  33299. 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;
  33300. /**
  33301. * Loads a file from a url
  33302. * @param url the file url to load
  33303. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33304. */
  33305. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33306. /**
  33307. * Load a 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 onSuccess defines the callback called when the script is loaded
  33311. * @param onError defines the callback to call if an error occurs
  33312. * @param scriptId defines the id of the script element
  33313. */
  33314. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33315. /**
  33316. * Load an asynchronous script (identified by an url). When the url returns, the
  33317. * content of this file is added into a new script element, attached to the DOM (body element)
  33318. * @param scriptUrl defines the url of the script to laod
  33319. * @param scriptId defines the id of the script element
  33320. * @returns a promise request object
  33321. */
  33322. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33323. /**
  33324. * Loads a file from a blob
  33325. * @param fileToLoad defines the blob to use
  33326. * @param callback defines the callback to call when data is loaded
  33327. * @param progressCallback defines the callback to call during loading process
  33328. * @returns a file request object
  33329. */
  33330. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33331. /**
  33332. * Reads a file from a File object
  33333. * @param file defines the file to load
  33334. * @param onSuccess defines the callback to call when data is loaded
  33335. * @param onProgress defines the callback to call during loading process
  33336. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33337. * @param onError defines the callback to call when an error occurs
  33338. * @returns a file request object
  33339. */
  33340. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33341. /**
  33342. * Creates a data url from a given string content
  33343. * @param content defines the content to convert
  33344. * @returns the new data url link
  33345. */
  33346. static FileAsURL(content: string): string;
  33347. /**
  33348. * Format the given number to a specific decimal format
  33349. * @param value defines the number to format
  33350. * @param decimals defines the number of decimals to use
  33351. * @returns the formatted string
  33352. */
  33353. static Format(value: number, decimals?: number): string;
  33354. /**
  33355. * Tries to copy an object by duplicating every property
  33356. * @param source defines the source object
  33357. * @param destination defines the target object
  33358. * @param doNotCopyList defines a list of properties to avoid
  33359. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33360. */
  33361. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33362. /**
  33363. * Gets a boolean indicating if the given object has no own property
  33364. * @param obj defines the object to test
  33365. * @returns true if object has no own property
  33366. */
  33367. static IsEmpty(obj: any): boolean;
  33368. /**
  33369. * Function used to register events at window level
  33370. * @param windowElement defines the Window object to use
  33371. * @param events defines the events to register
  33372. */
  33373. static RegisterTopRootEvents(windowElement: Window, events: {
  33374. name: string;
  33375. handler: Nullable<(e: FocusEvent) => any>;
  33376. }[]): void;
  33377. /**
  33378. * Function used to unregister events from window level
  33379. * @param windowElement defines the Window object to use
  33380. * @param events defines the events to unregister
  33381. */
  33382. static UnregisterTopRootEvents(windowElement: Window, events: {
  33383. name: string;
  33384. handler: Nullable<(e: FocusEvent) => any>;
  33385. }[]): void;
  33386. /**
  33387. * @ignore
  33388. */
  33389. static _ScreenshotCanvas: HTMLCanvasElement;
  33390. /**
  33391. * Dumps the current bound framebuffer
  33392. * @param width defines the rendering width
  33393. * @param height defines the rendering height
  33394. * @param engine defines the hosting engine
  33395. * @param successCallback defines the callback triggered once the data are available
  33396. * @param mimeType defines the mime type of the result
  33397. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33398. */
  33399. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33400. /**
  33401. * Converts the canvas data to blob.
  33402. * This acts as a polyfill for browsers not supporting the to blob function.
  33403. * @param canvas Defines the canvas to extract the data from
  33404. * @param successCallback Defines the callback triggered once the data are available
  33405. * @param mimeType Defines the mime type of the result
  33406. */
  33407. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33408. /**
  33409. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33410. * @param successCallback defines the callback triggered once the data are available
  33411. * @param mimeType defines the mime type of the result
  33412. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33413. */
  33414. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33415. /**
  33416. * Downloads a blob in the browser
  33417. * @param blob defines the blob to download
  33418. * @param fileName defines the name of the downloaded file
  33419. */
  33420. static Download(blob: Blob, fileName: string): void;
  33421. /**
  33422. * Captures a screenshot of the current rendering
  33423. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33424. * @param engine defines the rendering engine
  33425. * @param camera defines the source camera
  33426. * @param size This parameter can be set to a single number or to an object with the
  33427. * following (optional) properties: precision, width, height. If a single number is passed,
  33428. * it will be used for both width and height. If an object is passed, the screenshot size
  33429. * will be derived from the parameters. The precision property is a multiplier allowing
  33430. * rendering at a higher or lower resolution
  33431. * @param successCallback defines the callback receives a single parameter which contains the
  33432. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33433. * src parameter of an <img> to display it
  33434. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33435. * Check your browser for supported MIME types
  33436. */
  33437. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33438. /**
  33439. * Captures a screenshot of the current rendering
  33440. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33441. * @param engine defines the rendering engine
  33442. * @param camera defines the source camera
  33443. * @param size This parameter can be set to a single number or to an object with the
  33444. * following (optional) properties: precision, width, height. If a single number is passed,
  33445. * it will be used for both width and height. If an object is passed, the screenshot size
  33446. * will be derived from the parameters. The precision property is a multiplier allowing
  33447. * rendering at a higher or lower resolution
  33448. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33449. * Check your browser for supported MIME types
  33450. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33451. * to the src parameter of an <img> to display it
  33452. */
  33453. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33454. /**
  33455. * Generates an image screenshot from the specified camera.
  33456. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33457. * @param engine The engine to use for rendering
  33458. * @param camera The camera to use for rendering
  33459. * @param size This parameter can be set to a single number or to an object with the
  33460. * following (optional) properties: precision, width, height. If a single number is passed,
  33461. * it will be used for both width and height. If an object is passed, the screenshot size
  33462. * will be derived from the parameters. The precision property is a multiplier allowing
  33463. * rendering at a higher or lower resolution
  33464. * @param successCallback The callback receives a single parameter which contains the
  33465. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33466. * src parameter of an <img> to display it
  33467. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33468. * Check your browser for supported MIME types
  33469. * @param samples Texture samples (default: 1)
  33470. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33471. * @param fileName A name for for the downloaded file.
  33472. */
  33473. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33474. /**
  33475. * Generates an image screenshot from the specified camera.
  33476. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33477. * @param engine The engine to use for rendering
  33478. * @param camera The camera to use for rendering
  33479. * @param size This parameter can be set to a single number or to an object with the
  33480. * following (optional) properties: precision, width, height. If a single number is passed,
  33481. * it will be used for both width and height. If an object is passed, the screenshot size
  33482. * will be derived from the parameters. The precision property is a multiplier allowing
  33483. * rendering at a higher or lower resolution
  33484. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33485. * Check your browser for supported MIME types
  33486. * @param samples Texture samples (default: 1)
  33487. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33488. * @param fileName A name for for the downloaded file.
  33489. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33490. * to the src parameter of an <img> to display it
  33491. */
  33492. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33493. /**
  33494. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33495. * Be aware Math.random() could cause collisions, but:
  33496. * "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"
  33497. * @returns a pseudo random id
  33498. */
  33499. static RandomId(): string;
  33500. /**
  33501. * Test if the given uri is a base64 string
  33502. * @param uri The uri to test
  33503. * @return True if the uri is a base64 string or false otherwise
  33504. */
  33505. static IsBase64(uri: string): boolean;
  33506. /**
  33507. * Decode the given base64 uri.
  33508. * @param uri The uri to decode
  33509. * @return The decoded base64 data.
  33510. */
  33511. static DecodeBase64(uri: string): ArrayBuffer;
  33512. /**
  33513. * Gets the absolute url.
  33514. * @param url the input url
  33515. * @return the absolute url
  33516. */
  33517. static GetAbsoluteUrl(url: string): string;
  33518. /**
  33519. * No log
  33520. */
  33521. static readonly NoneLogLevel: number;
  33522. /**
  33523. * Only message logs
  33524. */
  33525. static readonly MessageLogLevel: number;
  33526. /**
  33527. * Only warning logs
  33528. */
  33529. static readonly WarningLogLevel: number;
  33530. /**
  33531. * Only error logs
  33532. */
  33533. static readonly ErrorLogLevel: number;
  33534. /**
  33535. * All logs
  33536. */
  33537. static readonly AllLogLevel: number;
  33538. /**
  33539. * Gets a value indicating the number of loading errors
  33540. * @ignorenaming
  33541. */
  33542. static readonly errorsCount: number;
  33543. /**
  33544. * Callback called when a new log is added
  33545. */
  33546. static OnNewCacheEntry: (entry: string) => void;
  33547. /**
  33548. * Log a message to the console
  33549. * @param message defines the message to log
  33550. */
  33551. static Log(message: string): void;
  33552. /**
  33553. * Write a warning message to the console
  33554. * @param message defines the message to log
  33555. */
  33556. static Warn(message: string): void;
  33557. /**
  33558. * Write an error message to the console
  33559. * @param message defines the message to log
  33560. */
  33561. static Error(message: string): void;
  33562. /**
  33563. * Gets current log cache (list of logs)
  33564. */
  33565. static readonly LogCache: string;
  33566. /**
  33567. * Clears the log cache
  33568. */
  33569. static ClearLogCache(): void;
  33570. /**
  33571. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33572. */
  33573. static LogLevels: number;
  33574. /**
  33575. * Checks if the window object exists
  33576. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33577. */
  33578. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33579. /**
  33580. * No performance log
  33581. */
  33582. static readonly PerformanceNoneLogLevel: number;
  33583. /**
  33584. * Use user marks to log performance
  33585. */
  33586. static readonly PerformanceUserMarkLogLevel: number;
  33587. /**
  33588. * Log performance to the console
  33589. */
  33590. static readonly PerformanceConsoleLogLevel: number;
  33591. private static _performance;
  33592. /**
  33593. * Sets the current performance log level
  33594. */
  33595. static PerformanceLogLevel: number;
  33596. private static _StartPerformanceCounterDisabled;
  33597. private static _EndPerformanceCounterDisabled;
  33598. private static _StartUserMark;
  33599. private static _EndUserMark;
  33600. private static _StartPerformanceConsole;
  33601. private static _EndPerformanceConsole;
  33602. /**
  33603. * Starts a performance counter
  33604. */
  33605. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33606. /**
  33607. * Ends a specific performance coutner
  33608. */
  33609. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33610. /**
  33611. * Gets either window.performance.now() if supported or Date.now() else
  33612. */
  33613. static readonly Now: number;
  33614. /**
  33615. * This method will return the name of the class used to create the instance of the given object.
  33616. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33617. * @param object the object to get the class name from
  33618. * @param isType defines if the object is actually a type
  33619. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33620. */
  33621. static GetClassName(object: any, isType?: boolean): string;
  33622. /**
  33623. * Gets the first element of an array satisfying a given predicate
  33624. * @param array defines the array to browse
  33625. * @param predicate defines the predicate to use
  33626. * @returns null if not found or the element
  33627. */
  33628. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33629. /**
  33630. * This method will return the name of the full name of the class, including its owning module (if any).
  33631. * 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).
  33632. * @param object the object to get the class name from
  33633. * @param isType defines if the object is actually a type
  33634. * @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.
  33635. * @ignorenaming
  33636. */
  33637. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33638. /**
  33639. * Returns a promise that resolves after the given amount of time.
  33640. * @param delay Number of milliseconds to delay
  33641. * @returns Promise that resolves after the given amount of time
  33642. */
  33643. static DelayAsync(delay: number): Promise<void>;
  33644. }
  33645. /**
  33646. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33647. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33648. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33649. * @param name The name of the class, case should be preserved
  33650. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33651. */
  33652. export function className(name: string, module?: string): (target: Object) => void;
  33653. /**
  33654. * An implementation of a loop for asynchronous functions.
  33655. */
  33656. export class AsyncLoop {
  33657. /**
  33658. * Defines the number of iterations for the loop
  33659. */
  33660. iterations: number;
  33661. /**
  33662. * Defines the current index of the loop.
  33663. */
  33664. index: number;
  33665. private _done;
  33666. private _fn;
  33667. private _successCallback;
  33668. /**
  33669. * Constructor.
  33670. * @param iterations the number of iterations.
  33671. * @param func the function to run each iteration
  33672. * @param successCallback the callback that will be called upon succesful execution
  33673. * @param offset starting offset.
  33674. */
  33675. constructor(
  33676. /**
  33677. * Defines the number of iterations for the loop
  33678. */
  33679. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33680. /**
  33681. * Execute the next iteration. Must be called after the last iteration was finished.
  33682. */
  33683. executeNext(): void;
  33684. /**
  33685. * Break the loop and run the success callback.
  33686. */
  33687. breakLoop(): void;
  33688. /**
  33689. * Create and run an async loop.
  33690. * @param iterations the number of iterations.
  33691. * @param fn the function to run each iteration
  33692. * @param successCallback the callback that will be called upon succesful execution
  33693. * @param offset starting offset.
  33694. * @returns the created async loop object
  33695. */
  33696. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33697. /**
  33698. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33699. * @param iterations total number of iterations
  33700. * @param syncedIterations number of synchronous iterations in each async iteration.
  33701. * @param fn the function to call each iteration.
  33702. * @param callback a success call back that will be called when iterating stops.
  33703. * @param breakFunction a break condition (optional)
  33704. * @param timeout timeout settings for the setTimeout function. default - 0.
  33705. * @returns the created async loop object
  33706. */
  33707. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33708. }
  33709. }
  33710. declare module "babylonjs/Misc/stringDictionary" {
  33711. import { Nullable } from "babylonjs/types";
  33712. /**
  33713. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33714. * The underlying implementation relies on an associative array to ensure the best performances.
  33715. * The value can be anything including 'null' but except 'undefined'
  33716. */
  33717. export class StringDictionary<T> {
  33718. /**
  33719. * This will clear this dictionary and copy the content from the 'source' one.
  33720. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33721. * @param source the dictionary to take the content from and copy to this dictionary
  33722. */
  33723. copyFrom(source: StringDictionary<T>): void;
  33724. /**
  33725. * Get a value based from its key
  33726. * @param key the given key to get the matching value from
  33727. * @return the value if found, otherwise undefined is returned
  33728. */
  33729. get(key: string): T | undefined;
  33730. /**
  33731. * Get a value from its key or add it if it doesn't exist.
  33732. * This method will ensure you that a given key/data will be present in the dictionary.
  33733. * @param key the given key to get the matching value from
  33734. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33735. * The factory will only be invoked if there's no data for the given key.
  33736. * @return the value corresponding to the key.
  33737. */
  33738. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33739. /**
  33740. * Get a value from its key if present in the dictionary otherwise add it
  33741. * @param key the key to get the value from
  33742. * @param val if there's no such key/value pair in the dictionary add it with this value
  33743. * @return the value corresponding to the key
  33744. */
  33745. getOrAdd(key: string, val: T): T;
  33746. /**
  33747. * Check if there's a given key in the dictionary
  33748. * @param key the key to check for
  33749. * @return true if the key is present, false otherwise
  33750. */
  33751. contains(key: string): boolean;
  33752. /**
  33753. * Add a new key and its corresponding value
  33754. * @param key the key to add
  33755. * @param value the value corresponding to the key
  33756. * @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
  33757. */
  33758. add(key: string, value: T): boolean;
  33759. /**
  33760. * Update a specific value associated to a key
  33761. * @param key defines the key to use
  33762. * @param value defines the value to store
  33763. * @returns true if the value was updated (or false if the key was not found)
  33764. */
  33765. set(key: string, value: T): boolean;
  33766. /**
  33767. * Get the element of the given key and remove it from the dictionary
  33768. * @param key defines the key to search
  33769. * @returns the value associated with the key or null if not found
  33770. */
  33771. getAndRemove(key: string): Nullable<T>;
  33772. /**
  33773. * Remove a key/value from the dictionary.
  33774. * @param key the key to remove
  33775. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33776. */
  33777. remove(key: string): boolean;
  33778. /**
  33779. * Clear the whole content of the dictionary
  33780. */
  33781. clear(): void;
  33782. /**
  33783. * Gets the current count
  33784. */
  33785. readonly count: number;
  33786. /**
  33787. * Execute a callback on each key/val of the dictionary.
  33788. * Note that you can remove any element in this dictionary in the callback implementation
  33789. * @param callback the callback to execute on a given key/value pair
  33790. */
  33791. forEach(callback: (key: string, val: T) => void): void;
  33792. /**
  33793. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33794. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33795. * Note that you can remove any element in this dictionary in the callback implementation
  33796. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33797. * @returns the first item
  33798. */
  33799. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33800. private _count;
  33801. private _data;
  33802. }
  33803. }
  33804. declare module "babylonjs/Collisions/collisionCoordinator" {
  33805. import { Nullable } from "babylonjs/types";
  33806. import { Scene } from "babylonjs/scene";
  33807. import { Vector3 } from "babylonjs/Maths/math.vector";
  33808. import { Collider } from "babylonjs/Collisions/collider";
  33809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33810. /** @hidden */
  33811. export interface ICollisionCoordinator {
  33812. createCollider(): Collider;
  33813. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33814. init(scene: Scene): void;
  33815. }
  33816. /** @hidden */
  33817. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33818. private _scene;
  33819. private _scaledPosition;
  33820. private _scaledVelocity;
  33821. private _finalPosition;
  33822. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33823. createCollider(): Collider;
  33824. init(scene: Scene): void;
  33825. private _collideWithWorld;
  33826. }
  33827. }
  33828. declare module "babylonjs/Inputs/scene.inputManager" {
  33829. import { Nullable } from "babylonjs/types";
  33830. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33831. import { Vector2 } from "babylonjs/Maths/math.vector";
  33832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33833. import { Scene } from "babylonjs/scene";
  33834. /**
  33835. * Class used to manage all inputs for the scene.
  33836. */
  33837. export class InputManager {
  33838. /** The distance in pixel that you have to move to prevent some events */
  33839. static DragMovementThreshold: number;
  33840. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33841. static LongPressDelay: number;
  33842. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33843. static DoubleClickDelay: number;
  33844. /** If you need to check double click without raising a single click at first click, enable this flag */
  33845. static ExclusiveDoubleClickMode: boolean;
  33846. private _wheelEventName;
  33847. private _onPointerMove;
  33848. private _onPointerDown;
  33849. private _onPointerUp;
  33850. private _initClickEvent;
  33851. private _initActionManager;
  33852. private _delayedSimpleClick;
  33853. private _delayedSimpleClickTimeout;
  33854. private _previousDelayedSimpleClickTimeout;
  33855. private _meshPickProceed;
  33856. private _previousButtonPressed;
  33857. private _currentPickResult;
  33858. private _previousPickResult;
  33859. private _totalPointersPressed;
  33860. private _doubleClickOccured;
  33861. private _pointerOverMesh;
  33862. private _pickedDownMesh;
  33863. private _pickedUpMesh;
  33864. private _pointerX;
  33865. private _pointerY;
  33866. private _unTranslatedPointerX;
  33867. private _unTranslatedPointerY;
  33868. private _startingPointerPosition;
  33869. private _previousStartingPointerPosition;
  33870. private _startingPointerTime;
  33871. private _previousStartingPointerTime;
  33872. private _pointerCaptures;
  33873. private _onKeyDown;
  33874. private _onKeyUp;
  33875. private _onCanvasFocusObserver;
  33876. private _onCanvasBlurObserver;
  33877. private _scene;
  33878. /**
  33879. * Creates a new InputManager
  33880. * @param scene defines the hosting scene
  33881. */
  33882. constructor(scene: Scene);
  33883. /**
  33884. * Gets the mesh that is currently under the pointer
  33885. */
  33886. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33887. /**
  33888. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33889. */
  33890. readonly unTranslatedPointer: Vector2;
  33891. /**
  33892. * Gets or sets the current on-screen X position of the pointer
  33893. */
  33894. pointerX: number;
  33895. /**
  33896. * Gets or sets the current on-screen Y position of the pointer
  33897. */
  33898. pointerY: number;
  33899. private _updatePointerPosition;
  33900. private _processPointerMove;
  33901. private _setRayOnPointerInfo;
  33902. private _checkPrePointerObservable;
  33903. /**
  33904. * Use this method to simulate a pointer move on a mesh
  33905. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33906. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33907. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33908. */
  33909. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33910. /**
  33911. * Use this method to simulate a pointer down on a mesh
  33912. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33913. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33914. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33915. */
  33916. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33917. private _processPointerDown;
  33918. /** @hidden */
  33919. _isPointerSwiping(): boolean;
  33920. /**
  33921. * Use this method to simulate a pointer up on a mesh
  33922. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33923. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33924. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33925. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33926. */
  33927. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33928. private _processPointerUp;
  33929. /**
  33930. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33931. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33932. * @returns true if the pointer was captured
  33933. */
  33934. isPointerCaptured(pointerId?: number): boolean;
  33935. /**
  33936. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33937. * @param attachUp defines if you want to attach events to pointerup
  33938. * @param attachDown defines if you want to attach events to pointerdown
  33939. * @param attachMove defines if you want to attach events to pointermove
  33940. */
  33941. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33942. /**
  33943. * Detaches all event handlers
  33944. */
  33945. detachControl(): void;
  33946. /**
  33947. * Force the value of meshUnderPointer
  33948. * @param mesh defines the mesh to use
  33949. */
  33950. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33951. /**
  33952. * Gets the mesh under the pointer
  33953. * @returns a Mesh or null if no mesh is under the pointer
  33954. */
  33955. getPointerOverMesh(): Nullable<AbstractMesh>;
  33956. }
  33957. }
  33958. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33959. /**
  33960. * Helper class used to generate session unique ID
  33961. */
  33962. export class UniqueIdGenerator {
  33963. private static _UniqueIdCounter;
  33964. /**
  33965. * Gets an unique (relatively to the current scene) Id
  33966. */
  33967. static readonly UniqueId: number;
  33968. }
  33969. }
  33970. declare module "babylonjs/Animations/animationGroup" {
  33971. import { Animatable } from "babylonjs/Animations/animatable";
  33972. import { Animation } from "babylonjs/Animations/animation";
  33973. import { Scene, IDisposable } from "babylonjs/scene";
  33974. import { Observable } from "babylonjs/Misc/observable";
  33975. import { Nullable } from "babylonjs/types";
  33976. import "babylonjs/Animations/animatable";
  33977. /**
  33978. * This class defines the direct association between an animation and a target
  33979. */
  33980. export class TargetedAnimation {
  33981. /**
  33982. * Animation to perform
  33983. */
  33984. animation: Animation;
  33985. /**
  33986. * Target to animate
  33987. */
  33988. target: any;
  33989. /**
  33990. * Serialize the object
  33991. * @returns the JSON object representing the current entity
  33992. */
  33993. serialize(): any;
  33994. }
  33995. /**
  33996. * Use this class to create coordinated animations on multiple targets
  33997. */
  33998. export class AnimationGroup implements IDisposable {
  33999. /** The name of the animation group */
  34000. name: string;
  34001. private _scene;
  34002. private _targetedAnimations;
  34003. private _animatables;
  34004. private _from;
  34005. private _to;
  34006. private _isStarted;
  34007. private _isPaused;
  34008. private _speedRatio;
  34009. private _loopAnimation;
  34010. /**
  34011. * Gets or sets the unique id of the node
  34012. */
  34013. uniqueId: number;
  34014. /**
  34015. * This observable will notify when one animation have ended
  34016. */
  34017. onAnimationEndObservable: Observable<TargetedAnimation>;
  34018. /**
  34019. * Observer raised when one animation loops
  34020. */
  34021. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34022. /**
  34023. * Observer raised when all animations have looped
  34024. */
  34025. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34026. /**
  34027. * This observable will notify when all animations have ended.
  34028. */
  34029. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34030. /**
  34031. * This observable will notify when all animations have paused.
  34032. */
  34033. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34034. /**
  34035. * This observable will notify when all animations are playing.
  34036. */
  34037. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34038. /**
  34039. * Gets the first frame
  34040. */
  34041. readonly from: number;
  34042. /**
  34043. * Gets the last frame
  34044. */
  34045. readonly to: number;
  34046. /**
  34047. * Define if the animations are started
  34048. */
  34049. readonly isStarted: boolean;
  34050. /**
  34051. * Gets a value indicating that the current group is playing
  34052. */
  34053. readonly isPlaying: boolean;
  34054. /**
  34055. * Gets or sets the speed ratio to use for all animations
  34056. */
  34057. /**
  34058. * Gets or sets the speed ratio to use for all animations
  34059. */
  34060. speedRatio: number;
  34061. /**
  34062. * Gets or sets if all animations should loop or not
  34063. */
  34064. loopAnimation: boolean;
  34065. /**
  34066. * Gets the targeted animations for this animation group
  34067. */
  34068. readonly targetedAnimations: Array<TargetedAnimation>;
  34069. /**
  34070. * returning the list of animatables controlled by this animation group.
  34071. */
  34072. readonly animatables: Array<Animatable>;
  34073. /**
  34074. * Instantiates a new Animation Group.
  34075. * This helps managing several animations at once.
  34076. * @see http://doc.babylonjs.com/how_to/group
  34077. * @param name Defines the name of the group
  34078. * @param scene Defines the scene the group belongs to
  34079. */
  34080. constructor(
  34081. /** The name of the animation group */
  34082. name: string, scene?: Nullable<Scene>);
  34083. /**
  34084. * Add an animation (with its target) in the group
  34085. * @param animation defines the animation we want to add
  34086. * @param target defines the target of the animation
  34087. * @returns the TargetedAnimation object
  34088. */
  34089. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34090. /**
  34091. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34092. * It can add constant keys at begin or end
  34093. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34094. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34095. * @returns the animation group
  34096. */
  34097. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34098. private _animationLoopCount;
  34099. private _animationLoopFlags;
  34100. private _processLoop;
  34101. /**
  34102. * Start all animations on given targets
  34103. * @param loop defines if animations must loop
  34104. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34105. * @param from defines the from key (optional)
  34106. * @param to defines the to key (optional)
  34107. * @returns the current animation group
  34108. */
  34109. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34110. /**
  34111. * Pause all animations
  34112. * @returns the animation group
  34113. */
  34114. pause(): AnimationGroup;
  34115. /**
  34116. * Play all animations to initial state
  34117. * This function will start() the animations if they were not started or will restart() them if they were paused
  34118. * @param loop defines if animations must loop
  34119. * @returns the animation group
  34120. */
  34121. play(loop?: boolean): AnimationGroup;
  34122. /**
  34123. * Reset all animations to initial state
  34124. * @returns the animation group
  34125. */
  34126. reset(): AnimationGroup;
  34127. /**
  34128. * Restart animations from key 0
  34129. * @returns the animation group
  34130. */
  34131. restart(): AnimationGroup;
  34132. /**
  34133. * Stop all animations
  34134. * @returns the animation group
  34135. */
  34136. stop(): AnimationGroup;
  34137. /**
  34138. * Set animation weight for all animatables
  34139. * @param weight defines the weight to use
  34140. * @return the animationGroup
  34141. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34142. */
  34143. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34144. /**
  34145. * Synchronize and normalize all animatables with a source animatable
  34146. * @param root defines the root animatable to synchronize with
  34147. * @return the animationGroup
  34148. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34149. */
  34150. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34151. /**
  34152. * Goes to a specific frame in this animation group
  34153. * @param frame the frame number to go to
  34154. * @return the animationGroup
  34155. */
  34156. goToFrame(frame: number): AnimationGroup;
  34157. /**
  34158. * Dispose all associated resources
  34159. */
  34160. dispose(): void;
  34161. private _checkAnimationGroupEnded;
  34162. /**
  34163. * Clone the current animation group and returns a copy
  34164. * @param newName defines the name of the new group
  34165. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34166. * @returns the new aniamtion group
  34167. */
  34168. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34169. /**
  34170. * Serializes the animationGroup to an object
  34171. * @returns Serialized object
  34172. */
  34173. serialize(): any;
  34174. /**
  34175. * Returns a new AnimationGroup object parsed from the source provided.
  34176. * @param parsedAnimationGroup defines the source
  34177. * @param scene defines the scene that will receive the animationGroup
  34178. * @returns a new AnimationGroup
  34179. */
  34180. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34181. /**
  34182. * Returns the string "AnimationGroup"
  34183. * @returns "AnimationGroup"
  34184. */
  34185. getClassName(): string;
  34186. /**
  34187. * Creates a detailled string about the object
  34188. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34189. * @returns a string representing the object
  34190. */
  34191. toString(fullDetails?: boolean): string;
  34192. }
  34193. }
  34194. declare module "babylonjs/scene" {
  34195. import { Nullable } from "babylonjs/types";
  34196. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34197. import { Observable } from "babylonjs/Misc/observable";
  34198. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34199. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34200. import { Geometry } from "babylonjs/Meshes/geometry";
  34201. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34202. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34204. import { Mesh } from "babylonjs/Meshes/mesh";
  34205. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34206. import { Bone } from "babylonjs/Bones/bone";
  34207. import { Skeleton } from "babylonjs/Bones/skeleton";
  34208. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34209. import { Camera } from "babylonjs/Cameras/camera";
  34210. import { AbstractScene } from "babylonjs/abstractScene";
  34211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34212. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34213. import { Material } from "babylonjs/Materials/material";
  34214. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34215. import { Effect } from "babylonjs/Materials/effect";
  34216. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34217. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34218. import { Light } from "babylonjs/Lights/light";
  34219. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34220. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34221. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34222. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34223. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34224. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34225. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34226. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34227. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34228. import { Engine } from "babylonjs/Engines/engine";
  34229. import { Node } from "babylonjs/node";
  34230. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34231. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34232. import { WebRequest } from "babylonjs/Misc/webRequest";
  34233. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34234. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34235. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34236. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34237. import { Plane } from "babylonjs/Maths/math.plane";
  34238. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34239. import { Ray } from "babylonjs/Culling/ray";
  34240. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34241. import { Animation } from "babylonjs/Animations/animation";
  34242. import { Animatable } from "babylonjs/Animations/animatable";
  34243. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34244. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34245. import { Collider } from "babylonjs/Collisions/collider";
  34246. /**
  34247. * Define an interface for all classes that will hold resources
  34248. */
  34249. export interface IDisposable {
  34250. /**
  34251. * Releases all held resources
  34252. */
  34253. dispose(): void;
  34254. }
  34255. /** Interface defining initialization parameters for Scene class */
  34256. export interface SceneOptions {
  34257. /**
  34258. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34259. * It will improve performance when the number of geometries becomes important.
  34260. */
  34261. useGeometryUniqueIdsMap?: boolean;
  34262. /**
  34263. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34264. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34265. */
  34266. useMaterialMeshMap?: boolean;
  34267. /**
  34268. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34269. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34270. */
  34271. useClonedMeshhMap?: boolean;
  34272. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34273. virtual?: boolean;
  34274. }
  34275. /**
  34276. * Represents a scene to be rendered by the engine.
  34277. * @see http://doc.babylonjs.com/features/scene
  34278. */
  34279. export class Scene extends AbstractScene implements IAnimatable {
  34280. /** The fog is deactivated */
  34281. static readonly FOGMODE_NONE: number;
  34282. /** The fog density is following an exponential function */
  34283. static readonly FOGMODE_EXP: number;
  34284. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34285. static readonly FOGMODE_EXP2: number;
  34286. /** The fog density is following a linear function. */
  34287. static readonly FOGMODE_LINEAR: number;
  34288. /**
  34289. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34290. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34291. */
  34292. static MinDeltaTime: number;
  34293. /**
  34294. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34295. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34296. */
  34297. static MaxDeltaTime: number;
  34298. /**
  34299. * Factory used to create the default material.
  34300. * @param name The name of the material to create
  34301. * @param scene The scene to create the material for
  34302. * @returns The default material
  34303. */
  34304. static DefaultMaterialFactory(scene: Scene): Material;
  34305. /**
  34306. * Factory used to create the a collision coordinator.
  34307. * @returns The collision coordinator
  34308. */
  34309. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34310. /** @hidden */
  34311. _inputManager: InputManager;
  34312. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34313. cameraToUseForPointers: Nullable<Camera>;
  34314. /** @hidden */
  34315. readonly _isScene: boolean;
  34316. /**
  34317. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34318. */
  34319. autoClear: boolean;
  34320. /**
  34321. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34322. */
  34323. autoClearDepthAndStencil: boolean;
  34324. /**
  34325. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34326. */
  34327. clearColor: Color4;
  34328. /**
  34329. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34330. */
  34331. ambientColor: Color3;
  34332. /**
  34333. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34334. * It should only be one of the following (if not the default embedded one):
  34335. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34336. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34337. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34338. * The material properties need to be setup according to the type of texture in use.
  34339. */
  34340. environmentBRDFTexture: BaseTexture;
  34341. /** @hidden */
  34342. protected _environmentTexture: Nullable<BaseTexture>;
  34343. /**
  34344. * Texture used in all pbr material as the reflection texture.
  34345. * As in the majority of the scene they are the same (exception for multi room and so on),
  34346. * this is easier to reference from here than from all the materials.
  34347. */
  34348. /**
  34349. * Texture used in all pbr material as the reflection texture.
  34350. * As in the majority of the scene they are the same (exception for multi room and so on),
  34351. * this is easier to set here than in all the materials.
  34352. */
  34353. environmentTexture: Nullable<BaseTexture>;
  34354. /** @hidden */
  34355. protected _environmentIntensity: number;
  34356. /**
  34357. * Intensity of the environment in all pbr material.
  34358. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34359. * As in the majority of the scene they are the same (exception for multi room and so on),
  34360. * this is easier to reference from here than from all the materials.
  34361. */
  34362. /**
  34363. * Intensity of the environment in all pbr material.
  34364. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34365. * As in the majority of the scene they are the same (exception for multi room and so on),
  34366. * this is easier to set here than in all the materials.
  34367. */
  34368. environmentIntensity: number;
  34369. /** @hidden */
  34370. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34371. /**
  34372. * Default image processing configuration used either in the rendering
  34373. * Forward main pass or through the imageProcessingPostProcess if present.
  34374. * As in the majority of the scene they are the same (exception for multi camera),
  34375. * this is easier to reference from here than from all the materials and post process.
  34376. *
  34377. * No setter as we it is a shared configuration, you can set the values instead.
  34378. */
  34379. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34380. private _forceWireframe;
  34381. /**
  34382. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34383. */
  34384. forceWireframe: boolean;
  34385. private _forcePointsCloud;
  34386. /**
  34387. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34388. */
  34389. forcePointsCloud: boolean;
  34390. /**
  34391. * Gets or sets the active clipplane 1
  34392. */
  34393. clipPlane: Nullable<Plane>;
  34394. /**
  34395. * Gets or sets the active clipplane 2
  34396. */
  34397. clipPlane2: Nullable<Plane>;
  34398. /**
  34399. * Gets or sets the active clipplane 3
  34400. */
  34401. clipPlane3: Nullable<Plane>;
  34402. /**
  34403. * Gets or sets the active clipplane 4
  34404. */
  34405. clipPlane4: Nullable<Plane>;
  34406. /**
  34407. * Gets or sets a boolean indicating if animations are enabled
  34408. */
  34409. animationsEnabled: boolean;
  34410. private _animationPropertiesOverride;
  34411. /**
  34412. * Gets or sets the animation properties override
  34413. */
  34414. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34415. /**
  34416. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34417. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34418. */
  34419. useConstantAnimationDeltaTime: boolean;
  34420. /**
  34421. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34422. * Please note that it requires to run a ray cast through the scene on every frame
  34423. */
  34424. constantlyUpdateMeshUnderPointer: boolean;
  34425. /**
  34426. * Defines the HTML cursor to use when hovering over interactive elements
  34427. */
  34428. hoverCursor: string;
  34429. /**
  34430. * Defines the HTML default cursor to use (empty by default)
  34431. */
  34432. defaultCursor: string;
  34433. /**
  34434. * Defines wether cursors are handled by the scene.
  34435. */
  34436. doNotHandleCursors: boolean;
  34437. /**
  34438. * This is used to call preventDefault() on pointer down
  34439. * in order to block unwanted artifacts like system double clicks
  34440. */
  34441. preventDefaultOnPointerDown: boolean;
  34442. /**
  34443. * This is used to call preventDefault() on pointer up
  34444. * in order to block unwanted artifacts like system double clicks
  34445. */
  34446. preventDefaultOnPointerUp: boolean;
  34447. /**
  34448. * Gets or sets user defined metadata
  34449. */
  34450. metadata: any;
  34451. /**
  34452. * For internal use only. Please do not use.
  34453. */
  34454. reservedDataStore: any;
  34455. /**
  34456. * Gets the name of the plugin used to load this scene (null by default)
  34457. */
  34458. loadingPluginName: string;
  34459. /**
  34460. * Use this array to add regular expressions used to disable offline support for specific urls
  34461. */
  34462. disableOfflineSupportExceptionRules: RegExp[];
  34463. /**
  34464. * An event triggered when the scene is disposed.
  34465. */
  34466. onDisposeObservable: Observable<Scene>;
  34467. private _onDisposeObserver;
  34468. /** Sets a function to be executed when this scene is disposed. */
  34469. onDispose: () => void;
  34470. /**
  34471. * An event triggered before rendering the scene (right after animations and physics)
  34472. */
  34473. onBeforeRenderObservable: Observable<Scene>;
  34474. private _onBeforeRenderObserver;
  34475. /** Sets a function to be executed before rendering this scene */
  34476. beforeRender: Nullable<() => void>;
  34477. /**
  34478. * An event triggered after rendering the scene
  34479. */
  34480. onAfterRenderObservable: Observable<Scene>;
  34481. /**
  34482. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34483. */
  34484. onAfterRenderCameraObservable: Observable<Camera>;
  34485. private _onAfterRenderObserver;
  34486. /** Sets a function to be executed after rendering this scene */
  34487. afterRender: Nullable<() => void>;
  34488. /**
  34489. * An event triggered before animating the scene
  34490. */
  34491. onBeforeAnimationsObservable: Observable<Scene>;
  34492. /**
  34493. * An event triggered after animations processing
  34494. */
  34495. onAfterAnimationsObservable: Observable<Scene>;
  34496. /**
  34497. * An event triggered before draw calls are ready to be sent
  34498. */
  34499. onBeforeDrawPhaseObservable: Observable<Scene>;
  34500. /**
  34501. * An event triggered after draw calls have been sent
  34502. */
  34503. onAfterDrawPhaseObservable: Observable<Scene>;
  34504. /**
  34505. * An event triggered when the scene is ready
  34506. */
  34507. onReadyObservable: Observable<Scene>;
  34508. /**
  34509. * An event triggered before rendering a camera
  34510. */
  34511. onBeforeCameraRenderObservable: Observable<Camera>;
  34512. private _onBeforeCameraRenderObserver;
  34513. /** Sets a function to be executed before rendering a camera*/
  34514. beforeCameraRender: () => void;
  34515. /**
  34516. * An event triggered after rendering a camera
  34517. */
  34518. onAfterCameraRenderObservable: Observable<Camera>;
  34519. private _onAfterCameraRenderObserver;
  34520. /** Sets a function to be executed after rendering a camera*/
  34521. afterCameraRender: () => void;
  34522. /**
  34523. * An event triggered when active meshes evaluation is about to start
  34524. */
  34525. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34526. /**
  34527. * An event triggered when active meshes evaluation is done
  34528. */
  34529. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34530. /**
  34531. * An event triggered when particles rendering is about to start
  34532. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34533. */
  34534. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34535. /**
  34536. * An event triggered when particles rendering is done
  34537. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34538. */
  34539. onAfterParticlesRenderingObservable: Observable<Scene>;
  34540. /**
  34541. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34542. */
  34543. onDataLoadedObservable: Observable<Scene>;
  34544. /**
  34545. * An event triggered when a camera is created
  34546. */
  34547. onNewCameraAddedObservable: Observable<Camera>;
  34548. /**
  34549. * An event triggered when a camera is removed
  34550. */
  34551. onCameraRemovedObservable: Observable<Camera>;
  34552. /**
  34553. * An event triggered when a light is created
  34554. */
  34555. onNewLightAddedObservable: Observable<Light>;
  34556. /**
  34557. * An event triggered when a light is removed
  34558. */
  34559. onLightRemovedObservable: Observable<Light>;
  34560. /**
  34561. * An event triggered when a geometry is created
  34562. */
  34563. onNewGeometryAddedObservable: Observable<Geometry>;
  34564. /**
  34565. * An event triggered when a geometry is removed
  34566. */
  34567. onGeometryRemovedObservable: Observable<Geometry>;
  34568. /**
  34569. * An event triggered when a transform node is created
  34570. */
  34571. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34572. /**
  34573. * An event triggered when a transform node is removed
  34574. */
  34575. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34576. /**
  34577. * An event triggered when a mesh is created
  34578. */
  34579. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34580. /**
  34581. * An event triggered when a mesh is removed
  34582. */
  34583. onMeshRemovedObservable: Observable<AbstractMesh>;
  34584. /**
  34585. * An event triggered when a skeleton is created
  34586. */
  34587. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34588. /**
  34589. * An event triggered when a skeleton is removed
  34590. */
  34591. onSkeletonRemovedObservable: Observable<Skeleton>;
  34592. /**
  34593. * An event triggered when a material is created
  34594. */
  34595. onNewMaterialAddedObservable: Observable<Material>;
  34596. /**
  34597. * An event triggered when a material is removed
  34598. */
  34599. onMaterialRemovedObservable: Observable<Material>;
  34600. /**
  34601. * An event triggered when a texture is created
  34602. */
  34603. onNewTextureAddedObservable: Observable<BaseTexture>;
  34604. /**
  34605. * An event triggered when a texture is removed
  34606. */
  34607. onTextureRemovedObservable: Observable<BaseTexture>;
  34608. /**
  34609. * An event triggered when render targets are about to be rendered
  34610. * Can happen multiple times per frame.
  34611. */
  34612. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34613. /**
  34614. * An event triggered when render targets were rendered.
  34615. * Can happen multiple times per frame.
  34616. */
  34617. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34618. /**
  34619. * An event triggered before calculating deterministic simulation step
  34620. */
  34621. onBeforeStepObservable: Observable<Scene>;
  34622. /**
  34623. * An event triggered after calculating deterministic simulation step
  34624. */
  34625. onAfterStepObservable: Observable<Scene>;
  34626. /**
  34627. * An event triggered when the activeCamera property is updated
  34628. */
  34629. onActiveCameraChanged: Observable<Scene>;
  34630. /**
  34631. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34632. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34633. * 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)
  34634. */
  34635. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34636. /**
  34637. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34638. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34639. * 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)
  34640. */
  34641. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34642. /**
  34643. * This Observable will when a mesh has been imported into the scene.
  34644. */
  34645. onMeshImportedObservable: Observable<AbstractMesh>;
  34646. /**
  34647. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34648. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34649. */
  34650. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34651. /** @hidden */
  34652. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34653. /**
  34654. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34655. */
  34656. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34657. /**
  34658. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34659. */
  34660. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34661. /**
  34662. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34663. */
  34664. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34665. /** Callback called when a pointer move is detected */
  34666. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34667. /** Callback called when a pointer down is detected */
  34668. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34669. /** Callback called when a pointer up is detected */
  34670. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34671. /** Callback called when a pointer pick is detected */
  34672. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34673. /**
  34674. * 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).
  34675. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34676. */
  34677. onPrePointerObservable: Observable<PointerInfoPre>;
  34678. /**
  34679. * Observable event triggered each time an input event is received from the rendering canvas
  34680. */
  34681. onPointerObservable: Observable<PointerInfo>;
  34682. /**
  34683. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34684. */
  34685. readonly unTranslatedPointer: Vector2;
  34686. /**
  34687. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34688. */
  34689. static DragMovementThreshold: number;
  34690. /**
  34691. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34692. */
  34693. static LongPressDelay: number;
  34694. /**
  34695. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34696. */
  34697. static DoubleClickDelay: number;
  34698. /** If you need to check double click without raising a single click at first click, enable this flag */
  34699. static ExclusiveDoubleClickMode: boolean;
  34700. /** @hidden */
  34701. _mirroredCameraPosition: Nullable<Vector3>;
  34702. /**
  34703. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34704. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34705. */
  34706. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34707. /**
  34708. * Observable event triggered each time an keyboard event is received from the hosting window
  34709. */
  34710. onKeyboardObservable: Observable<KeyboardInfo>;
  34711. private _useRightHandedSystem;
  34712. /**
  34713. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34714. */
  34715. useRightHandedSystem: boolean;
  34716. private _timeAccumulator;
  34717. private _currentStepId;
  34718. private _currentInternalStep;
  34719. /**
  34720. * Sets the step Id used by deterministic lock step
  34721. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34722. * @param newStepId defines the step Id
  34723. */
  34724. setStepId(newStepId: number): void;
  34725. /**
  34726. * Gets the step Id used by deterministic lock step
  34727. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34728. * @returns the step Id
  34729. */
  34730. getStepId(): number;
  34731. /**
  34732. * Gets the internal step used by deterministic lock step
  34733. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34734. * @returns the internal step
  34735. */
  34736. getInternalStep(): number;
  34737. private _fogEnabled;
  34738. /**
  34739. * Gets or sets a boolean indicating if fog is enabled on this scene
  34740. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34741. * (Default is true)
  34742. */
  34743. fogEnabled: boolean;
  34744. private _fogMode;
  34745. /**
  34746. * Gets or sets the fog mode to use
  34747. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34748. * | mode | value |
  34749. * | --- | --- |
  34750. * | FOGMODE_NONE | 0 |
  34751. * | FOGMODE_EXP | 1 |
  34752. * | FOGMODE_EXP2 | 2 |
  34753. * | FOGMODE_LINEAR | 3 |
  34754. */
  34755. fogMode: number;
  34756. /**
  34757. * Gets or sets the fog color to use
  34758. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34759. * (Default is Color3(0.2, 0.2, 0.3))
  34760. */
  34761. fogColor: Color3;
  34762. /**
  34763. * Gets or sets the fog density to use
  34764. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34765. * (Default is 0.1)
  34766. */
  34767. fogDensity: number;
  34768. /**
  34769. * Gets or sets the fog start distance to use
  34770. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34771. * (Default is 0)
  34772. */
  34773. fogStart: number;
  34774. /**
  34775. * Gets or sets the fog end distance to use
  34776. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34777. * (Default is 1000)
  34778. */
  34779. fogEnd: number;
  34780. private _shadowsEnabled;
  34781. /**
  34782. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34783. */
  34784. shadowsEnabled: boolean;
  34785. private _lightsEnabled;
  34786. /**
  34787. * Gets or sets a boolean indicating if lights are enabled on this scene
  34788. */
  34789. lightsEnabled: boolean;
  34790. /** All of the active cameras added to this scene. */
  34791. activeCameras: Camera[];
  34792. /** @hidden */
  34793. _activeCamera: Nullable<Camera>;
  34794. /** Gets or sets the current active camera */
  34795. activeCamera: Nullable<Camera>;
  34796. private _defaultMaterial;
  34797. /** The default material used on meshes when no material is affected */
  34798. /** The default material used on meshes when no material is affected */
  34799. defaultMaterial: Material;
  34800. private _texturesEnabled;
  34801. /**
  34802. * Gets or sets a boolean indicating if textures are enabled on this scene
  34803. */
  34804. texturesEnabled: boolean;
  34805. /**
  34806. * Gets or sets a boolean indicating if particles are enabled on this scene
  34807. */
  34808. particlesEnabled: boolean;
  34809. /**
  34810. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34811. */
  34812. spritesEnabled: boolean;
  34813. private _skeletonsEnabled;
  34814. /**
  34815. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34816. */
  34817. skeletonsEnabled: boolean;
  34818. /**
  34819. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34820. */
  34821. lensFlaresEnabled: boolean;
  34822. /**
  34823. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34824. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34825. */
  34826. collisionsEnabled: boolean;
  34827. private _collisionCoordinator;
  34828. /** @hidden */
  34829. readonly collisionCoordinator: ICollisionCoordinator;
  34830. /**
  34831. * Defines the gravity applied to this scene (used only for collisions)
  34832. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34833. */
  34834. gravity: Vector3;
  34835. /**
  34836. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34837. */
  34838. postProcessesEnabled: boolean;
  34839. /**
  34840. * The list of postprocesses added to the scene
  34841. */
  34842. postProcesses: PostProcess[];
  34843. /**
  34844. * Gets the current postprocess manager
  34845. */
  34846. postProcessManager: PostProcessManager;
  34847. /**
  34848. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34849. */
  34850. renderTargetsEnabled: boolean;
  34851. /**
  34852. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34853. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34854. */
  34855. dumpNextRenderTargets: boolean;
  34856. /**
  34857. * The list of user defined render targets added to the scene
  34858. */
  34859. customRenderTargets: RenderTargetTexture[];
  34860. /**
  34861. * Defines if texture loading must be delayed
  34862. * If true, textures will only be loaded when they need to be rendered
  34863. */
  34864. useDelayedTextureLoading: boolean;
  34865. /**
  34866. * Gets the list of meshes imported to the scene through SceneLoader
  34867. */
  34868. importedMeshesFiles: String[];
  34869. /**
  34870. * Gets or sets a boolean indicating if probes are enabled on this scene
  34871. */
  34872. probesEnabled: boolean;
  34873. /**
  34874. * Gets or sets the current offline provider to use to store scene data
  34875. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34876. */
  34877. offlineProvider: IOfflineProvider;
  34878. /**
  34879. * Gets or sets the action manager associated with the scene
  34880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34881. */
  34882. actionManager: AbstractActionManager;
  34883. private _meshesForIntersections;
  34884. /**
  34885. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34886. */
  34887. proceduralTexturesEnabled: boolean;
  34888. private _engine;
  34889. private _totalVertices;
  34890. /** @hidden */
  34891. _activeIndices: PerfCounter;
  34892. /** @hidden */
  34893. _activeParticles: PerfCounter;
  34894. /** @hidden */
  34895. _activeBones: PerfCounter;
  34896. private _animationRatio;
  34897. /** @hidden */
  34898. _animationTimeLast: number;
  34899. /** @hidden */
  34900. _animationTime: number;
  34901. /**
  34902. * Gets or sets a general scale for animation speed
  34903. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34904. */
  34905. animationTimeScale: number;
  34906. /** @hidden */
  34907. _cachedMaterial: Nullable<Material>;
  34908. /** @hidden */
  34909. _cachedEffect: Nullable<Effect>;
  34910. /** @hidden */
  34911. _cachedVisibility: Nullable<number>;
  34912. private _renderId;
  34913. private _frameId;
  34914. private _executeWhenReadyTimeoutId;
  34915. private _intermediateRendering;
  34916. private _viewUpdateFlag;
  34917. private _projectionUpdateFlag;
  34918. /** @hidden */
  34919. _toBeDisposed: Nullable<IDisposable>[];
  34920. private _activeRequests;
  34921. /** @hidden */
  34922. _pendingData: any[];
  34923. private _isDisposed;
  34924. /**
  34925. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34926. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34927. */
  34928. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34929. private _activeMeshes;
  34930. private _processedMaterials;
  34931. private _renderTargets;
  34932. /** @hidden */
  34933. _activeParticleSystems: SmartArray<IParticleSystem>;
  34934. private _activeSkeletons;
  34935. private _softwareSkinnedMeshes;
  34936. private _renderingManager;
  34937. /** @hidden */
  34938. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34939. private _transformMatrix;
  34940. private _sceneUbo;
  34941. /** @hidden */
  34942. _viewMatrix: Matrix;
  34943. private _projectionMatrix;
  34944. /** @hidden */
  34945. _forcedViewPosition: Nullable<Vector3>;
  34946. /** @hidden */
  34947. _frustumPlanes: Plane[];
  34948. /**
  34949. * Gets the list of frustum planes (built from the active camera)
  34950. */
  34951. readonly frustumPlanes: Plane[];
  34952. /**
  34953. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34954. * This is useful if there are more lights that the maximum simulteanous authorized
  34955. */
  34956. requireLightSorting: boolean;
  34957. /** @hidden */
  34958. readonly useMaterialMeshMap: boolean;
  34959. /** @hidden */
  34960. readonly useClonedMeshhMap: boolean;
  34961. private _externalData;
  34962. private _uid;
  34963. /**
  34964. * @hidden
  34965. * Backing store of defined scene components.
  34966. */
  34967. _components: ISceneComponent[];
  34968. /**
  34969. * @hidden
  34970. * Backing store of defined scene components.
  34971. */
  34972. _serializableComponents: ISceneSerializableComponent[];
  34973. /**
  34974. * List of components to register on the next registration step.
  34975. */
  34976. private _transientComponents;
  34977. /**
  34978. * Registers the transient components if needed.
  34979. */
  34980. private _registerTransientComponents;
  34981. /**
  34982. * @hidden
  34983. * Add a component to the scene.
  34984. * Note that the ccomponent could be registered on th next frame if this is called after
  34985. * the register component stage.
  34986. * @param component Defines the component to add to the scene
  34987. */
  34988. _addComponent(component: ISceneComponent): void;
  34989. /**
  34990. * @hidden
  34991. * Gets a component from the scene.
  34992. * @param name defines the name of the component to retrieve
  34993. * @returns the component or null if not present
  34994. */
  34995. _getComponent(name: string): Nullable<ISceneComponent>;
  34996. /**
  34997. * @hidden
  34998. * Defines the actions happening before camera updates.
  34999. */
  35000. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35001. /**
  35002. * @hidden
  35003. * Defines the actions happening before clear the canvas.
  35004. */
  35005. _beforeClearStage: Stage<SimpleStageAction>;
  35006. /**
  35007. * @hidden
  35008. * Defines the actions when collecting render targets for the frame.
  35009. */
  35010. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35011. /**
  35012. * @hidden
  35013. * Defines the actions happening for one camera in the frame.
  35014. */
  35015. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35016. /**
  35017. * @hidden
  35018. * Defines the actions happening during the per mesh ready checks.
  35019. */
  35020. _isReadyForMeshStage: Stage<MeshStageAction>;
  35021. /**
  35022. * @hidden
  35023. * Defines the actions happening before evaluate active mesh checks.
  35024. */
  35025. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35026. /**
  35027. * @hidden
  35028. * Defines the actions happening during the evaluate sub mesh checks.
  35029. */
  35030. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35031. /**
  35032. * @hidden
  35033. * Defines the actions happening during the active mesh stage.
  35034. */
  35035. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35036. /**
  35037. * @hidden
  35038. * Defines the actions happening during the per camera render target step.
  35039. */
  35040. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35041. /**
  35042. * @hidden
  35043. * Defines the actions happening just before the active camera is drawing.
  35044. */
  35045. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35046. /**
  35047. * @hidden
  35048. * Defines the actions happening just before a render target is drawing.
  35049. */
  35050. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35051. /**
  35052. * @hidden
  35053. * Defines the actions happening just before a rendering group is drawing.
  35054. */
  35055. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35056. /**
  35057. * @hidden
  35058. * Defines the actions happening just before a mesh is drawing.
  35059. */
  35060. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35061. /**
  35062. * @hidden
  35063. * Defines the actions happening just after a mesh has been drawn.
  35064. */
  35065. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35066. /**
  35067. * @hidden
  35068. * Defines the actions happening just after a rendering group has been drawn.
  35069. */
  35070. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35071. /**
  35072. * @hidden
  35073. * Defines the actions happening just after the active camera has been drawn.
  35074. */
  35075. _afterCameraDrawStage: Stage<CameraStageAction>;
  35076. /**
  35077. * @hidden
  35078. * Defines the actions happening just after a render target has been drawn.
  35079. */
  35080. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35081. /**
  35082. * @hidden
  35083. * Defines the actions happening just after rendering all cameras and computing intersections.
  35084. */
  35085. _afterRenderStage: Stage<SimpleStageAction>;
  35086. /**
  35087. * @hidden
  35088. * Defines the actions happening when a pointer move event happens.
  35089. */
  35090. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35091. /**
  35092. * @hidden
  35093. * Defines the actions happening when a pointer down event happens.
  35094. */
  35095. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35096. /**
  35097. * @hidden
  35098. * Defines the actions happening when a pointer up event happens.
  35099. */
  35100. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35101. /**
  35102. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35103. */
  35104. private geometriesByUniqueId;
  35105. /**
  35106. * Creates a new Scene
  35107. * @param engine defines the engine to use to render this scene
  35108. * @param options defines the scene options
  35109. */
  35110. constructor(engine: Engine, options?: SceneOptions);
  35111. /**
  35112. * Gets a string idenfifying the name of the class
  35113. * @returns "Scene" string
  35114. */
  35115. getClassName(): string;
  35116. private _defaultMeshCandidates;
  35117. /**
  35118. * @hidden
  35119. */
  35120. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35121. private _defaultSubMeshCandidates;
  35122. /**
  35123. * @hidden
  35124. */
  35125. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35126. /**
  35127. * Sets the default candidate providers for the scene.
  35128. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35129. * and getCollidingSubMeshCandidates to their default function
  35130. */
  35131. setDefaultCandidateProviders(): void;
  35132. /**
  35133. * Gets the mesh that is currently under the pointer
  35134. */
  35135. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35136. /**
  35137. * Gets or sets the current on-screen X position of the pointer
  35138. */
  35139. pointerX: number;
  35140. /**
  35141. * Gets or sets the current on-screen Y position of the pointer
  35142. */
  35143. pointerY: number;
  35144. /**
  35145. * Gets the cached material (ie. the latest rendered one)
  35146. * @returns the cached material
  35147. */
  35148. getCachedMaterial(): Nullable<Material>;
  35149. /**
  35150. * Gets the cached effect (ie. the latest rendered one)
  35151. * @returns the cached effect
  35152. */
  35153. getCachedEffect(): Nullable<Effect>;
  35154. /**
  35155. * Gets the cached visibility state (ie. the latest rendered one)
  35156. * @returns the cached visibility state
  35157. */
  35158. getCachedVisibility(): Nullable<number>;
  35159. /**
  35160. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35161. * @param material defines the current material
  35162. * @param effect defines the current effect
  35163. * @param visibility defines the current visibility state
  35164. * @returns true if one parameter is not cached
  35165. */
  35166. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35167. /**
  35168. * Gets the engine associated with the scene
  35169. * @returns an Engine
  35170. */
  35171. getEngine(): Engine;
  35172. /**
  35173. * Gets the total number of vertices rendered per frame
  35174. * @returns the total number of vertices rendered per frame
  35175. */
  35176. getTotalVertices(): number;
  35177. /**
  35178. * Gets the performance counter for total vertices
  35179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35180. */
  35181. readonly totalVerticesPerfCounter: PerfCounter;
  35182. /**
  35183. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35184. * @returns the total number of active indices rendered per frame
  35185. */
  35186. getActiveIndices(): number;
  35187. /**
  35188. * Gets the performance counter for active indices
  35189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35190. */
  35191. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35192. /**
  35193. * Gets the total number of active particles rendered per frame
  35194. * @returns the total number of active particles rendered per frame
  35195. */
  35196. getActiveParticles(): number;
  35197. /**
  35198. * Gets the performance counter for active particles
  35199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35200. */
  35201. readonly activeParticlesPerfCounter: PerfCounter;
  35202. /**
  35203. * Gets the total number of active bones rendered per frame
  35204. * @returns the total number of active bones rendered per frame
  35205. */
  35206. getActiveBones(): number;
  35207. /**
  35208. * Gets the performance counter for active bones
  35209. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35210. */
  35211. readonly activeBonesPerfCounter: PerfCounter;
  35212. /**
  35213. * Gets the array of active meshes
  35214. * @returns an array of AbstractMesh
  35215. */
  35216. getActiveMeshes(): SmartArray<AbstractMesh>;
  35217. /**
  35218. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35219. * @returns a number
  35220. */
  35221. getAnimationRatio(): number;
  35222. /**
  35223. * Gets an unique Id for the current render phase
  35224. * @returns a number
  35225. */
  35226. getRenderId(): number;
  35227. /**
  35228. * Gets an unique Id for the current frame
  35229. * @returns a number
  35230. */
  35231. getFrameId(): number;
  35232. /** Call this function if you want to manually increment the render Id*/
  35233. incrementRenderId(): void;
  35234. private _createUbo;
  35235. /**
  35236. * Use this method to simulate a pointer move on a mesh
  35237. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35238. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35239. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35240. * @returns the current scene
  35241. */
  35242. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35243. /**
  35244. * Use this method to simulate a pointer down on a mesh
  35245. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35246. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35247. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35248. * @returns the current scene
  35249. */
  35250. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35251. /**
  35252. * Use this method to simulate a pointer up on a mesh
  35253. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35254. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35255. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35256. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35257. * @returns the current scene
  35258. */
  35259. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35260. /**
  35261. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35262. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35263. * @returns true if the pointer was captured
  35264. */
  35265. isPointerCaptured(pointerId?: number): boolean;
  35266. /**
  35267. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35268. * @param attachUp defines if you want to attach events to pointerup
  35269. * @param attachDown defines if you want to attach events to pointerdown
  35270. * @param attachMove defines if you want to attach events to pointermove
  35271. */
  35272. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35273. /** Detaches all event handlers*/
  35274. detachControl(): void;
  35275. /**
  35276. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35277. * Delay loaded resources are not taking in account
  35278. * @return true if all required resources are ready
  35279. */
  35280. isReady(): boolean;
  35281. /** Resets all cached information relative to material (including effect and visibility) */
  35282. resetCachedMaterial(): void;
  35283. /**
  35284. * Registers a function to be called before every frame render
  35285. * @param func defines the function to register
  35286. */
  35287. registerBeforeRender(func: () => void): void;
  35288. /**
  35289. * Unregisters a function called before every frame render
  35290. * @param func defines the function to unregister
  35291. */
  35292. unregisterBeforeRender(func: () => void): void;
  35293. /**
  35294. * Registers a function to be called after every frame render
  35295. * @param func defines the function to register
  35296. */
  35297. registerAfterRender(func: () => void): void;
  35298. /**
  35299. * Unregisters a function called after every frame render
  35300. * @param func defines the function to unregister
  35301. */
  35302. unregisterAfterRender(func: () => void): void;
  35303. private _executeOnceBeforeRender;
  35304. /**
  35305. * The provided function will run before render once and will be disposed afterwards.
  35306. * A timeout delay can be provided so that the function will be executed in N ms.
  35307. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35308. * @param func The function to be executed.
  35309. * @param timeout optional delay in ms
  35310. */
  35311. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35312. /** @hidden */
  35313. _addPendingData(data: any): void;
  35314. /** @hidden */
  35315. _removePendingData(data: any): void;
  35316. /**
  35317. * Returns the number of items waiting to be loaded
  35318. * @returns the number of items waiting to be loaded
  35319. */
  35320. getWaitingItemsCount(): number;
  35321. /**
  35322. * Returns a boolean indicating if the scene is still loading data
  35323. */
  35324. readonly isLoading: boolean;
  35325. /**
  35326. * Registers a function to be executed when the scene is ready
  35327. * @param {Function} func - the function to be executed
  35328. */
  35329. executeWhenReady(func: () => void): void;
  35330. /**
  35331. * Returns a promise that resolves when the scene is ready
  35332. * @returns A promise that resolves when the scene is ready
  35333. */
  35334. whenReadyAsync(): Promise<void>;
  35335. /** @hidden */
  35336. _checkIsReady(): void;
  35337. /**
  35338. * Gets all animatable attached to the scene
  35339. */
  35340. readonly animatables: Animatable[];
  35341. /**
  35342. * Resets the last animation time frame.
  35343. * Useful to override when animations start running when loading a scene for the first time.
  35344. */
  35345. resetLastAnimationTimeFrame(): void;
  35346. /**
  35347. * Gets the current view matrix
  35348. * @returns a Matrix
  35349. */
  35350. getViewMatrix(): Matrix;
  35351. /**
  35352. * Gets the current projection matrix
  35353. * @returns a Matrix
  35354. */
  35355. getProjectionMatrix(): Matrix;
  35356. /**
  35357. * Gets the current transform matrix
  35358. * @returns a Matrix made of View * Projection
  35359. */
  35360. getTransformMatrix(): Matrix;
  35361. /**
  35362. * Sets the current transform matrix
  35363. * @param viewL defines the View matrix to use
  35364. * @param projectionL defines the Projection matrix to use
  35365. * @param viewR defines the right View matrix to use (if provided)
  35366. * @param projectionR defines the right Projection matrix to use (if provided)
  35367. */
  35368. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35369. /**
  35370. * Gets the uniform buffer used to store scene data
  35371. * @returns a UniformBuffer
  35372. */
  35373. getSceneUniformBuffer(): UniformBuffer;
  35374. /**
  35375. * Gets an unique (relatively to the current scene) Id
  35376. * @returns an unique number for the scene
  35377. */
  35378. getUniqueId(): number;
  35379. /**
  35380. * Add a mesh to the list of scene's meshes
  35381. * @param newMesh defines the mesh to add
  35382. * @param recursive if all child meshes should also be added to the scene
  35383. */
  35384. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35385. /**
  35386. * Remove a mesh for the list of scene's meshes
  35387. * @param toRemove defines the mesh to remove
  35388. * @param recursive if all child meshes should also be removed from the scene
  35389. * @returns the index where the mesh was in the mesh list
  35390. */
  35391. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35392. /**
  35393. * Add a transform node to the list of scene's transform nodes
  35394. * @param newTransformNode defines the transform node to add
  35395. */
  35396. addTransformNode(newTransformNode: TransformNode): void;
  35397. /**
  35398. * Remove a transform node for the list of scene's transform nodes
  35399. * @param toRemove defines the transform node to remove
  35400. * @returns the index where the transform node was in the transform node list
  35401. */
  35402. removeTransformNode(toRemove: TransformNode): number;
  35403. /**
  35404. * Remove a skeleton for the list of scene's skeletons
  35405. * @param toRemove defines the skeleton to remove
  35406. * @returns the index where the skeleton was in the skeleton list
  35407. */
  35408. removeSkeleton(toRemove: Skeleton): number;
  35409. /**
  35410. * Remove a morph target for the list of scene's morph targets
  35411. * @param toRemove defines the morph target to remove
  35412. * @returns the index where the morph target was in the morph target list
  35413. */
  35414. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35415. /**
  35416. * Remove a light for the list of scene's lights
  35417. * @param toRemove defines the light to remove
  35418. * @returns the index where the light was in the light list
  35419. */
  35420. removeLight(toRemove: Light): number;
  35421. /**
  35422. * Remove a camera for the list of scene's cameras
  35423. * @param toRemove defines the camera to remove
  35424. * @returns the index where the camera was in the camera list
  35425. */
  35426. removeCamera(toRemove: Camera): number;
  35427. /**
  35428. * Remove a particle system for the list of scene's particle systems
  35429. * @param toRemove defines the particle system to remove
  35430. * @returns the index where the particle system was in the particle system list
  35431. */
  35432. removeParticleSystem(toRemove: IParticleSystem): number;
  35433. /**
  35434. * Remove a animation for the list of scene's animations
  35435. * @param toRemove defines the animation to remove
  35436. * @returns the index where the animation was in the animation list
  35437. */
  35438. removeAnimation(toRemove: Animation): number;
  35439. /**
  35440. * Will stop the animation of the given target
  35441. * @param target - the target
  35442. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35443. * @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)
  35444. */
  35445. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35446. /**
  35447. * Removes the given animation group from this scene.
  35448. * @param toRemove The animation group to remove
  35449. * @returns The index of the removed animation group
  35450. */
  35451. removeAnimationGroup(toRemove: AnimationGroup): number;
  35452. /**
  35453. * Removes the given multi-material from this scene.
  35454. * @param toRemove The multi-material to remove
  35455. * @returns The index of the removed multi-material
  35456. */
  35457. removeMultiMaterial(toRemove: MultiMaterial): number;
  35458. /**
  35459. * Removes the given material from this scene.
  35460. * @param toRemove The material to remove
  35461. * @returns The index of the removed material
  35462. */
  35463. removeMaterial(toRemove: Material): number;
  35464. /**
  35465. * Removes the given action manager from this scene.
  35466. * @param toRemove The action manager to remove
  35467. * @returns The index of the removed action manager
  35468. */
  35469. removeActionManager(toRemove: AbstractActionManager): number;
  35470. /**
  35471. * Removes the given texture from this scene.
  35472. * @param toRemove The texture to remove
  35473. * @returns The index of the removed texture
  35474. */
  35475. removeTexture(toRemove: BaseTexture): number;
  35476. /**
  35477. * Adds the given light to this scene
  35478. * @param newLight The light to add
  35479. */
  35480. addLight(newLight: Light): void;
  35481. /**
  35482. * Sorts the list list based on light priorities
  35483. */
  35484. sortLightsByPriority(): void;
  35485. /**
  35486. * Adds the given camera to this scene
  35487. * @param newCamera The camera to add
  35488. */
  35489. addCamera(newCamera: Camera): void;
  35490. /**
  35491. * Adds the given skeleton to this scene
  35492. * @param newSkeleton The skeleton to add
  35493. */
  35494. addSkeleton(newSkeleton: Skeleton): void;
  35495. /**
  35496. * Adds the given particle system to this scene
  35497. * @param newParticleSystem The particle system to add
  35498. */
  35499. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35500. /**
  35501. * Adds the given animation to this scene
  35502. * @param newAnimation The animation to add
  35503. */
  35504. addAnimation(newAnimation: Animation): void;
  35505. /**
  35506. * Adds the given animation group to this scene.
  35507. * @param newAnimationGroup The animation group to add
  35508. */
  35509. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35510. /**
  35511. * Adds the given multi-material to this scene
  35512. * @param newMultiMaterial The multi-material to add
  35513. */
  35514. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35515. /**
  35516. * Adds the given material to this scene
  35517. * @param newMaterial The material to add
  35518. */
  35519. addMaterial(newMaterial: Material): void;
  35520. /**
  35521. * Adds the given morph target to this scene
  35522. * @param newMorphTargetManager The morph target to add
  35523. */
  35524. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35525. /**
  35526. * Adds the given geometry to this scene
  35527. * @param newGeometry The geometry to add
  35528. */
  35529. addGeometry(newGeometry: Geometry): void;
  35530. /**
  35531. * Adds the given action manager to this scene
  35532. * @param newActionManager The action manager to add
  35533. */
  35534. addActionManager(newActionManager: AbstractActionManager): void;
  35535. /**
  35536. * Adds the given texture to this scene.
  35537. * @param newTexture The texture to add
  35538. */
  35539. addTexture(newTexture: BaseTexture): void;
  35540. /**
  35541. * Switch active camera
  35542. * @param newCamera defines the new active camera
  35543. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35544. */
  35545. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35546. /**
  35547. * sets the active camera of the scene using its ID
  35548. * @param id defines the camera's ID
  35549. * @return the new active camera or null if none found.
  35550. */
  35551. setActiveCameraByID(id: string): Nullable<Camera>;
  35552. /**
  35553. * sets the active camera of the scene using its name
  35554. * @param name defines the camera's name
  35555. * @returns the new active camera or null if none found.
  35556. */
  35557. setActiveCameraByName(name: string): Nullable<Camera>;
  35558. /**
  35559. * get an animation group using its name
  35560. * @param name defines the material's name
  35561. * @return the animation group or null if none found.
  35562. */
  35563. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35564. /**
  35565. * Get a material using its unique id
  35566. * @param uniqueId defines the material's unique id
  35567. * @return the material or null if none found.
  35568. */
  35569. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35570. /**
  35571. * get a material using its id
  35572. * @param id defines the material's ID
  35573. * @return the material or null if none found.
  35574. */
  35575. getMaterialByID(id: string): Nullable<Material>;
  35576. /**
  35577. * Gets a the last added material using a given id
  35578. * @param id defines the material's ID
  35579. * @return the last material with the given id or null if none found.
  35580. */
  35581. getLastMaterialByID(id: string): Nullable<Material>;
  35582. /**
  35583. * Gets a material using its name
  35584. * @param name defines the material's name
  35585. * @return the material or null if none found.
  35586. */
  35587. getMaterialByName(name: string): Nullable<Material>;
  35588. /**
  35589. * Get a texture using its unique id
  35590. * @param uniqueId defines the texture's unique id
  35591. * @return the texture or null if none found.
  35592. */
  35593. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35594. /**
  35595. * Gets a camera using its id
  35596. * @param id defines the id to look for
  35597. * @returns the camera or null if not found
  35598. */
  35599. getCameraByID(id: string): Nullable<Camera>;
  35600. /**
  35601. * Gets a camera using its unique id
  35602. * @param uniqueId defines the unique id to look for
  35603. * @returns the camera or null if not found
  35604. */
  35605. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35606. /**
  35607. * Gets a camera using its name
  35608. * @param name defines the camera's name
  35609. * @return the camera or null if none found.
  35610. */
  35611. getCameraByName(name: string): Nullable<Camera>;
  35612. /**
  35613. * Gets a bone using its id
  35614. * @param id defines the bone's id
  35615. * @return the bone or null if not found
  35616. */
  35617. getBoneByID(id: string): Nullable<Bone>;
  35618. /**
  35619. * Gets a bone using its id
  35620. * @param name defines the bone's name
  35621. * @return the bone or null if not found
  35622. */
  35623. getBoneByName(name: string): Nullable<Bone>;
  35624. /**
  35625. * Gets a light node using its name
  35626. * @param name defines the the light's name
  35627. * @return the light or null if none found.
  35628. */
  35629. getLightByName(name: string): Nullable<Light>;
  35630. /**
  35631. * Gets a light node using its id
  35632. * @param id defines the light's id
  35633. * @return the light or null if none found.
  35634. */
  35635. getLightByID(id: string): Nullable<Light>;
  35636. /**
  35637. * Gets a light node using its scene-generated unique ID
  35638. * @param uniqueId defines the light's unique id
  35639. * @return the light or null if none found.
  35640. */
  35641. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35642. /**
  35643. * Gets a particle system by id
  35644. * @param id defines the particle system id
  35645. * @return the corresponding system or null if none found
  35646. */
  35647. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35648. /**
  35649. * Gets a geometry using its ID
  35650. * @param id defines the geometry's id
  35651. * @return the geometry or null if none found.
  35652. */
  35653. getGeometryByID(id: string): Nullable<Geometry>;
  35654. private _getGeometryByUniqueID;
  35655. /**
  35656. * Add a new geometry to this scene
  35657. * @param geometry defines the geometry to be added to the scene.
  35658. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35659. * @return a boolean defining if the geometry was added or not
  35660. */
  35661. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35662. /**
  35663. * Removes an existing geometry
  35664. * @param geometry defines the geometry to be removed from the scene
  35665. * @return a boolean defining if the geometry was removed or not
  35666. */
  35667. removeGeometry(geometry: Geometry): boolean;
  35668. /**
  35669. * Gets the list of geometries attached to the scene
  35670. * @returns an array of Geometry
  35671. */
  35672. getGeometries(): Geometry[];
  35673. /**
  35674. * Gets the first added mesh found of a given ID
  35675. * @param id defines the id to search for
  35676. * @return the mesh found or null if not found at all
  35677. */
  35678. getMeshByID(id: string): Nullable<AbstractMesh>;
  35679. /**
  35680. * Gets a list of meshes using their id
  35681. * @param id defines the id to search for
  35682. * @returns a list of meshes
  35683. */
  35684. getMeshesByID(id: string): Array<AbstractMesh>;
  35685. /**
  35686. * Gets the first added transform node found of a given ID
  35687. * @param id defines the id to search for
  35688. * @return the found transform node or null if not found at all.
  35689. */
  35690. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35691. /**
  35692. * Gets a transform node with its auto-generated unique id
  35693. * @param uniqueId efines the unique id to search for
  35694. * @return the found transform node or null if not found at all.
  35695. */
  35696. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35697. /**
  35698. * Gets a list of transform nodes using their id
  35699. * @param id defines the id to search for
  35700. * @returns a list of transform nodes
  35701. */
  35702. getTransformNodesByID(id: string): Array<TransformNode>;
  35703. /**
  35704. * Gets a mesh with its auto-generated unique id
  35705. * @param uniqueId defines the unique id to search for
  35706. * @return the found mesh or null if not found at all.
  35707. */
  35708. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35709. /**
  35710. * Gets a the last added mesh using a given id
  35711. * @param id defines the id to search for
  35712. * @return the found mesh or null if not found at all.
  35713. */
  35714. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35715. /**
  35716. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35717. * @param id defines the id to search for
  35718. * @return the found node or null if not found at all
  35719. */
  35720. getLastEntryByID(id: string): Nullable<Node>;
  35721. /**
  35722. * Gets a node (Mesh, Camera, Light) using a given id
  35723. * @param id defines the id to search for
  35724. * @return the found node or null if not found at all
  35725. */
  35726. getNodeByID(id: string): Nullable<Node>;
  35727. /**
  35728. * Gets a node (Mesh, Camera, Light) using a given name
  35729. * @param name defines the name to search for
  35730. * @return the found node or null if not found at all.
  35731. */
  35732. getNodeByName(name: string): Nullable<Node>;
  35733. /**
  35734. * Gets a mesh using a given name
  35735. * @param name defines the name to search for
  35736. * @return the found mesh or null if not found at all.
  35737. */
  35738. getMeshByName(name: string): Nullable<AbstractMesh>;
  35739. /**
  35740. * Gets a transform node using a given name
  35741. * @param name defines the name to search for
  35742. * @return the found transform node or null if not found at all.
  35743. */
  35744. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35745. /**
  35746. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35747. * @param id defines the id to search for
  35748. * @return the found skeleton or null if not found at all.
  35749. */
  35750. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35751. /**
  35752. * Gets a skeleton using a given auto generated unique id
  35753. * @param uniqueId defines the unique id to search for
  35754. * @return the found skeleton or null if not found at all.
  35755. */
  35756. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35757. /**
  35758. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35759. * @param id defines the id to search for
  35760. * @return the found skeleton or null if not found at all.
  35761. */
  35762. getSkeletonById(id: string): Nullable<Skeleton>;
  35763. /**
  35764. * Gets a skeleton using a given name
  35765. * @param name defines the name to search for
  35766. * @return the found skeleton or null if not found at all.
  35767. */
  35768. getSkeletonByName(name: string): Nullable<Skeleton>;
  35769. /**
  35770. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35771. * @param id defines the id to search for
  35772. * @return the found morph target manager or null if not found at all.
  35773. */
  35774. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35775. /**
  35776. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35777. * @param id defines the id to search for
  35778. * @return the found morph target or null if not found at all.
  35779. */
  35780. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35781. /**
  35782. * Gets a boolean indicating if the given mesh is active
  35783. * @param mesh defines the mesh to look for
  35784. * @returns true if the mesh is in the active list
  35785. */
  35786. isActiveMesh(mesh: AbstractMesh): boolean;
  35787. /**
  35788. * Return a unique id as a string which can serve as an identifier for the scene
  35789. */
  35790. readonly uid: string;
  35791. /**
  35792. * Add an externaly attached data from its key.
  35793. * This method call will fail and return false, if such key already exists.
  35794. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35795. * @param key the unique key that identifies the data
  35796. * @param data the data object to associate to the key for this Engine instance
  35797. * @return true if no such key were already present and the data was added successfully, false otherwise
  35798. */
  35799. addExternalData<T>(key: string, data: T): boolean;
  35800. /**
  35801. * Get an externaly attached data from its key
  35802. * @param key the unique key that identifies the data
  35803. * @return the associated data, if present (can be null), or undefined if not present
  35804. */
  35805. getExternalData<T>(key: string): Nullable<T>;
  35806. /**
  35807. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35808. * @param key the unique key that identifies the data
  35809. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35810. * @return the associated data, can be null if the factory returned null.
  35811. */
  35812. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35813. /**
  35814. * Remove an externaly attached data from the Engine instance
  35815. * @param key the unique key that identifies the data
  35816. * @return true if the data was successfully removed, false if it doesn't exist
  35817. */
  35818. removeExternalData(key: string): boolean;
  35819. private _evaluateSubMesh;
  35820. /**
  35821. * Clear the processed materials smart array preventing retention point in material dispose.
  35822. */
  35823. freeProcessedMaterials(): void;
  35824. private _preventFreeActiveMeshesAndRenderingGroups;
  35825. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35826. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35827. * when disposing several meshes in a row or a hierarchy of meshes.
  35828. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35829. */
  35830. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35831. /**
  35832. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35833. */
  35834. freeActiveMeshes(): void;
  35835. /**
  35836. * Clear the info related to rendering groups preventing retention points during dispose.
  35837. */
  35838. freeRenderingGroups(): void;
  35839. /** @hidden */
  35840. _isInIntermediateRendering(): boolean;
  35841. /**
  35842. * Lambda returning the list of potentially active meshes.
  35843. */
  35844. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35845. /**
  35846. * Lambda returning the list of potentially active sub meshes.
  35847. */
  35848. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35849. /**
  35850. * Lambda returning the list of potentially intersecting sub meshes.
  35851. */
  35852. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35853. /**
  35854. * Lambda returning the list of potentially colliding sub meshes.
  35855. */
  35856. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35857. private _activeMeshesFrozen;
  35858. /**
  35859. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35860. * @returns the current scene
  35861. */
  35862. freezeActiveMeshes(): Scene;
  35863. /**
  35864. * Use this function to restart evaluating active meshes on every frame
  35865. * @returns the current scene
  35866. */
  35867. unfreezeActiveMeshes(): Scene;
  35868. private _evaluateActiveMeshes;
  35869. private _activeMesh;
  35870. /**
  35871. * Update the transform matrix to update from the current active camera
  35872. * @param force defines a boolean used to force the update even if cache is up to date
  35873. */
  35874. updateTransformMatrix(force?: boolean): void;
  35875. private _bindFrameBuffer;
  35876. /** @hidden */
  35877. _allowPostProcessClearColor: boolean;
  35878. /** @hidden */
  35879. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35880. private _processSubCameras;
  35881. private _checkIntersections;
  35882. /** @hidden */
  35883. _advancePhysicsEngineStep(step: number): void;
  35884. /**
  35885. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35886. */
  35887. getDeterministicFrameTime: () => number;
  35888. /** @hidden */
  35889. _animate(): void;
  35890. /** Execute all animations (for a frame) */
  35891. animate(): void;
  35892. /**
  35893. * Render the scene
  35894. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35895. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35896. */
  35897. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35898. /**
  35899. * Freeze all materials
  35900. * A frozen material will not be updatable but should be faster to render
  35901. */
  35902. freezeMaterials(): void;
  35903. /**
  35904. * Unfreeze all materials
  35905. * A frozen material will not be updatable but should be faster to render
  35906. */
  35907. unfreezeMaterials(): void;
  35908. /**
  35909. * Releases all held ressources
  35910. */
  35911. dispose(): void;
  35912. /**
  35913. * Gets if the scene is already disposed
  35914. */
  35915. readonly isDisposed: boolean;
  35916. /**
  35917. * Call this function to reduce memory footprint of the scene.
  35918. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35919. */
  35920. clearCachedVertexData(): void;
  35921. /**
  35922. * This function will remove the local cached buffer data from texture.
  35923. * It will save memory but will prevent the texture from being rebuilt
  35924. */
  35925. cleanCachedTextureBuffer(): void;
  35926. /**
  35927. * Get the world extend vectors with an optional filter
  35928. *
  35929. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35930. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35931. */
  35932. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35933. min: Vector3;
  35934. max: Vector3;
  35935. };
  35936. /**
  35937. * Creates a ray that can be used to pick in the scene
  35938. * @param x defines the x coordinate of the origin (on-screen)
  35939. * @param y defines the y coordinate of the origin (on-screen)
  35940. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35941. * @param camera defines the camera to use for the picking
  35942. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35943. * @returns a Ray
  35944. */
  35945. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35946. /**
  35947. * Creates a ray that can be used to pick in the scene
  35948. * @param x defines the x coordinate of the origin (on-screen)
  35949. * @param y defines the y coordinate of the origin (on-screen)
  35950. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35951. * @param result defines the ray where to store the picking ray
  35952. * @param camera defines the camera to use for the picking
  35953. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35954. * @returns the current scene
  35955. */
  35956. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35957. /**
  35958. * Creates a ray that can be used to pick in the scene
  35959. * @param x defines the x coordinate of the origin (on-screen)
  35960. * @param y defines the y coordinate of the origin (on-screen)
  35961. * @param camera defines the camera to use for the picking
  35962. * @returns a Ray
  35963. */
  35964. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35965. /**
  35966. * Creates a ray that can be used to pick in the scene
  35967. * @param x defines the x coordinate of the origin (on-screen)
  35968. * @param y defines the y coordinate of the origin (on-screen)
  35969. * @param result defines the ray where to store the picking ray
  35970. * @param camera defines the camera to use for the picking
  35971. * @returns the current scene
  35972. */
  35973. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35974. /** Launch a ray to try to pick a mesh in the scene
  35975. * @param x position on screen
  35976. * @param y position on screen
  35977. * @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
  35978. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35979. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35980. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35981. * @returns a PickingInfo
  35982. */
  35983. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35984. /** Use the given ray to pick a mesh in the scene
  35985. * @param ray The ray to use to pick meshes
  35986. * @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
  35987. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35988. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35989. * @returns a PickingInfo
  35990. */
  35991. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35992. /**
  35993. * Launch a ray to try to pick a mesh in the scene
  35994. * @param x X position on screen
  35995. * @param y Y position on screen
  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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35998. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35999. * @returns an array of PickingInfo
  36000. */
  36001. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36002. /**
  36003. * Launch a ray to try to pick a mesh in the scene
  36004. * @param ray Ray to use
  36005. * @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
  36006. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36007. * @returns an array of PickingInfo
  36008. */
  36009. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36010. /**
  36011. * Force the value of meshUnderPointer
  36012. * @param mesh defines the mesh to use
  36013. */
  36014. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36015. /**
  36016. * Gets the mesh under the pointer
  36017. * @returns a Mesh or null if no mesh is under the pointer
  36018. */
  36019. getPointerOverMesh(): Nullable<AbstractMesh>;
  36020. /** @hidden */
  36021. _rebuildGeometries(): void;
  36022. /** @hidden */
  36023. _rebuildTextures(): void;
  36024. private _getByTags;
  36025. /**
  36026. * Get a list of meshes by tags
  36027. * @param tagsQuery defines the tags query to use
  36028. * @param forEach defines a predicate used to filter results
  36029. * @returns an array of Mesh
  36030. */
  36031. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36032. /**
  36033. * Get a list of cameras by tags
  36034. * @param tagsQuery defines the tags query to use
  36035. * @param forEach defines a predicate used to filter results
  36036. * @returns an array of Camera
  36037. */
  36038. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36039. /**
  36040. * Get a list of lights by tags
  36041. * @param tagsQuery defines the tags query to use
  36042. * @param forEach defines a predicate used to filter results
  36043. * @returns an array of Light
  36044. */
  36045. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36046. /**
  36047. * Get a list of materials by tags
  36048. * @param tagsQuery defines the tags query to use
  36049. * @param forEach defines a predicate used to filter results
  36050. * @returns an array of Material
  36051. */
  36052. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36053. /**
  36054. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36055. * This allowed control for front to back rendering or reversly depending of the special needs.
  36056. *
  36057. * @param renderingGroupId The rendering group id corresponding to its index
  36058. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36059. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36060. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36061. */
  36062. 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;
  36063. /**
  36064. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36065. *
  36066. * @param renderingGroupId The rendering group id corresponding to its index
  36067. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36068. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36069. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36070. */
  36071. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36072. /**
  36073. * Gets the current auto clear configuration for one rendering group of the rendering
  36074. * manager.
  36075. * @param index the rendering group index to get the information for
  36076. * @returns The auto clear setup for the requested rendering group
  36077. */
  36078. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36079. private _blockMaterialDirtyMechanism;
  36080. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36081. blockMaterialDirtyMechanism: boolean;
  36082. /**
  36083. * Will flag all materials as dirty to trigger new shader compilation
  36084. * @param flag defines the flag used to specify which material part must be marked as dirty
  36085. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36086. */
  36087. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36088. /** @hidden */
  36089. _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;
  36090. /** @hidden */
  36091. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36092. /** @hidden */
  36093. _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;
  36094. /** @hidden */
  36095. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36096. /** @hidden */
  36097. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36098. /** @hidden */
  36099. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36100. }
  36101. }
  36102. declare module "babylonjs/assetContainer" {
  36103. import { AbstractScene } from "babylonjs/abstractScene";
  36104. import { Scene } from "babylonjs/scene";
  36105. import { Mesh } from "babylonjs/Meshes/mesh";
  36106. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36107. import { Skeleton } from "babylonjs/Bones/skeleton";
  36108. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36109. /**
  36110. * Set of assets to keep when moving a scene into an asset container.
  36111. */
  36112. export class KeepAssets extends AbstractScene {
  36113. }
  36114. /**
  36115. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36116. */
  36117. export class InstantiatedEntries {
  36118. /**
  36119. * List of new root nodes (eg. nodes with no parent)
  36120. */
  36121. rootNodes: TransformNode[];
  36122. /**
  36123. * List of new skeletons
  36124. */
  36125. skeletons: Skeleton[];
  36126. /**
  36127. * List of new animation groups
  36128. */
  36129. animationGroups: AnimationGroup[];
  36130. }
  36131. /**
  36132. * Container with a set of assets that can be added or removed from a scene.
  36133. */
  36134. export class AssetContainer extends AbstractScene {
  36135. /**
  36136. * The scene the AssetContainer belongs to.
  36137. */
  36138. scene: Scene;
  36139. /**
  36140. * Instantiates an AssetContainer.
  36141. * @param scene The scene the AssetContainer belongs to.
  36142. */
  36143. constructor(scene: Scene);
  36144. /**
  36145. * Instantiate or clone all meshes and add the new ones to the scene.
  36146. * Skeletons and animation groups will all be cloned
  36147. * @param nameFunction defines an optional function used to get new names for clones
  36148. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36149. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36150. */
  36151. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36152. /**
  36153. * Adds all the assets from the container to the scene.
  36154. */
  36155. addAllToScene(): void;
  36156. /**
  36157. * Removes all the assets in the container from the scene
  36158. */
  36159. removeAllFromScene(): void;
  36160. /**
  36161. * Disposes all the assets in the container
  36162. */
  36163. dispose(): void;
  36164. private _moveAssets;
  36165. /**
  36166. * Removes all the assets contained in the scene and adds them to the container.
  36167. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36168. */
  36169. moveAllFromScene(keepAssets?: KeepAssets): void;
  36170. /**
  36171. * 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.
  36172. * @returns the root mesh
  36173. */
  36174. createRootMesh(): Mesh;
  36175. }
  36176. }
  36177. declare module "babylonjs/abstractScene" {
  36178. import { Scene } from "babylonjs/scene";
  36179. import { Nullable } from "babylonjs/types";
  36180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36181. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36182. import { Geometry } from "babylonjs/Meshes/geometry";
  36183. import { Skeleton } from "babylonjs/Bones/skeleton";
  36184. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36185. import { AssetContainer } from "babylonjs/assetContainer";
  36186. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36187. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36189. import { Material } from "babylonjs/Materials/material";
  36190. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36191. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36192. import { Camera } from "babylonjs/Cameras/camera";
  36193. import { Light } from "babylonjs/Lights/light";
  36194. import { Node } from "babylonjs/node";
  36195. import { Animation } from "babylonjs/Animations/animation";
  36196. /**
  36197. * Defines how the parser contract is defined.
  36198. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36199. */
  36200. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36201. /**
  36202. * Defines how the individual parser contract is defined.
  36203. * These parser can parse an individual asset
  36204. */
  36205. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36206. /**
  36207. * Base class of the scene acting as a container for the different elements composing a scene.
  36208. * This class is dynamically extended by the different components of the scene increasing
  36209. * flexibility and reducing coupling
  36210. */
  36211. export abstract class AbstractScene {
  36212. /**
  36213. * Stores the list of available parsers in the application.
  36214. */
  36215. private static _BabylonFileParsers;
  36216. /**
  36217. * Stores the list of available individual parsers in the application.
  36218. */
  36219. private static _IndividualBabylonFileParsers;
  36220. /**
  36221. * Adds a parser in the list of available ones
  36222. * @param name Defines the name of the parser
  36223. * @param parser Defines the parser to add
  36224. */
  36225. static AddParser(name: string, parser: BabylonFileParser): void;
  36226. /**
  36227. * Gets a general parser from the list of avaialble ones
  36228. * @param name Defines the name of the parser
  36229. * @returns the requested parser or null
  36230. */
  36231. static GetParser(name: string): Nullable<BabylonFileParser>;
  36232. /**
  36233. * Adds n individual parser in the list of available ones
  36234. * @param name Defines the name of the parser
  36235. * @param parser Defines the parser to add
  36236. */
  36237. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36238. /**
  36239. * Gets an individual parser from the list of avaialble ones
  36240. * @param name Defines the name of the parser
  36241. * @returns the requested parser or null
  36242. */
  36243. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36244. /**
  36245. * Parser json data and populate both a scene and its associated container object
  36246. * @param jsonData Defines the data to parse
  36247. * @param scene Defines the scene to parse the data for
  36248. * @param container Defines the container attached to the parsing sequence
  36249. * @param rootUrl Defines the root url of the data
  36250. */
  36251. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36252. /**
  36253. * Gets the list of root nodes (ie. nodes with no parent)
  36254. */
  36255. rootNodes: Node[];
  36256. /** All of the cameras added to this scene
  36257. * @see http://doc.babylonjs.com/babylon101/cameras
  36258. */
  36259. cameras: Camera[];
  36260. /**
  36261. * All of the lights added to this scene
  36262. * @see http://doc.babylonjs.com/babylon101/lights
  36263. */
  36264. lights: Light[];
  36265. /**
  36266. * All of the (abstract) meshes added to this scene
  36267. */
  36268. meshes: AbstractMesh[];
  36269. /**
  36270. * The list of skeletons added to the scene
  36271. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36272. */
  36273. skeletons: Skeleton[];
  36274. /**
  36275. * All of the particle systems added to this scene
  36276. * @see http://doc.babylonjs.com/babylon101/particles
  36277. */
  36278. particleSystems: IParticleSystem[];
  36279. /**
  36280. * Gets a list of Animations associated with the scene
  36281. */
  36282. animations: Animation[];
  36283. /**
  36284. * All of the animation groups added to this scene
  36285. * @see http://doc.babylonjs.com/how_to/group
  36286. */
  36287. animationGroups: AnimationGroup[];
  36288. /**
  36289. * All of the multi-materials added to this scene
  36290. * @see http://doc.babylonjs.com/how_to/multi_materials
  36291. */
  36292. multiMaterials: MultiMaterial[];
  36293. /**
  36294. * All of the materials added to this scene
  36295. * In the context of a Scene, it is not supposed to be modified manually.
  36296. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36297. * Note also that the order of the Material within the array is not significant and might change.
  36298. * @see http://doc.babylonjs.com/babylon101/materials
  36299. */
  36300. materials: Material[];
  36301. /**
  36302. * The list of morph target managers added to the scene
  36303. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36304. */
  36305. morphTargetManagers: MorphTargetManager[];
  36306. /**
  36307. * The list of geometries used in the scene.
  36308. */
  36309. geometries: Geometry[];
  36310. /**
  36311. * All of the tranform nodes added to this scene
  36312. * In the context of a Scene, it is not supposed to be modified manually.
  36313. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36314. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36315. * @see http://doc.babylonjs.com/how_to/transformnode
  36316. */
  36317. transformNodes: TransformNode[];
  36318. /**
  36319. * ActionManagers available on the scene.
  36320. */
  36321. actionManagers: AbstractActionManager[];
  36322. /**
  36323. * Textures to keep.
  36324. */
  36325. textures: BaseTexture[];
  36326. /**
  36327. * Environment texture for the scene
  36328. */
  36329. environmentTexture: Nullable<BaseTexture>;
  36330. }
  36331. }
  36332. declare module "babylonjs/Audio/sound" {
  36333. import { Observable } from "babylonjs/Misc/observable";
  36334. import { Vector3 } from "babylonjs/Maths/math.vector";
  36335. import { Nullable } from "babylonjs/types";
  36336. import { Scene } from "babylonjs/scene";
  36337. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36338. /**
  36339. * Interface used to define options for Sound class
  36340. */
  36341. export interface ISoundOptions {
  36342. /**
  36343. * Does the sound autoplay once loaded.
  36344. */
  36345. autoplay?: boolean;
  36346. /**
  36347. * Does the sound loop after it finishes playing once.
  36348. */
  36349. loop?: boolean;
  36350. /**
  36351. * Sound's volume
  36352. */
  36353. volume?: number;
  36354. /**
  36355. * Is it a spatial sound?
  36356. */
  36357. spatialSound?: boolean;
  36358. /**
  36359. * Maximum distance to hear that sound
  36360. */
  36361. maxDistance?: number;
  36362. /**
  36363. * Uses user defined attenuation function
  36364. */
  36365. useCustomAttenuation?: boolean;
  36366. /**
  36367. * Define the roll off factor of spatial sounds.
  36368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36369. */
  36370. rolloffFactor?: number;
  36371. /**
  36372. * Define the reference distance the sound should be heard perfectly.
  36373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36374. */
  36375. refDistance?: number;
  36376. /**
  36377. * Define the distance attenuation model the sound will follow.
  36378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36379. */
  36380. distanceModel?: string;
  36381. /**
  36382. * Defines the playback speed (1 by default)
  36383. */
  36384. playbackRate?: number;
  36385. /**
  36386. * Defines if the sound is from a streaming source
  36387. */
  36388. streaming?: boolean;
  36389. /**
  36390. * Defines an optional length (in seconds) inside the sound file
  36391. */
  36392. length?: number;
  36393. /**
  36394. * Defines an optional offset (in seconds) inside the sound file
  36395. */
  36396. offset?: number;
  36397. /**
  36398. * If true, URLs will not be required to state the audio file codec to use.
  36399. */
  36400. skipCodecCheck?: boolean;
  36401. }
  36402. /**
  36403. * Defines a sound that can be played in the application.
  36404. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36406. */
  36407. export class Sound {
  36408. /**
  36409. * The name of the sound in the scene.
  36410. */
  36411. name: string;
  36412. /**
  36413. * Does the sound autoplay once loaded.
  36414. */
  36415. autoplay: boolean;
  36416. /**
  36417. * Does the sound loop after it finishes playing once.
  36418. */
  36419. loop: boolean;
  36420. /**
  36421. * Does the sound use a custom attenuation curve to simulate the falloff
  36422. * happening when the source gets further away from the camera.
  36423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36424. */
  36425. useCustomAttenuation: boolean;
  36426. /**
  36427. * The sound track id this sound belongs to.
  36428. */
  36429. soundTrackId: number;
  36430. /**
  36431. * Is this sound currently played.
  36432. */
  36433. isPlaying: boolean;
  36434. /**
  36435. * Is this sound currently paused.
  36436. */
  36437. isPaused: boolean;
  36438. /**
  36439. * Does this sound enables spatial sound.
  36440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36441. */
  36442. spatialSound: boolean;
  36443. /**
  36444. * Define the reference distance the sound should be heard perfectly.
  36445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36446. */
  36447. refDistance: number;
  36448. /**
  36449. * Define the roll off factor of spatial sounds.
  36450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36451. */
  36452. rolloffFactor: number;
  36453. /**
  36454. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36456. */
  36457. maxDistance: number;
  36458. /**
  36459. * Define the distance attenuation model the sound will follow.
  36460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36461. */
  36462. distanceModel: string;
  36463. /**
  36464. * @hidden
  36465. * Back Compat
  36466. **/
  36467. onended: () => any;
  36468. /**
  36469. * Observable event when the current playing sound finishes.
  36470. */
  36471. onEndedObservable: Observable<Sound>;
  36472. private _panningModel;
  36473. private _playbackRate;
  36474. private _streaming;
  36475. private _startTime;
  36476. private _startOffset;
  36477. private _position;
  36478. /** @hidden */
  36479. _positionInEmitterSpace: boolean;
  36480. private _localDirection;
  36481. private _volume;
  36482. private _isReadyToPlay;
  36483. private _isDirectional;
  36484. private _readyToPlayCallback;
  36485. private _audioBuffer;
  36486. private _soundSource;
  36487. private _streamingSource;
  36488. private _soundPanner;
  36489. private _soundGain;
  36490. private _inputAudioNode;
  36491. private _outputAudioNode;
  36492. private _coneInnerAngle;
  36493. private _coneOuterAngle;
  36494. private _coneOuterGain;
  36495. private _scene;
  36496. private _connectedTransformNode;
  36497. private _customAttenuationFunction;
  36498. private _registerFunc;
  36499. private _isOutputConnected;
  36500. private _htmlAudioElement;
  36501. private _urlType;
  36502. private _length?;
  36503. private _offset?;
  36504. /** @hidden */
  36505. static _SceneComponentInitialization: (scene: Scene) => void;
  36506. /**
  36507. * Create a sound and attach it to a scene
  36508. * @param name Name of your sound
  36509. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36510. * @param scene defines the scene the sound belongs to
  36511. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36512. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36513. */
  36514. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36515. /**
  36516. * Release the sound and its associated resources
  36517. */
  36518. dispose(): void;
  36519. /**
  36520. * Gets if the sounds is ready to be played or not.
  36521. * @returns true if ready, otherwise false
  36522. */
  36523. isReady(): boolean;
  36524. private _soundLoaded;
  36525. /**
  36526. * Sets the data of the sound from an audiobuffer
  36527. * @param audioBuffer The audioBuffer containing the data
  36528. */
  36529. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36530. /**
  36531. * Updates the current sounds options such as maxdistance, loop...
  36532. * @param options A JSON object containing values named as the object properties
  36533. */
  36534. updateOptions(options: ISoundOptions): void;
  36535. private _createSpatialParameters;
  36536. private _updateSpatialParameters;
  36537. /**
  36538. * Switch the panning model to HRTF:
  36539. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36541. */
  36542. switchPanningModelToHRTF(): void;
  36543. /**
  36544. * Switch the panning model to Equal Power:
  36545. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36547. */
  36548. switchPanningModelToEqualPower(): void;
  36549. private _switchPanningModel;
  36550. /**
  36551. * Connect this sound to a sound track audio node like gain...
  36552. * @param soundTrackAudioNode the sound track audio node to connect to
  36553. */
  36554. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36555. /**
  36556. * Transform this sound into a directional source
  36557. * @param coneInnerAngle Size of the inner cone in degree
  36558. * @param coneOuterAngle Size of the outer cone in degree
  36559. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36560. */
  36561. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36562. /**
  36563. * Gets or sets the inner angle for the directional cone.
  36564. */
  36565. /**
  36566. * Gets or sets the inner angle for the directional cone.
  36567. */
  36568. directionalConeInnerAngle: number;
  36569. /**
  36570. * Gets or sets the outer angle for the directional cone.
  36571. */
  36572. /**
  36573. * Gets or sets the outer angle for the directional cone.
  36574. */
  36575. directionalConeOuterAngle: number;
  36576. /**
  36577. * Sets the position of the emitter if spatial sound is enabled
  36578. * @param newPosition Defines the new posisiton
  36579. */
  36580. setPosition(newPosition: Vector3): void;
  36581. /**
  36582. * Sets the local direction of the emitter if spatial sound is enabled
  36583. * @param newLocalDirection Defines the new local direction
  36584. */
  36585. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36586. private _updateDirection;
  36587. /** @hidden */
  36588. updateDistanceFromListener(): void;
  36589. /**
  36590. * Sets a new custom attenuation function for the sound.
  36591. * @param callback Defines the function used for the attenuation
  36592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36593. */
  36594. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36595. /**
  36596. * Play the sound
  36597. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36598. * @param offset (optional) Start the sound at a specific time in seconds
  36599. * @param length (optional) Sound duration (in seconds)
  36600. */
  36601. play(time?: number, offset?: number, length?: number): void;
  36602. private _onended;
  36603. /**
  36604. * Stop the sound
  36605. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36606. */
  36607. stop(time?: number): void;
  36608. /**
  36609. * Put the sound in pause
  36610. */
  36611. pause(): void;
  36612. /**
  36613. * Sets a dedicated volume for this sounds
  36614. * @param newVolume Define the new volume of the sound
  36615. * @param time Define time for gradual change to new volume
  36616. */
  36617. setVolume(newVolume: number, time?: number): void;
  36618. /**
  36619. * Set the sound play back rate
  36620. * @param newPlaybackRate Define the playback rate the sound should be played at
  36621. */
  36622. setPlaybackRate(newPlaybackRate: number): void;
  36623. /**
  36624. * Gets the volume of the sound.
  36625. * @returns the volume of the sound
  36626. */
  36627. getVolume(): number;
  36628. /**
  36629. * Attach the sound to a dedicated mesh
  36630. * @param transformNode The transform node to connect the sound with
  36631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36632. */
  36633. attachToMesh(transformNode: TransformNode): void;
  36634. /**
  36635. * Detach the sound from the previously attached mesh
  36636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36637. */
  36638. detachFromMesh(): void;
  36639. private _onRegisterAfterWorldMatrixUpdate;
  36640. /**
  36641. * Clone the current sound in the scene.
  36642. * @returns the new sound clone
  36643. */
  36644. clone(): Nullable<Sound>;
  36645. /**
  36646. * Gets the current underlying audio buffer containing the data
  36647. * @returns the audio buffer
  36648. */
  36649. getAudioBuffer(): Nullable<AudioBuffer>;
  36650. /**
  36651. * Serializes the Sound in a JSON representation
  36652. * @returns the JSON representation of the sound
  36653. */
  36654. serialize(): any;
  36655. /**
  36656. * Parse a JSON representation of a sound to innstantiate in a given scene
  36657. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36658. * @param scene Define the scene the new parsed sound should be created in
  36659. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36660. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36661. * @returns the newly parsed sound
  36662. */
  36663. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36664. }
  36665. }
  36666. declare module "babylonjs/Actions/directAudioActions" {
  36667. import { Action } from "babylonjs/Actions/action";
  36668. import { Condition } from "babylonjs/Actions/condition";
  36669. import { Sound } from "babylonjs/Audio/sound";
  36670. /**
  36671. * This defines an action helpful to play a defined sound on a triggered action.
  36672. */
  36673. export class PlaySoundAction extends Action {
  36674. private _sound;
  36675. /**
  36676. * Instantiate the action
  36677. * @param triggerOptions defines the trigger options
  36678. * @param sound defines the sound to play
  36679. * @param condition defines the trigger related conditions
  36680. */
  36681. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36682. /** @hidden */
  36683. _prepare(): void;
  36684. /**
  36685. * Execute the action and play the sound.
  36686. */
  36687. execute(): void;
  36688. /**
  36689. * Serializes the actions and its related information.
  36690. * @param parent defines the object to serialize in
  36691. * @returns the serialized object
  36692. */
  36693. serialize(parent: any): any;
  36694. }
  36695. /**
  36696. * This defines an action helpful to stop a defined sound on a triggered action.
  36697. */
  36698. export class StopSoundAction extends Action {
  36699. private _sound;
  36700. /**
  36701. * Instantiate the action
  36702. * @param triggerOptions defines the trigger options
  36703. * @param sound defines the sound to stop
  36704. * @param condition defines the trigger related conditions
  36705. */
  36706. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36707. /** @hidden */
  36708. _prepare(): void;
  36709. /**
  36710. * Execute the action and stop the sound.
  36711. */
  36712. execute(): void;
  36713. /**
  36714. * Serializes the actions and its related information.
  36715. * @param parent defines the object to serialize in
  36716. * @returns the serialized object
  36717. */
  36718. serialize(parent: any): any;
  36719. }
  36720. }
  36721. declare module "babylonjs/Actions/interpolateValueAction" {
  36722. import { Action } from "babylonjs/Actions/action";
  36723. import { Condition } from "babylonjs/Actions/condition";
  36724. import { Observable } from "babylonjs/Misc/observable";
  36725. /**
  36726. * This defines an action responsible to change the value of a property
  36727. * by interpolating between its current value and the newly set one once triggered.
  36728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36729. */
  36730. export class InterpolateValueAction extends Action {
  36731. /**
  36732. * Defines the path of the property where the value should be interpolated
  36733. */
  36734. propertyPath: string;
  36735. /**
  36736. * Defines the target value at the end of the interpolation.
  36737. */
  36738. value: any;
  36739. /**
  36740. * Defines the time it will take for the property to interpolate to the value.
  36741. */
  36742. duration: number;
  36743. /**
  36744. * Defines if the other scene animations should be stopped when the action has been triggered
  36745. */
  36746. stopOtherAnimations?: boolean;
  36747. /**
  36748. * Defines a callback raised once the interpolation animation has been done.
  36749. */
  36750. onInterpolationDone?: () => void;
  36751. /**
  36752. * Observable triggered once the interpolation animation has been done.
  36753. */
  36754. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36755. private _target;
  36756. private _effectiveTarget;
  36757. private _property;
  36758. /**
  36759. * Instantiate the action
  36760. * @param triggerOptions defines the trigger options
  36761. * @param target defines the object containing the value to interpolate
  36762. * @param propertyPath defines the path to the property in the target object
  36763. * @param value defines the target value at the end of the interpolation
  36764. * @param duration deines the time it will take for the property to interpolate to the value.
  36765. * @param condition defines the trigger related conditions
  36766. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36767. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36768. */
  36769. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36770. /** @hidden */
  36771. _prepare(): void;
  36772. /**
  36773. * Execute the action starts the value interpolation.
  36774. */
  36775. execute(): void;
  36776. /**
  36777. * Serializes the actions and its related information.
  36778. * @param parent defines the object to serialize in
  36779. * @returns the serialized object
  36780. */
  36781. serialize(parent: any): any;
  36782. }
  36783. }
  36784. declare module "babylonjs/Actions/index" {
  36785. export * from "babylonjs/Actions/abstractActionManager";
  36786. export * from "babylonjs/Actions/action";
  36787. export * from "babylonjs/Actions/actionEvent";
  36788. export * from "babylonjs/Actions/actionManager";
  36789. export * from "babylonjs/Actions/condition";
  36790. export * from "babylonjs/Actions/directActions";
  36791. export * from "babylonjs/Actions/directAudioActions";
  36792. export * from "babylonjs/Actions/interpolateValueAction";
  36793. }
  36794. declare module "babylonjs/Animations/index" {
  36795. export * from "babylonjs/Animations/animatable";
  36796. export * from "babylonjs/Animations/animation";
  36797. export * from "babylonjs/Animations/animationGroup";
  36798. export * from "babylonjs/Animations/animationPropertiesOverride";
  36799. export * from "babylonjs/Animations/easing";
  36800. export * from "babylonjs/Animations/runtimeAnimation";
  36801. export * from "babylonjs/Animations/animationEvent";
  36802. export * from "babylonjs/Animations/animationGroup";
  36803. export * from "babylonjs/Animations/animationKey";
  36804. export * from "babylonjs/Animations/animationRange";
  36805. export * from "babylonjs/Animations/animatable.interface";
  36806. }
  36807. declare module "babylonjs/Audio/soundTrack" {
  36808. import { Sound } from "babylonjs/Audio/sound";
  36809. import { Analyser } from "babylonjs/Audio/analyser";
  36810. import { Scene } from "babylonjs/scene";
  36811. /**
  36812. * Options allowed during the creation of a sound track.
  36813. */
  36814. export interface ISoundTrackOptions {
  36815. /**
  36816. * The volume the sound track should take during creation
  36817. */
  36818. volume?: number;
  36819. /**
  36820. * Define if the sound track is the main sound track of the scene
  36821. */
  36822. mainTrack?: boolean;
  36823. }
  36824. /**
  36825. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36826. * It will be also used in a future release to apply effects on a specific track.
  36827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36828. */
  36829. export class SoundTrack {
  36830. /**
  36831. * The unique identifier of the sound track in the scene.
  36832. */
  36833. id: number;
  36834. /**
  36835. * The list of sounds included in the sound track.
  36836. */
  36837. soundCollection: Array<Sound>;
  36838. private _outputAudioNode;
  36839. private _scene;
  36840. private _connectedAnalyser;
  36841. private _options;
  36842. private _isInitialized;
  36843. /**
  36844. * Creates a new sound track.
  36845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36846. * @param scene Define the scene the sound track belongs to
  36847. * @param options
  36848. */
  36849. constructor(scene: Scene, options?: ISoundTrackOptions);
  36850. private _initializeSoundTrackAudioGraph;
  36851. /**
  36852. * Release the sound track and its associated resources
  36853. */
  36854. dispose(): void;
  36855. /**
  36856. * Adds a sound to this sound track
  36857. * @param sound define the cound to add
  36858. * @ignoreNaming
  36859. */
  36860. AddSound(sound: Sound): void;
  36861. /**
  36862. * Removes a sound to this sound track
  36863. * @param sound define the cound to remove
  36864. * @ignoreNaming
  36865. */
  36866. RemoveSound(sound: Sound): void;
  36867. /**
  36868. * Set a global volume for the full sound track.
  36869. * @param newVolume Define the new volume of the sound track
  36870. */
  36871. setVolume(newVolume: number): void;
  36872. /**
  36873. * Switch the panning model to HRTF:
  36874. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36876. */
  36877. switchPanningModelToHRTF(): void;
  36878. /**
  36879. * Switch the panning model to Equal Power:
  36880. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36882. */
  36883. switchPanningModelToEqualPower(): void;
  36884. /**
  36885. * Connect the sound track to an audio analyser allowing some amazing
  36886. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36888. * @param analyser The analyser to connect to the engine
  36889. */
  36890. connectToAnalyser(analyser: Analyser): void;
  36891. }
  36892. }
  36893. declare module "babylonjs/Audio/audioSceneComponent" {
  36894. import { Sound } from "babylonjs/Audio/sound";
  36895. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36896. import { Nullable } from "babylonjs/types";
  36897. import { Vector3 } from "babylonjs/Maths/math.vector";
  36898. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36899. import { Scene } from "babylonjs/scene";
  36900. import { AbstractScene } from "babylonjs/abstractScene";
  36901. import "babylonjs/Audio/audioEngine";
  36902. module "babylonjs/abstractScene" {
  36903. interface AbstractScene {
  36904. /**
  36905. * The list of sounds used in the scene.
  36906. */
  36907. sounds: Nullable<Array<Sound>>;
  36908. }
  36909. }
  36910. module "babylonjs/scene" {
  36911. interface Scene {
  36912. /**
  36913. * @hidden
  36914. * Backing field
  36915. */
  36916. _mainSoundTrack: SoundTrack;
  36917. /**
  36918. * The main sound track played by the scene.
  36919. * It cotains your primary collection of sounds.
  36920. */
  36921. mainSoundTrack: SoundTrack;
  36922. /**
  36923. * The list of sound tracks added to the scene
  36924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36925. */
  36926. soundTracks: Nullable<Array<SoundTrack>>;
  36927. /**
  36928. * Gets a sound using a given name
  36929. * @param name defines the name to search for
  36930. * @return the found sound or null if not found at all.
  36931. */
  36932. getSoundByName(name: string): Nullable<Sound>;
  36933. /**
  36934. * Gets or sets if audio support is enabled
  36935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36936. */
  36937. audioEnabled: boolean;
  36938. /**
  36939. * Gets or sets if audio will be output to headphones
  36940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36941. */
  36942. headphone: boolean;
  36943. /**
  36944. * Gets or sets custom audio listener position provider
  36945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36946. */
  36947. audioListenerPositionProvider: Nullable<() => Vector3>;
  36948. /**
  36949. * Gets or sets a refresh rate when using 3D audio positioning
  36950. */
  36951. audioPositioningRefreshRate: number;
  36952. }
  36953. }
  36954. /**
  36955. * Defines the sound scene component responsible to manage any sounds
  36956. * in a given scene.
  36957. */
  36958. export class AudioSceneComponent implements ISceneSerializableComponent {
  36959. /**
  36960. * The component name helpfull to identify the component in the list of scene components.
  36961. */
  36962. readonly name: string;
  36963. /**
  36964. * The scene the component belongs to.
  36965. */
  36966. scene: Scene;
  36967. private _audioEnabled;
  36968. /**
  36969. * Gets whether audio is enabled or not.
  36970. * Please use related enable/disable method to switch state.
  36971. */
  36972. readonly audioEnabled: boolean;
  36973. private _headphone;
  36974. /**
  36975. * Gets whether audio is outputing to headphone or not.
  36976. * Please use the according Switch methods to change output.
  36977. */
  36978. readonly headphone: boolean;
  36979. /**
  36980. * Gets or sets a refresh rate when using 3D audio positioning
  36981. */
  36982. audioPositioningRefreshRate: number;
  36983. private _audioListenerPositionProvider;
  36984. /**
  36985. * Gets the current audio listener position provider
  36986. */
  36987. /**
  36988. * Sets a custom listener position for all sounds in the scene
  36989. * By default, this is the position of the first active camera
  36990. */
  36991. audioListenerPositionProvider: Nullable<() => Vector3>;
  36992. /**
  36993. * Creates a new instance of the component for the given scene
  36994. * @param scene Defines the scene to register the component in
  36995. */
  36996. constructor(scene: Scene);
  36997. /**
  36998. * Registers the component in a given scene
  36999. */
  37000. register(): void;
  37001. /**
  37002. * Rebuilds the elements related to this component in case of
  37003. * context lost for instance.
  37004. */
  37005. rebuild(): void;
  37006. /**
  37007. * Serializes the component data to the specified json object
  37008. * @param serializationObject The object to serialize to
  37009. */
  37010. serialize(serializationObject: any): void;
  37011. /**
  37012. * Adds all the elements from the container to the scene
  37013. * @param container the container holding the elements
  37014. */
  37015. addFromContainer(container: AbstractScene): void;
  37016. /**
  37017. * Removes all the elements in the container from the scene
  37018. * @param container contains the elements to remove
  37019. * @param dispose if the removed element should be disposed (default: false)
  37020. */
  37021. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37022. /**
  37023. * Disposes the component and the associated ressources.
  37024. */
  37025. dispose(): void;
  37026. /**
  37027. * Disables audio in the associated scene.
  37028. */
  37029. disableAudio(): void;
  37030. /**
  37031. * Enables audio in the associated scene.
  37032. */
  37033. enableAudio(): void;
  37034. /**
  37035. * Switch audio to headphone output.
  37036. */
  37037. switchAudioModeForHeadphones(): void;
  37038. /**
  37039. * Switch audio to normal speakers.
  37040. */
  37041. switchAudioModeForNormalSpeakers(): void;
  37042. private _cachedCameraDirection;
  37043. private _cachedCameraPosition;
  37044. private _lastCheck;
  37045. private _afterRender;
  37046. }
  37047. }
  37048. declare module "babylonjs/Audio/weightedsound" {
  37049. import { Sound } from "babylonjs/Audio/sound";
  37050. /**
  37051. * Wraps one or more Sound objects and selects one with random weight for playback.
  37052. */
  37053. export class WeightedSound {
  37054. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37055. loop: boolean;
  37056. private _coneInnerAngle;
  37057. private _coneOuterAngle;
  37058. private _volume;
  37059. /** A Sound is currently playing. */
  37060. isPlaying: boolean;
  37061. /** A Sound is currently paused. */
  37062. isPaused: boolean;
  37063. private _sounds;
  37064. private _weights;
  37065. private _currentIndex?;
  37066. /**
  37067. * Creates a new WeightedSound from the list of sounds given.
  37068. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37069. * @param sounds Array of Sounds that will be selected from.
  37070. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37071. */
  37072. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37073. /**
  37074. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37075. */
  37076. /**
  37077. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37078. */
  37079. directionalConeInnerAngle: number;
  37080. /**
  37081. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37082. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37083. */
  37084. /**
  37085. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37086. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37087. */
  37088. directionalConeOuterAngle: number;
  37089. /**
  37090. * Playback volume.
  37091. */
  37092. /**
  37093. * Playback volume.
  37094. */
  37095. volume: number;
  37096. private _onended;
  37097. /**
  37098. * Suspend playback
  37099. */
  37100. pause(): void;
  37101. /**
  37102. * Stop playback
  37103. */
  37104. stop(): void;
  37105. /**
  37106. * Start playback.
  37107. * @param startOffset Position the clip head at a specific time in seconds.
  37108. */
  37109. play(startOffset?: number): void;
  37110. }
  37111. }
  37112. declare module "babylonjs/Audio/index" {
  37113. export * from "babylonjs/Audio/analyser";
  37114. export * from "babylonjs/Audio/audioEngine";
  37115. export * from "babylonjs/Audio/audioSceneComponent";
  37116. export * from "babylonjs/Audio/sound";
  37117. export * from "babylonjs/Audio/soundTrack";
  37118. export * from "babylonjs/Audio/weightedsound";
  37119. }
  37120. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37121. import { Behavior } from "babylonjs/Behaviors/behavior";
  37122. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37123. import { BackEase } from "babylonjs/Animations/easing";
  37124. /**
  37125. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37126. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37127. */
  37128. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37129. /**
  37130. * Gets the name of the behavior.
  37131. */
  37132. readonly name: string;
  37133. /**
  37134. * The easing function used by animations
  37135. */
  37136. static EasingFunction: BackEase;
  37137. /**
  37138. * The easing mode used by animations
  37139. */
  37140. static EasingMode: number;
  37141. /**
  37142. * The duration of the animation, in milliseconds
  37143. */
  37144. transitionDuration: number;
  37145. /**
  37146. * Length of the distance animated by the transition when lower radius is reached
  37147. */
  37148. lowerRadiusTransitionRange: number;
  37149. /**
  37150. * Length of the distance animated by the transition when upper radius is reached
  37151. */
  37152. upperRadiusTransitionRange: number;
  37153. private _autoTransitionRange;
  37154. /**
  37155. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37156. */
  37157. /**
  37158. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37159. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37160. */
  37161. autoTransitionRange: boolean;
  37162. private _attachedCamera;
  37163. private _onAfterCheckInputsObserver;
  37164. private _onMeshTargetChangedObserver;
  37165. /**
  37166. * Initializes the behavior.
  37167. */
  37168. init(): void;
  37169. /**
  37170. * Attaches the behavior to its arc rotate camera.
  37171. * @param camera Defines the camera to attach the behavior to
  37172. */
  37173. attach(camera: ArcRotateCamera): void;
  37174. /**
  37175. * Detaches the behavior from its current arc rotate camera.
  37176. */
  37177. detach(): void;
  37178. private _radiusIsAnimating;
  37179. private _radiusBounceTransition;
  37180. private _animatables;
  37181. private _cachedWheelPrecision;
  37182. /**
  37183. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37184. * @param radiusLimit The limit to check against.
  37185. * @return Bool to indicate if at limit.
  37186. */
  37187. private _isRadiusAtLimit;
  37188. /**
  37189. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37190. * @param radiusDelta The delta by which to animate to. Can be negative.
  37191. */
  37192. private _applyBoundRadiusAnimation;
  37193. /**
  37194. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37195. */
  37196. protected _clearAnimationLocks(): void;
  37197. /**
  37198. * Stops and removes all animations that have been applied to the camera
  37199. */
  37200. stopAllAnimations(): void;
  37201. }
  37202. }
  37203. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37204. import { Behavior } from "babylonjs/Behaviors/behavior";
  37205. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37206. import { ExponentialEase } from "babylonjs/Animations/easing";
  37207. import { Nullable } from "babylonjs/types";
  37208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37209. import { Vector3 } from "babylonjs/Maths/math.vector";
  37210. /**
  37211. * 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.
  37212. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37213. */
  37214. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37215. /**
  37216. * Gets the name of the behavior.
  37217. */
  37218. readonly name: string;
  37219. private _mode;
  37220. private _radiusScale;
  37221. private _positionScale;
  37222. private _defaultElevation;
  37223. private _elevationReturnTime;
  37224. private _elevationReturnWaitTime;
  37225. private _zoomStopsAnimation;
  37226. private _framingTime;
  37227. /**
  37228. * The easing function used by animations
  37229. */
  37230. static EasingFunction: ExponentialEase;
  37231. /**
  37232. * The easing mode used by animations
  37233. */
  37234. static EasingMode: number;
  37235. /**
  37236. * Sets the current mode used by the behavior
  37237. */
  37238. /**
  37239. * Gets current mode used by the behavior.
  37240. */
  37241. mode: number;
  37242. /**
  37243. * Sets the scale applied to the radius (1 by default)
  37244. */
  37245. /**
  37246. * Gets the scale applied to the radius
  37247. */
  37248. radiusScale: number;
  37249. /**
  37250. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37251. */
  37252. /**
  37253. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37254. */
  37255. positionScale: number;
  37256. /**
  37257. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37258. * behaviour is triggered, in radians.
  37259. */
  37260. /**
  37261. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37262. * behaviour is triggered, in radians.
  37263. */
  37264. defaultElevation: number;
  37265. /**
  37266. * Sets the time (in milliseconds) taken to return to the default beta position.
  37267. * Negative value indicates camera should not return to default.
  37268. */
  37269. /**
  37270. * Gets the time (in milliseconds) taken to return to the default beta position.
  37271. * Negative value indicates camera should not return to default.
  37272. */
  37273. elevationReturnTime: number;
  37274. /**
  37275. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37276. */
  37277. /**
  37278. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37279. */
  37280. elevationReturnWaitTime: number;
  37281. /**
  37282. * Sets the flag that indicates if user zooming should stop animation.
  37283. */
  37284. /**
  37285. * Gets the flag that indicates if user zooming should stop animation.
  37286. */
  37287. zoomStopsAnimation: boolean;
  37288. /**
  37289. * Sets the transition time when framing the mesh, in milliseconds
  37290. */
  37291. /**
  37292. * Gets the transition time when framing the mesh, in milliseconds
  37293. */
  37294. framingTime: number;
  37295. /**
  37296. * Define if the behavior should automatically change the configured
  37297. * camera limits and sensibilities.
  37298. */
  37299. autoCorrectCameraLimitsAndSensibility: boolean;
  37300. private _onPrePointerObservableObserver;
  37301. private _onAfterCheckInputsObserver;
  37302. private _onMeshTargetChangedObserver;
  37303. private _attachedCamera;
  37304. private _isPointerDown;
  37305. private _lastInteractionTime;
  37306. /**
  37307. * Initializes the behavior.
  37308. */
  37309. init(): void;
  37310. /**
  37311. * Attaches the behavior to its arc rotate camera.
  37312. * @param camera Defines the camera to attach the behavior to
  37313. */
  37314. attach(camera: ArcRotateCamera): void;
  37315. /**
  37316. * Detaches the behavior from its current arc rotate camera.
  37317. */
  37318. detach(): void;
  37319. private _animatables;
  37320. private _betaIsAnimating;
  37321. private _betaTransition;
  37322. private _radiusTransition;
  37323. private _vectorTransition;
  37324. /**
  37325. * Targets the given mesh and updates zoom level accordingly.
  37326. * @param mesh The mesh to target.
  37327. * @param radius Optional. If a cached radius position already exists, overrides default.
  37328. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37329. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37330. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37331. */
  37332. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37333. /**
  37334. * Targets the given mesh with its children and updates zoom level accordingly.
  37335. * @param mesh The mesh to target.
  37336. * @param radius Optional. If a cached radius position already exists, overrides default.
  37337. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37338. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37339. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37340. */
  37341. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37342. /**
  37343. * Targets the given meshes with their children and updates zoom level accordingly.
  37344. * @param meshes The mesh to target.
  37345. * @param radius Optional. If a cached radius position already exists, overrides default.
  37346. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  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. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37351. /**
  37352. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37353. * @param minimumWorld Determines the smaller position of the bounding box extend
  37354. * @param maximumWorld Determines the bigger position of the bounding box extend
  37355. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37356. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37357. */
  37358. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37359. /**
  37360. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37361. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37362. * frustum width.
  37363. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37364. * to fully enclose the mesh in the viewing frustum.
  37365. */
  37366. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37367. /**
  37368. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37369. * is automatically returned to its default position (expected to be above ground plane).
  37370. */
  37371. private _maintainCameraAboveGround;
  37372. /**
  37373. * Returns the frustum slope based on the canvas ratio and camera FOV
  37374. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37375. */
  37376. private _getFrustumSlope;
  37377. /**
  37378. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37379. */
  37380. private _clearAnimationLocks;
  37381. /**
  37382. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37383. */
  37384. private _applyUserInteraction;
  37385. /**
  37386. * Stops and removes all animations that have been applied to the camera
  37387. */
  37388. stopAllAnimations(): void;
  37389. /**
  37390. * Gets a value indicating if the user is moving the camera
  37391. */
  37392. readonly isUserIsMoving: boolean;
  37393. /**
  37394. * The camera can move all the way towards the mesh.
  37395. */
  37396. static IgnoreBoundsSizeMode: number;
  37397. /**
  37398. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37399. */
  37400. static FitFrustumSidesMode: number;
  37401. }
  37402. }
  37403. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37404. import { Nullable } from "babylonjs/types";
  37405. import { Camera } from "babylonjs/Cameras/camera";
  37406. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37407. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37408. /**
  37409. * Base class for Camera Pointer Inputs.
  37410. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37411. * for example usage.
  37412. */
  37413. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37414. /**
  37415. * Defines the camera the input is attached to.
  37416. */
  37417. abstract camera: Camera;
  37418. /**
  37419. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37420. */
  37421. protected _altKey: boolean;
  37422. protected _ctrlKey: boolean;
  37423. protected _metaKey: boolean;
  37424. protected _shiftKey: boolean;
  37425. /**
  37426. * Which mouse buttons were pressed at time of last mouse event.
  37427. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37428. */
  37429. protected _buttonsPressed: number;
  37430. /**
  37431. * Defines the buttons associated with the input to handle camera move.
  37432. */
  37433. buttons: number[];
  37434. /**
  37435. * Attach the input controls to a specific dom element to get the input from.
  37436. * @param element Defines the element the controls should be listened from
  37437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37438. */
  37439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37440. /**
  37441. * Detach the current controls from the specified dom element.
  37442. * @param element Defines the element to stop listening the inputs from
  37443. */
  37444. detachControl(element: Nullable<HTMLElement>): void;
  37445. /**
  37446. * Gets the class name of the current input.
  37447. * @returns the class name
  37448. */
  37449. getClassName(): string;
  37450. /**
  37451. * Get the friendly name associated with the input class.
  37452. * @returns the input friendly name
  37453. */
  37454. getSimpleName(): string;
  37455. /**
  37456. * Called on pointer POINTERDOUBLETAP event.
  37457. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37458. */
  37459. protected onDoubleTap(type: string): void;
  37460. /**
  37461. * Called on pointer POINTERMOVE event if only a single touch is active.
  37462. * Override this method to provide functionality.
  37463. */
  37464. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37465. /**
  37466. * Called on pointer POINTERMOVE event if multiple touches are active.
  37467. * Override this method to provide functionality.
  37468. */
  37469. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37470. /**
  37471. * Called on JS contextmenu event.
  37472. * Override this method to provide functionality.
  37473. */
  37474. protected onContextMenu(evt: PointerEvent): void;
  37475. /**
  37476. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37477. * press.
  37478. * Override this method to provide functionality.
  37479. */
  37480. protected onButtonDown(evt: PointerEvent): void;
  37481. /**
  37482. * Called each time a new POINTERUP event occurs. Ie, for each button
  37483. * release.
  37484. * Override this method to provide functionality.
  37485. */
  37486. protected onButtonUp(evt: PointerEvent): void;
  37487. /**
  37488. * Called when window becomes inactive.
  37489. * Override this method to provide functionality.
  37490. */
  37491. protected onLostFocus(): void;
  37492. private _pointerInput;
  37493. private _observer;
  37494. private _onLostFocus;
  37495. private pointA;
  37496. private pointB;
  37497. }
  37498. }
  37499. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37500. import { Nullable } from "babylonjs/types";
  37501. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37502. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37503. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37504. /**
  37505. * Manage the pointers inputs to control an arc rotate camera.
  37506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37507. */
  37508. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37509. /**
  37510. * Defines the camera the input is attached to.
  37511. */
  37512. camera: ArcRotateCamera;
  37513. /**
  37514. * Gets the class name of the current input.
  37515. * @returns the class name
  37516. */
  37517. getClassName(): string;
  37518. /**
  37519. * Defines the buttons associated with the input to handle camera move.
  37520. */
  37521. buttons: number[];
  37522. /**
  37523. * Defines the pointer angular sensibility along the X axis or how fast is
  37524. * the camera rotating.
  37525. */
  37526. angularSensibilityX: number;
  37527. /**
  37528. * Defines the pointer angular sensibility along the Y axis or how fast is
  37529. * the camera rotating.
  37530. */
  37531. angularSensibilityY: number;
  37532. /**
  37533. * Defines the pointer pinch precision or how fast is the camera zooming.
  37534. */
  37535. pinchPrecision: number;
  37536. /**
  37537. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37538. * from 0.
  37539. * It defines the percentage of current camera.radius to use as delta when
  37540. * pinch zoom is used.
  37541. */
  37542. pinchDeltaPercentage: number;
  37543. /**
  37544. * Defines the pointer panning sensibility or how fast is the camera moving.
  37545. */
  37546. panningSensibility: number;
  37547. /**
  37548. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37549. */
  37550. multiTouchPanning: boolean;
  37551. /**
  37552. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37553. * zoom (pinch) through multitouch.
  37554. */
  37555. multiTouchPanAndZoom: boolean;
  37556. /**
  37557. * Revers pinch action direction.
  37558. */
  37559. pinchInwards: boolean;
  37560. private _isPanClick;
  37561. private _twoFingerActivityCount;
  37562. private _isPinching;
  37563. /**
  37564. * Called on pointer POINTERMOVE event if only a single touch is active.
  37565. */
  37566. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37567. /**
  37568. * Called on pointer POINTERDOUBLETAP event.
  37569. */
  37570. protected onDoubleTap(type: string): void;
  37571. /**
  37572. * Called on pointer POINTERMOVE event if multiple touches are active.
  37573. */
  37574. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37575. /**
  37576. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37577. * press.
  37578. */
  37579. protected onButtonDown(evt: PointerEvent): void;
  37580. /**
  37581. * Called each time a new POINTERUP event occurs. Ie, for each button
  37582. * release.
  37583. */
  37584. protected onButtonUp(evt: PointerEvent): void;
  37585. /**
  37586. * Called when window becomes inactive.
  37587. */
  37588. protected onLostFocus(): void;
  37589. }
  37590. }
  37591. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37592. import { Nullable } from "babylonjs/types";
  37593. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37594. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37595. /**
  37596. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37597. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37598. */
  37599. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37600. /**
  37601. * Defines the camera the input is attached to.
  37602. */
  37603. camera: ArcRotateCamera;
  37604. /**
  37605. * Defines the list of key codes associated with the up action (increase alpha)
  37606. */
  37607. keysUp: number[];
  37608. /**
  37609. * Defines the list of key codes associated with the down action (decrease alpha)
  37610. */
  37611. keysDown: number[];
  37612. /**
  37613. * Defines the list of key codes associated with the left action (increase beta)
  37614. */
  37615. keysLeft: number[];
  37616. /**
  37617. * Defines the list of key codes associated with the right action (decrease beta)
  37618. */
  37619. keysRight: number[];
  37620. /**
  37621. * Defines the list of key codes associated with the reset action.
  37622. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37623. */
  37624. keysReset: number[];
  37625. /**
  37626. * Defines the panning sensibility of the inputs.
  37627. * (How fast is the camera paning)
  37628. */
  37629. panningSensibility: number;
  37630. /**
  37631. * Defines the zooming sensibility of the inputs.
  37632. * (How fast is the camera zooming)
  37633. */
  37634. zoomingSensibility: number;
  37635. /**
  37636. * Defines wether maintaining the alt key down switch the movement mode from
  37637. * orientation to zoom.
  37638. */
  37639. useAltToZoom: boolean;
  37640. /**
  37641. * Rotation speed of the camera
  37642. */
  37643. angularSpeed: number;
  37644. private _keys;
  37645. private _ctrlPressed;
  37646. private _altPressed;
  37647. private _onCanvasBlurObserver;
  37648. private _onKeyboardObserver;
  37649. private _engine;
  37650. private _scene;
  37651. /**
  37652. * Attach the input controls to a specific dom element to get the input from.
  37653. * @param element Defines the element the controls should be listened from
  37654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37655. */
  37656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37657. /**
  37658. * Detach the current controls from the specified dom element.
  37659. * @param element Defines the element to stop listening the inputs from
  37660. */
  37661. detachControl(element: Nullable<HTMLElement>): void;
  37662. /**
  37663. * Update the current camera state depending on the inputs that have been used this frame.
  37664. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37665. */
  37666. checkInputs(): void;
  37667. /**
  37668. * Gets the class name of the current intput.
  37669. * @returns the class name
  37670. */
  37671. getClassName(): string;
  37672. /**
  37673. * Get the friendly name associated with the input class.
  37674. * @returns the input friendly name
  37675. */
  37676. getSimpleName(): string;
  37677. }
  37678. }
  37679. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37680. import { Nullable } from "babylonjs/types";
  37681. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37682. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37683. /**
  37684. * Manage the mouse wheel inputs to control an arc rotate camera.
  37685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37686. */
  37687. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37688. /**
  37689. * Defines the camera the input is attached to.
  37690. */
  37691. camera: ArcRotateCamera;
  37692. /**
  37693. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37694. */
  37695. wheelPrecision: number;
  37696. /**
  37697. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37698. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37699. */
  37700. wheelDeltaPercentage: number;
  37701. private _wheel;
  37702. private _observer;
  37703. private computeDeltaFromMouseWheelLegacyEvent;
  37704. /**
  37705. * Attach the input controls to a specific dom element to get the input from.
  37706. * @param element Defines the element the controls should be listened from
  37707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37708. */
  37709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37710. /**
  37711. * Detach the current controls from the specified dom element.
  37712. * @param element Defines the element to stop listening the inputs from
  37713. */
  37714. detachControl(element: Nullable<HTMLElement>): void;
  37715. /**
  37716. * Gets the class name of the current intput.
  37717. * @returns the class name
  37718. */
  37719. getClassName(): string;
  37720. /**
  37721. * Get the friendly name associated with the input class.
  37722. * @returns the input friendly name
  37723. */
  37724. getSimpleName(): string;
  37725. }
  37726. }
  37727. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37728. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37729. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37730. /**
  37731. * Default Inputs manager for the ArcRotateCamera.
  37732. * It groups all the default supported inputs for ease of use.
  37733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37734. */
  37735. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37736. /**
  37737. * Instantiates a new ArcRotateCameraInputsManager.
  37738. * @param camera Defines the camera the inputs belong to
  37739. */
  37740. constructor(camera: ArcRotateCamera);
  37741. /**
  37742. * Add mouse wheel input support to the input manager.
  37743. * @returns the current input manager
  37744. */
  37745. addMouseWheel(): ArcRotateCameraInputsManager;
  37746. /**
  37747. * Add pointers input support to the input manager.
  37748. * @returns the current input manager
  37749. */
  37750. addPointers(): ArcRotateCameraInputsManager;
  37751. /**
  37752. * Add keyboard input support to the input manager.
  37753. * @returns the current input manager
  37754. */
  37755. addKeyboard(): ArcRotateCameraInputsManager;
  37756. }
  37757. }
  37758. declare module "babylonjs/Cameras/arcRotateCamera" {
  37759. import { Observable } from "babylonjs/Misc/observable";
  37760. import { Nullable } from "babylonjs/types";
  37761. import { Scene } from "babylonjs/scene";
  37762. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37764. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37765. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37766. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37767. import { Camera } from "babylonjs/Cameras/camera";
  37768. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37769. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37770. import { Collider } from "babylonjs/Collisions/collider";
  37771. /**
  37772. * This represents an orbital type of camera.
  37773. *
  37774. * 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.
  37775. * 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.
  37776. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37777. */
  37778. export class ArcRotateCamera extends TargetCamera {
  37779. /**
  37780. * Defines the rotation angle of the camera along the longitudinal axis.
  37781. */
  37782. alpha: number;
  37783. /**
  37784. * Defines the rotation angle of the camera along the latitudinal axis.
  37785. */
  37786. beta: number;
  37787. /**
  37788. * Defines the radius of the camera from it s target point.
  37789. */
  37790. radius: number;
  37791. protected _target: Vector3;
  37792. protected _targetHost: Nullable<AbstractMesh>;
  37793. /**
  37794. * Defines the target point of the camera.
  37795. * The camera looks towards it form the radius distance.
  37796. */
  37797. target: Vector3;
  37798. /**
  37799. * Define the current local position of the camera in the scene
  37800. */
  37801. position: Vector3;
  37802. protected _upVector: Vector3;
  37803. protected _upToYMatrix: Matrix;
  37804. protected _YToUpMatrix: Matrix;
  37805. /**
  37806. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37807. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37808. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37809. */
  37810. upVector: Vector3;
  37811. /**
  37812. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37813. */
  37814. setMatUp(): void;
  37815. /**
  37816. * Current inertia value on the longitudinal axis.
  37817. * The bigger this number the longer it will take for the camera to stop.
  37818. */
  37819. inertialAlphaOffset: number;
  37820. /**
  37821. * Current inertia value on the latitudinal axis.
  37822. * The bigger this number the longer it will take for the camera to stop.
  37823. */
  37824. inertialBetaOffset: number;
  37825. /**
  37826. * Current inertia value on the radius axis.
  37827. * The bigger this number the longer it will take for the camera to stop.
  37828. */
  37829. inertialRadiusOffset: number;
  37830. /**
  37831. * Minimum allowed angle on the longitudinal axis.
  37832. * This can help limiting how the Camera is able to move in the scene.
  37833. */
  37834. lowerAlphaLimit: Nullable<number>;
  37835. /**
  37836. * Maximum allowed angle on the longitudinal axis.
  37837. * This can help limiting how the Camera is able to move in the scene.
  37838. */
  37839. upperAlphaLimit: Nullable<number>;
  37840. /**
  37841. * Minimum allowed angle on the latitudinal axis.
  37842. * This can help limiting how the Camera is able to move in the scene.
  37843. */
  37844. lowerBetaLimit: number;
  37845. /**
  37846. * Maximum allowed angle on the latitudinal axis.
  37847. * This can help limiting how the Camera is able to move in the scene.
  37848. */
  37849. upperBetaLimit: number;
  37850. /**
  37851. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37852. * This can help limiting how the Camera is able to move in the scene.
  37853. */
  37854. lowerRadiusLimit: Nullable<number>;
  37855. /**
  37856. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37857. * This can help limiting how the Camera is able to move in the scene.
  37858. */
  37859. upperRadiusLimit: Nullable<number>;
  37860. /**
  37861. * Defines the current inertia value used during panning of the camera along the X axis.
  37862. */
  37863. inertialPanningX: number;
  37864. /**
  37865. * Defines the current inertia value used during panning of the camera along the Y axis.
  37866. */
  37867. inertialPanningY: number;
  37868. /**
  37869. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37870. * Basically if your fingers moves away from more than this distance you will be considered
  37871. * in pinch mode.
  37872. */
  37873. pinchToPanMaxDistance: number;
  37874. /**
  37875. * Defines the maximum distance the camera can pan.
  37876. * This could help keeping the cammera always in your scene.
  37877. */
  37878. panningDistanceLimit: Nullable<number>;
  37879. /**
  37880. * Defines the target of the camera before paning.
  37881. */
  37882. panningOriginTarget: Vector3;
  37883. /**
  37884. * Defines the value of the inertia used during panning.
  37885. * 0 would mean stop inertia and one would mean no decelleration at all.
  37886. */
  37887. panningInertia: number;
  37888. /**
  37889. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37890. */
  37891. angularSensibilityX: number;
  37892. /**
  37893. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37894. */
  37895. angularSensibilityY: number;
  37896. /**
  37897. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37898. */
  37899. pinchPrecision: number;
  37900. /**
  37901. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37902. * It will be used instead of pinchDeltaPrecision if different from 0.
  37903. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37904. */
  37905. pinchDeltaPercentage: number;
  37906. /**
  37907. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37908. */
  37909. panningSensibility: number;
  37910. /**
  37911. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37912. */
  37913. keysUp: number[];
  37914. /**
  37915. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37916. */
  37917. keysDown: number[];
  37918. /**
  37919. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37920. */
  37921. keysLeft: number[];
  37922. /**
  37923. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37924. */
  37925. keysRight: number[];
  37926. /**
  37927. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37928. */
  37929. wheelPrecision: number;
  37930. /**
  37931. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37932. * It will be used instead of pinchDeltaPrecision if different from 0.
  37933. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37934. */
  37935. wheelDeltaPercentage: number;
  37936. /**
  37937. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37938. */
  37939. zoomOnFactor: number;
  37940. /**
  37941. * Defines a screen offset for the camera position.
  37942. */
  37943. targetScreenOffset: Vector2;
  37944. /**
  37945. * Allows the camera to be completely reversed.
  37946. * If false the camera can not arrive upside down.
  37947. */
  37948. allowUpsideDown: boolean;
  37949. /**
  37950. * Define if double tap/click is used to restore the previously saved state of the camera.
  37951. */
  37952. useInputToRestoreState: boolean;
  37953. /** @hidden */
  37954. _viewMatrix: Matrix;
  37955. /** @hidden */
  37956. _useCtrlForPanning: boolean;
  37957. /** @hidden */
  37958. _panningMouseButton: number;
  37959. /**
  37960. * Defines the input associated to the camera.
  37961. */
  37962. inputs: ArcRotateCameraInputsManager;
  37963. /** @hidden */
  37964. _reset: () => void;
  37965. /**
  37966. * Defines the allowed panning axis.
  37967. */
  37968. panningAxis: Vector3;
  37969. protected _localDirection: Vector3;
  37970. protected _transformedDirection: Vector3;
  37971. private _bouncingBehavior;
  37972. /**
  37973. * Gets the bouncing behavior of the camera if it has been enabled.
  37974. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37975. */
  37976. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37977. /**
  37978. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37979. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37980. */
  37981. useBouncingBehavior: boolean;
  37982. private _framingBehavior;
  37983. /**
  37984. * Gets the framing behavior of the camera if it has been enabled.
  37985. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37986. */
  37987. readonly framingBehavior: Nullable<FramingBehavior>;
  37988. /**
  37989. * Defines if the framing behavior of the camera is enabled on the camera.
  37990. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37991. */
  37992. useFramingBehavior: boolean;
  37993. private _autoRotationBehavior;
  37994. /**
  37995. * Gets the auto rotation behavior of the camera if it has been enabled.
  37996. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37997. */
  37998. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37999. /**
  38000. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38001. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38002. */
  38003. useAutoRotationBehavior: boolean;
  38004. /**
  38005. * Observable triggered when the mesh target has been changed on the camera.
  38006. */
  38007. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38008. /**
  38009. * Event raised when the camera is colliding with a mesh.
  38010. */
  38011. onCollide: (collidedMesh: AbstractMesh) => void;
  38012. /**
  38013. * Defines whether the camera should check collision with the objects oh the scene.
  38014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38015. */
  38016. checkCollisions: boolean;
  38017. /**
  38018. * Defines the collision radius of the camera.
  38019. * This simulates a sphere around the camera.
  38020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38021. */
  38022. collisionRadius: Vector3;
  38023. protected _collider: Collider;
  38024. protected _previousPosition: Vector3;
  38025. protected _collisionVelocity: Vector3;
  38026. protected _newPosition: Vector3;
  38027. protected _previousAlpha: number;
  38028. protected _previousBeta: number;
  38029. protected _previousRadius: number;
  38030. protected _collisionTriggered: boolean;
  38031. protected _targetBoundingCenter: Nullable<Vector3>;
  38032. private _computationVector;
  38033. /**
  38034. * Instantiates a new ArcRotateCamera in a given scene
  38035. * @param name Defines the name of the camera
  38036. * @param alpha Defines the camera rotation along the logitudinal axis
  38037. * @param beta Defines the camera rotation along the latitudinal axis
  38038. * @param radius Defines the camera distance from its target
  38039. * @param target Defines the camera target
  38040. * @param scene Defines the scene the camera belongs to
  38041. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38042. */
  38043. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38044. /** @hidden */
  38045. _initCache(): void;
  38046. /** @hidden */
  38047. _updateCache(ignoreParentClass?: boolean): void;
  38048. protected _getTargetPosition(): Vector3;
  38049. private _storedAlpha;
  38050. private _storedBeta;
  38051. private _storedRadius;
  38052. private _storedTarget;
  38053. private _storedTargetScreenOffset;
  38054. /**
  38055. * Stores the current state of the camera (alpha, beta, radius and target)
  38056. * @returns the camera itself
  38057. */
  38058. storeState(): Camera;
  38059. /**
  38060. * @hidden
  38061. * Restored camera state. You must call storeState() first
  38062. */
  38063. _restoreStateValues(): boolean;
  38064. /** @hidden */
  38065. _isSynchronizedViewMatrix(): boolean;
  38066. /**
  38067. * Attached controls to the current camera.
  38068. * @param element Defines the element the controls should be listened from
  38069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38070. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38071. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38072. */
  38073. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38074. /**
  38075. * Detach the current controls from the camera.
  38076. * The camera will stop reacting to inputs.
  38077. * @param element Defines the element to stop listening the inputs from
  38078. */
  38079. detachControl(element: HTMLElement): void;
  38080. /** @hidden */
  38081. _checkInputs(): void;
  38082. protected _checkLimits(): void;
  38083. /**
  38084. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38085. */
  38086. rebuildAnglesAndRadius(): void;
  38087. /**
  38088. * Use a position to define the current camera related information like alpha, beta and radius
  38089. * @param position Defines the position to set the camera at
  38090. */
  38091. setPosition(position: Vector3): void;
  38092. /**
  38093. * Defines the target the camera should look at.
  38094. * This will automatically adapt alpha beta and radius to fit within the new target.
  38095. * @param target Defines the new target as a Vector or a mesh
  38096. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38097. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38098. */
  38099. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38100. /** @hidden */
  38101. _getViewMatrix(): Matrix;
  38102. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38103. /**
  38104. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38105. * @param meshes Defines the mesh to zoom on
  38106. * @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)
  38107. */
  38108. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38109. /**
  38110. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38111. * The target will be changed but the radius
  38112. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38113. * @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)
  38114. */
  38115. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38116. min: Vector3;
  38117. max: Vector3;
  38118. distance: number;
  38119. }, doNotUpdateMaxZ?: boolean): void;
  38120. /**
  38121. * @override
  38122. * Override Camera.createRigCamera
  38123. */
  38124. createRigCamera(name: string, cameraIndex: number): Camera;
  38125. /**
  38126. * @hidden
  38127. * @override
  38128. * Override Camera._updateRigCameras
  38129. */
  38130. _updateRigCameras(): void;
  38131. /**
  38132. * Destroy the camera and release the current resources hold by it.
  38133. */
  38134. dispose(): void;
  38135. /**
  38136. * Gets the current object class name.
  38137. * @return the class name
  38138. */
  38139. getClassName(): string;
  38140. }
  38141. }
  38142. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38143. import { Behavior } from "babylonjs/Behaviors/behavior";
  38144. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38145. /**
  38146. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38148. */
  38149. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38150. /**
  38151. * Gets the name of the behavior.
  38152. */
  38153. readonly name: string;
  38154. private _zoomStopsAnimation;
  38155. private _idleRotationSpeed;
  38156. private _idleRotationWaitTime;
  38157. private _idleRotationSpinupTime;
  38158. /**
  38159. * Sets the flag that indicates if user zooming should stop animation.
  38160. */
  38161. /**
  38162. * Gets the flag that indicates if user zooming should stop animation.
  38163. */
  38164. zoomStopsAnimation: boolean;
  38165. /**
  38166. * Sets the default speed at which the camera rotates around the model.
  38167. */
  38168. /**
  38169. * Gets the default speed at which the camera rotates around the model.
  38170. */
  38171. idleRotationSpeed: number;
  38172. /**
  38173. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38174. */
  38175. /**
  38176. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38177. */
  38178. idleRotationWaitTime: number;
  38179. /**
  38180. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38181. */
  38182. /**
  38183. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38184. */
  38185. idleRotationSpinupTime: number;
  38186. /**
  38187. * Gets a value indicating if the camera is currently rotating because of this behavior
  38188. */
  38189. readonly rotationInProgress: boolean;
  38190. private _onPrePointerObservableObserver;
  38191. private _onAfterCheckInputsObserver;
  38192. private _attachedCamera;
  38193. private _isPointerDown;
  38194. private _lastFrameTime;
  38195. private _lastInteractionTime;
  38196. private _cameraRotationSpeed;
  38197. /**
  38198. * Initializes the behavior.
  38199. */
  38200. init(): void;
  38201. /**
  38202. * Attaches the behavior to its arc rotate camera.
  38203. * @param camera Defines the camera to attach the behavior to
  38204. */
  38205. attach(camera: ArcRotateCamera): void;
  38206. /**
  38207. * Detaches the behavior from its current arc rotate camera.
  38208. */
  38209. detach(): void;
  38210. /**
  38211. * Returns true if user is scrolling.
  38212. * @return true if user is scrolling.
  38213. */
  38214. private _userIsZooming;
  38215. private _lastFrameRadius;
  38216. private _shouldAnimationStopForInteraction;
  38217. /**
  38218. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38219. */
  38220. private _applyUserInteraction;
  38221. private _userIsMoving;
  38222. }
  38223. }
  38224. declare module "babylonjs/Behaviors/Cameras/index" {
  38225. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38226. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38227. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38228. }
  38229. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38230. import { Mesh } from "babylonjs/Meshes/mesh";
  38231. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38232. import { Behavior } from "babylonjs/Behaviors/behavior";
  38233. /**
  38234. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38235. */
  38236. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38237. private ui;
  38238. /**
  38239. * The name of the behavior
  38240. */
  38241. name: string;
  38242. /**
  38243. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38244. */
  38245. distanceAwayFromFace: number;
  38246. /**
  38247. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38248. */
  38249. distanceAwayFromBottomOfFace: number;
  38250. private _faceVectors;
  38251. private _target;
  38252. private _scene;
  38253. private _onRenderObserver;
  38254. private _tmpMatrix;
  38255. private _tmpVector;
  38256. /**
  38257. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38258. * @param ui The transform node that should be attched to the mesh
  38259. */
  38260. constructor(ui: TransformNode);
  38261. /**
  38262. * Initializes the behavior
  38263. */
  38264. init(): void;
  38265. private _closestFace;
  38266. private _zeroVector;
  38267. private _lookAtTmpMatrix;
  38268. private _lookAtToRef;
  38269. /**
  38270. * Attaches the AttachToBoxBehavior to the passed in mesh
  38271. * @param target The mesh that the specified node will be attached to
  38272. */
  38273. attach(target: Mesh): void;
  38274. /**
  38275. * Detaches the behavior from the mesh
  38276. */
  38277. detach(): void;
  38278. }
  38279. }
  38280. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38281. import { Behavior } from "babylonjs/Behaviors/behavior";
  38282. import { Mesh } from "babylonjs/Meshes/mesh";
  38283. /**
  38284. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38285. */
  38286. export class FadeInOutBehavior implements Behavior<Mesh> {
  38287. /**
  38288. * Time in milliseconds to delay before fading in (Default: 0)
  38289. */
  38290. delay: number;
  38291. /**
  38292. * Time in milliseconds for the mesh to fade in (Default: 300)
  38293. */
  38294. fadeInTime: number;
  38295. private _millisecondsPerFrame;
  38296. private _hovered;
  38297. private _hoverValue;
  38298. private _ownerNode;
  38299. /**
  38300. * Instatiates the FadeInOutBehavior
  38301. */
  38302. constructor();
  38303. /**
  38304. * The name of the behavior
  38305. */
  38306. readonly name: string;
  38307. /**
  38308. * Initializes the behavior
  38309. */
  38310. init(): void;
  38311. /**
  38312. * Attaches the fade behavior on the passed in mesh
  38313. * @param ownerNode The mesh that will be faded in/out once attached
  38314. */
  38315. attach(ownerNode: Mesh): void;
  38316. /**
  38317. * Detaches the behavior from the mesh
  38318. */
  38319. detach(): void;
  38320. /**
  38321. * Triggers the mesh to begin fading in or out
  38322. * @param value if the object should fade in or out (true to fade in)
  38323. */
  38324. fadeIn(value: boolean): void;
  38325. private _update;
  38326. private _setAllVisibility;
  38327. }
  38328. }
  38329. declare module "babylonjs/Misc/pivotTools" {
  38330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38331. /**
  38332. * Class containing a set of static utilities functions for managing Pivots
  38333. * @hidden
  38334. */
  38335. export class PivotTools {
  38336. private static _PivotCached;
  38337. private static _OldPivotPoint;
  38338. private static _PivotTranslation;
  38339. private static _PivotTmpVector;
  38340. /** @hidden */
  38341. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38342. /** @hidden */
  38343. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38344. }
  38345. }
  38346. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38347. import { Scene } from "babylonjs/scene";
  38348. import { Vector4 } from "babylonjs/Maths/math.vector";
  38349. import { Mesh } from "babylonjs/Meshes/mesh";
  38350. import { Nullable } from "babylonjs/types";
  38351. import { Plane } from "babylonjs/Maths/math.plane";
  38352. /**
  38353. * Class containing static functions to help procedurally build meshes
  38354. */
  38355. export class PlaneBuilder {
  38356. /**
  38357. * Creates a plane mesh
  38358. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38359. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38360. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38364. * @param name defines the name of the mesh
  38365. * @param options defines the options used to create the mesh
  38366. * @param scene defines the hosting scene
  38367. * @returns the plane mesh
  38368. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38369. */
  38370. static CreatePlane(name: string, options: {
  38371. size?: number;
  38372. width?: number;
  38373. height?: number;
  38374. sideOrientation?: number;
  38375. frontUVs?: Vector4;
  38376. backUVs?: Vector4;
  38377. updatable?: boolean;
  38378. sourcePlane?: Plane;
  38379. }, scene?: Nullable<Scene>): Mesh;
  38380. }
  38381. }
  38382. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38383. import { Behavior } from "babylonjs/Behaviors/behavior";
  38384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38385. import { Observable } from "babylonjs/Misc/observable";
  38386. import { Vector3 } from "babylonjs/Maths/math.vector";
  38387. import { Ray } from "babylonjs/Culling/ray";
  38388. import "babylonjs/Meshes/Builders/planeBuilder";
  38389. /**
  38390. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38391. */
  38392. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38393. private static _AnyMouseID;
  38394. /**
  38395. * Abstract mesh the behavior is set on
  38396. */
  38397. attachedNode: AbstractMesh;
  38398. private _dragPlane;
  38399. private _scene;
  38400. private _pointerObserver;
  38401. private _beforeRenderObserver;
  38402. private static _planeScene;
  38403. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38404. /**
  38405. * 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)
  38406. */
  38407. maxDragAngle: number;
  38408. /**
  38409. * @hidden
  38410. */
  38411. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38412. /**
  38413. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38414. */
  38415. currentDraggingPointerID: number;
  38416. /**
  38417. * The last position where the pointer hit the drag plane in world space
  38418. */
  38419. lastDragPosition: Vector3;
  38420. /**
  38421. * If the behavior is currently in a dragging state
  38422. */
  38423. dragging: boolean;
  38424. /**
  38425. * 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)
  38426. */
  38427. dragDeltaRatio: number;
  38428. /**
  38429. * If the drag plane orientation should be updated during the dragging (Default: true)
  38430. */
  38431. updateDragPlane: boolean;
  38432. private _debugMode;
  38433. private _moving;
  38434. /**
  38435. * Fires each time the attached mesh is dragged with the pointer
  38436. * * delta between last drag position and current drag position in world space
  38437. * * dragDistance along the drag axis
  38438. * * dragPlaneNormal normal of the current drag plane used during the drag
  38439. * * dragPlanePoint in world space where the drag intersects the drag plane
  38440. */
  38441. onDragObservable: Observable<{
  38442. delta: Vector3;
  38443. dragPlanePoint: Vector3;
  38444. dragPlaneNormal: Vector3;
  38445. dragDistance: number;
  38446. pointerId: number;
  38447. }>;
  38448. /**
  38449. * Fires each time a drag begins (eg. mouse down on mesh)
  38450. */
  38451. onDragStartObservable: Observable<{
  38452. dragPlanePoint: Vector3;
  38453. pointerId: number;
  38454. }>;
  38455. /**
  38456. * Fires each time a drag ends (eg. mouse release after drag)
  38457. */
  38458. onDragEndObservable: Observable<{
  38459. dragPlanePoint: Vector3;
  38460. pointerId: number;
  38461. }>;
  38462. /**
  38463. * If the attached mesh should be moved when dragged
  38464. */
  38465. moveAttached: boolean;
  38466. /**
  38467. * If the drag behavior will react to drag events (Default: true)
  38468. */
  38469. enabled: boolean;
  38470. /**
  38471. * If pointer events should start and release the drag (Default: true)
  38472. */
  38473. startAndReleaseDragOnPointerEvents: boolean;
  38474. /**
  38475. * If camera controls should be detached during the drag
  38476. */
  38477. detachCameraControls: boolean;
  38478. /**
  38479. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38480. */
  38481. useObjectOrienationForDragging: boolean;
  38482. private _options;
  38483. /**
  38484. * Creates a pointer drag behavior that can be attached to a mesh
  38485. * @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)
  38486. */
  38487. constructor(options?: {
  38488. dragAxis?: Vector3;
  38489. dragPlaneNormal?: Vector3;
  38490. });
  38491. /**
  38492. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38493. */
  38494. validateDrag: (targetPosition: Vector3) => boolean;
  38495. /**
  38496. * The name of the behavior
  38497. */
  38498. readonly name: string;
  38499. /**
  38500. * Initializes the behavior
  38501. */
  38502. init(): void;
  38503. private _tmpVector;
  38504. private _alternatePickedPoint;
  38505. private _worldDragAxis;
  38506. private _targetPosition;
  38507. private _attachedElement;
  38508. /**
  38509. * Attaches the drag behavior the passed in mesh
  38510. * @param ownerNode The mesh that will be dragged around once attached
  38511. * @param predicate Predicate to use for pick filtering
  38512. */
  38513. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38514. /**
  38515. * Force relase the drag action by code.
  38516. */
  38517. releaseDrag(): void;
  38518. private _startDragRay;
  38519. private _lastPointerRay;
  38520. /**
  38521. * Simulates the start of a pointer drag event on the behavior
  38522. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38523. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38524. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38525. */
  38526. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38527. private _startDrag;
  38528. private _dragDelta;
  38529. private _moveDrag;
  38530. private _pickWithRayOnDragPlane;
  38531. private _pointA;
  38532. private _pointB;
  38533. private _pointC;
  38534. private _lineA;
  38535. private _lineB;
  38536. private _localAxis;
  38537. private _lookAt;
  38538. private _updateDragPlanePosition;
  38539. /**
  38540. * Detaches the behavior from the mesh
  38541. */
  38542. detach(): void;
  38543. }
  38544. }
  38545. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38546. import { Mesh } from "babylonjs/Meshes/mesh";
  38547. import { Behavior } from "babylonjs/Behaviors/behavior";
  38548. /**
  38549. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38550. */
  38551. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38552. private _dragBehaviorA;
  38553. private _dragBehaviorB;
  38554. private _startDistance;
  38555. private _initialScale;
  38556. private _targetScale;
  38557. private _ownerNode;
  38558. private _sceneRenderObserver;
  38559. /**
  38560. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38561. */
  38562. constructor();
  38563. /**
  38564. * The name of the behavior
  38565. */
  38566. readonly name: string;
  38567. /**
  38568. * Initializes the behavior
  38569. */
  38570. init(): void;
  38571. private _getCurrentDistance;
  38572. /**
  38573. * Attaches the scale behavior the passed in mesh
  38574. * @param ownerNode The mesh that will be scaled around once attached
  38575. */
  38576. attach(ownerNode: Mesh): void;
  38577. /**
  38578. * Detaches the behavior from the mesh
  38579. */
  38580. detach(): void;
  38581. }
  38582. }
  38583. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38584. import { Behavior } from "babylonjs/Behaviors/behavior";
  38585. import { Mesh } from "babylonjs/Meshes/mesh";
  38586. import { Observable } from "babylonjs/Misc/observable";
  38587. /**
  38588. * 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
  38589. */
  38590. export class SixDofDragBehavior implements Behavior<Mesh> {
  38591. private static _virtualScene;
  38592. private _ownerNode;
  38593. private _sceneRenderObserver;
  38594. private _scene;
  38595. private _targetPosition;
  38596. private _virtualOriginMesh;
  38597. private _virtualDragMesh;
  38598. private _pointerObserver;
  38599. private _moving;
  38600. private _startingOrientation;
  38601. /**
  38602. * 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)
  38603. */
  38604. private zDragFactor;
  38605. /**
  38606. * If the object should rotate to face the drag origin
  38607. */
  38608. rotateDraggedObject: boolean;
  38609. /**
  38610. * If the behavior is currently in a dragging state
  38611. */
  38612. dragging: boolean;
  38613. /**
  38614. * 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)
  38615. */
  38616. dragDeltaRatio: number;
  38617. /**
  38618. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38619. */
  38620. currentDraggingPointerID: number;
  38621. /**
  38622. * If camera controls should be detached during the drag
  38623. */
  38624. detachCameraControls: boolean;
  38625. /**
  38626. * Fires each time a drag starts
  38627. */
  38628. onDragStartObservable: Observable<{}>;
  38629. /**
  38630. * Fires each time a drag ends (eg. mouse release after drag)
  38631. */
  38632. onDragEndObservable: Observable<{}>;
  38633. /**
  38634. * 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
  38635. */
  38636. constructor();
  38637. /**
  38638. * The name of the behavior
  38639. */
  38640. readonly name: string;
  38641. /**
  38642. * Initializes the behavior
  38643. */
  38644. init(): void;
  38645. /**
  38646. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38647. */
  38648. private readonly _pointerCamera;
  38649. /**
  38650. * Attaches the scale behavior the passed in mesh
  38651. * @param ownerNode The mesh that will be scaled around once attached
  38652. */
  38653. attach(ownerNode: Mesh): void;
  38654. /**
  38655. * Detaches the behavior from the mesh
  38656. */
  38657. detach(): void;
  38658. }
  38659. }
  38660. declare module "babylonjs/Behaviors/Meshes/index" {
  38661. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38662. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38663. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38664. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38665. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38666. }
  38667. declare module "babylonjs/Behaviors/index" {
  38668. export * from "babylonjs/Behaviors/behavior";
  38669. export * from "babylonjs/Behaviors/Cameras/index";
  38670. export * from "babylonjs/Behaviors/Meshes/index";
  38671. }
  38672. declare module "babylonjs/Bones/boneIKController" {
  38673. import { Bone } from "babylonjs/Bones/bone";
  38674. import { Vector3 } from "babylonjs/Maths/math.vector";
  38675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38676. import { Nullable } from "babylonjs/types";
  38677. /**
  38678. * Class used to apply inverse kinematics to bones
  38679. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38680. */
  38681. export class BoneIKController {
  38682. private static _tmpVecs;
  38683. private static _tmpQuat;
  38684. private static _tmpMats;
  38685. /**
  38686. * Gets or sets the target mesh
  38687. */
  38688. targetMesh: AbstractMesh;
  38689. /** Gets or sets the mesh used as pole */
  38690. poleTargetMesh: AbstractMesh;
  38691. /**
  38692. * Gets or sets the bone used as pole
  38693. */
  38694. poleTargetBone: Nullable<Bone>;
  38695. /**
  38696. * Gets or sets the target position
  38697. */
  38698. targetPosition: Vector3;
  38699. /**
  38700. * Gets or sets the pole target position
  38701. */
  38702. poleTargetPosition: Vector3;
  38703. /**
  38704. * Gets or sets the pole target local offset
  38705. */
  38706. poleTargetLocalOffset: Vector3;
  38707. /**
  38708. * Gets or sets the pole angle
  38709. */
  38710. poleAngle: number;
  38711. /**
  38712. * Gets or sets the mesh associated with the controller
  38713. */
  38714. mesh: AbstractMesh;
  38715. /**
  38716. * 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)
  38717. */
  38718. slerpAmount: number;
  38719. private _bone1Quat;
  38720. private _bone1Mat;
  38721. private _bone2Ang;
  38722. private _bone1;
  38723. private _bone2;
  38724. private _bone1Length;
  38725. private _bone2Length;
  38726. private _maxAngle;
  38727. private _maxReach;
  38728. private _rightHandedSystem;
  38729. private _bendAxis;
  38730. private _slerping;
  38731. private _adjustRoll;
  38732. /**
  38733. * Gets or sets maximum allowed angle
  38734. */
  38735. maxAngle: number;
  38736. /**
  38737. * Creates a new BoneIKController
  38738. * @param mesh defines the mesh to control
  38739. * @param bone defines the bone to control
  38740. * @param options defines options to set up the controller
  38741. */
  38742. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38743. targetMesh?: AbstractMesh;
  38744. poleTargetMesh?: AbstractMesh;
  38745. poleTargetBone?: Bone;
  38746. poleTargetLocalOffset?: Vector3;
  38747. poleAngle?: number;
  38748. bendAxis?: Vector3;
  38749. maxAngle?: number;
  38750. slerpAmount?: number;
  38751. });
  38752. private _setMaxAngle;
  38753. /**
  38754. * Force the controller to update the bones
  38755. */
  38756. update(): void;
  38757. }
  38758. }
  38759. declare module "babylonjs/Bones/boneLookController" {
  38760. import { Vector3 } from "babylonjs/Maths/math.vector";
  38761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38762. import { Bone } from "babylonjs/Bones/bone";
  38763. import { Space } from "babylonjs/Maths/math.axis";
  38764. /**
  38765. * Class used to make a bone look toward a point in space
  38766. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38767. */
  38768. export class BoneLookController {
  38769. private static _tmpVecs;
  38770. private static _tmpQuat;
  38771. private static _tmpMats;
  38772. /**
  38773. * The target Vector3 that the bone will look at
  38774. */
  38775. target: Vector3;
  38776. /**
  38777. * The mesh that the bone is attached to
  38778. */
  38779. mesh: AbstractMesh;
  38780. /**
  38781. * The bone that will be looking to the target
  38782. */
  38783. bone: Bone;
  38784. /**
  38785. * The up axis of the coordinate system that is used when the bone is rotated
  38786. */
  38787. upAxis: Vector3;
  38788. /**
  38789. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38790. */
  38791. upAxisSpace: Space;
  38792. /**
  38793. * Used to make an adjustment to the yaw of the bone
  38794. */
  38795. adjustYaw: number;
  38796. /**
  38797. * Used to make an adjustment to the pitch of the bone
  38798. */
  38799. adjustPitch: number;
  38800. /**
  38801. * Used to make an adjustment to the roll of the bone
  38802. */
  38803. adjustRoll: number;
  38804. /**
  38805. * 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)
  38806. */
  38807. slerpAmount: number;
  38808. private _minYaw;
  38809. private _maxYaw;
  38810. private _minPitch;
  38811. private _maxPitch;
  38812. private _minYawSin;
  38813. private _minYawCos;
  38814. private _maxYawSin;
  38815. private _maxYawCos;
  38816. private _midYawConstraint;
  38817. private _minPitchTan;
  38818. private _maxPitchTan;
  38819. private _boneQuat;
  38820. private _slerping;
  38821. private _transformYawPitch;
  38822. private _transformYawPitchInv;
  38823. private _firstFrameSkipped;
  38824. private _yawRange;
  38825. private _fowardAxis;
  38826. /**
  38827. * Gets or sets the minimum yaw angle that the bone can look to
  38828. */
  38829. minYaw: number;
  38830. /**
  38831. * Gets or sets the maximum yaw angle that the bone can look to
  38832. */
  38833. maxYaw: number;
  38834. /**
  38835. * Gets or sets the minimum pitch angle that the bone can look to
  38836. */
  38837. minPitch: number;
  38838. /**
  38839. * Gets or sets the maximum pitch angle that the bone can look to
  38840. */
  38841. maxPitch: number;
  38842. /**
  38843. * Create a BoneLookController
  38844. * @param mesh the mesh that the bone belongs to
  38845. * @param bone the bone that will be looking to the target
  38846. * @param target the target Vector3 to look at
  38847. * @param options optional settings:
  38848. * * maxYaw: the maximum angle the bone will yaw to
  38849. * * minYaw: the minimum angle the bone will yaw to
  38850. * * maxPitch: the maximum angle the bone will pitch to
  38851. * * minPitch: the minimum angle the bone will yaw to
  38852. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38853. * * upAxis: the up axis of the coordinate system
  38854. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38855. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38856. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38857. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38858. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38859. * * adjustRoll: used to make an adjustment to the roll of the bone
  38860. **/
  38861. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38862. maxYaw?: number;
  38863. minYaw?: number;
  38864. maxPitch?: number;
  38865. minPitch?: number;
  38866. slerpAmount?: number;
  38867. upAxis?: Vector3;
  38868. upAxisSpace?: Space;
  38869. yawAxis?: Vector3;
  38870. pitchAxis?: Vector3;
  38871. adjustYaw?: number;
  38872. adjustPitch?: number;
  38873. adjustRoll?: number;
  38874. });
  38875. /**
  38876. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38877. */
  38878. update(): void;
  38879. private _getAngleDiff;
  38880. private _getAngleBetween;
  38881. private _isAngleBetween;
  38882. }
  38883. }
  38884. declare module "babylonjs/Bones/index" {
  38885. export * from "babylonjs/Bones/bone";
  38886. export * from "babylonjs/Bones/boneIKController";
  38887. export * from "babylonjs/Bones/boneLookController";
  38888. export * from "babylonjs/Bones/skeleton";
  38889. }
  38890. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38891. import { Nullable } from "babylonjs/types";
  38892. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38894. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38895. /**
  38896. * Manage the gamepad inputs to control an arc rotate camera.
  38897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38898. */
  38899. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38900. /**
  38901. * Defines the camera the input is attached to.
  38902. */
  38903. camera: ArcRotateCamera;
  38904. /**
  38905. * Defines the gamepad the input is gathering event from.
  38906. */
  38907. gamepad: Nullable<Gamepad>;
  38908. /**
  38909. * Defines the gamepad rotation sensiblity.
  38910. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38911. */
  38912. gamepadRotationSensibility: number;
  38913. /**
  38914. * Defines the gamepad move sensiblity.
  38915. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38916. */
  38917. gamepadMoveSensibility: number;
  38918. private _yAxisScale;
  38919. /**
  38920. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38921. */
  38922. invertYAxis: boolean;
  38923. private _onGamepadConnectedObserver;
  38924. private _onGamepadDisconnectedObserver;
  38925. /**
  38926. * Attach the input controls to a specific dom element to get the input from.
  38927. * @param element Defines the element the controls should be listened from
  38928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38929. */
  38930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38931. /**
  38932. * Detach the current controls from the specified dom element.
  38933. * @param element Defines the element to stop listening the inputs from
  38934. */
  38935. detachControl(element: Nullable<HTMLElement>): void;
  38936. /**
  38937. * Update the current camera state depending on the inputs that have been used this frame.
  38938. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38939. */
  38940. checkInputs(): void;
  38941. /**
  38942. * Gets the class name of the current intput.
  38943. * @returns the class name
  38944. */
  38945. getClassName(): string;
  38946. /**
  38947. * Get the friendly name associated with the input class.
  38948. * @returns the input friendly name
  38949. */
  38950. getSimpleName(): string;
  38951. }
  38952. }
  38953. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38954. import { Nullable } from "babylonjs/types";
  38955. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38956. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38957. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38958. interface ArcRotateCameraInputsManager {
  38959. /**
  38960. * Add orientation input support to the input manager.
  38961. * @returns the current input manager
  38962. */
  38963. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38964. }
  38965. }
  38966. /**
  38967. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38969. */
  38970. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38971. /**
  38972. * Defines the camera the input is attached to.
  38973. */
  38974. camera: ArcRotateCamera;
  38975. /**
  38976. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38977. */
  38978. alphaCorrection: number;
  38979. /**
  38980. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38981. */
  38982. gammaCorrection: number;
  38983. private _alpha;
  38984. private _gamma;
  38985. private _dirty;
  38986. private _deviceOrientationHandler;
  38987. /**
  38988. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38989. */
  38990. constructor();
  38991. /**
  38992. * Attach the input controls to a specific dom element to get the input from.
  38993. * @param element Defines the element the controls should be listened from
  38994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38995. */
  38996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38997. /** @hidden */
  38998. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38999. /**
  39000. * Update the current camera state depending on the inputs that have been used this frame.
  39001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39002. */
  39003. checkInputs(): void;
  39004. /**
  39005. * Detach the current controls from the specified dom element.
  39006. * @param element Defines the element to stop listening the inputs from
  39007. */
  39008. detachControl(element: Nullable<HTMLElement>): void;
  39009. /**
  39010. * Gets the class name of the current intput.
  39011. * @returns the class name
  39012. */
  39013. getClassName(): string;
  39014. /**
  39015. * Get the friendly name associated with the input class.
  39016. * @returns the input friendly name
  39017. */
  39018. getSimpleName(): string;
  39019. }
  39020. }
  39021. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39022. import { Nullable } from "babylonjs/types";
  39023. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39024. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39025. /**
  39026. * Listen to mouse events to control the camera.
  39027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39028. */
  39029. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39030. /**
  39031. * Defines the camera the input is attached to.
  39032. */
  39033. camera: FlyCamera;
  39034. /**
  39035. * Defines if touch is enabled. (Default is true.)
  39036. */
  39037. touchEnabled: boolean;
  39038. /**
  39039. * Defines the buttons associated with the input to handle camera rotation.
  39040. */
  39041. buttons: number[];
  39042. /**
  39043. * Assign buttons for Yaw control.
  39044. */
  39045. buttonsYaw: number[];
  39046. /**
  39047. * Assign buttons for Pitch control.
  39048. */
  39049. buttonsPitch: number[];
  39050. /**
  39051. * Assign buttons for Roll control.
  39052. */
  39053. buttonsRoll: number[];
  39054. /**
  39055. * Detect if any button is being pressed while mouse is moved.
  39056. * -1 = Mouse locked.
  39057. * 0 = Left button.
  39058. * 1 = Middle Button.
  39059. * 2 = Right Button.
  39060. */
  39061. activeButton: number;
  39062. /**
  39063. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39064. * Higher values reduce its sensitivity.
  39065. */
  39066. angularSensibility: number;
  39067. private _mousemoveCallback;
  39068. private _observer;
  39069. private _rollObserver;
  39070. private previousPosition;
  39071. private noPreventDefault;
  39072. private element;
  39073. /**
  39074. * Listen to mouse events to control the camera.
  39075. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39077. */
  39078. constructor(touchEnabled?: boolean);
  39079. /**
  39080. * Attach the mouse control to the HTML DOM element.
  39081. * @param element Defines the element that listens to the input events.
  39082. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39083. */
  39084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39085. /**
  39086. * Detach the current controls from the specified dom element.
  39087. * @param element Defines the element to stop listening the inputs from
  39088. */
  39089. detachControl(element: Nullable<HTMLElement>): void;
  39090. /**
  39091. * Gets the class name of the current input.
  39092. * @returns the class name.
  39093. */
  39094. getClassName(): string;
  39095. /**
  39096. * Get the friendly name associated with the input class.
  39097. * @returns the input's friendly name.
  39098. */
  39099. getSimpleName(): string;
  39100. private _pointerInput;
  39101. private _onMouseMove;
  39102. /**
  39103. * Rotate camera by mouse offset.
  39104. */
  39105. private rotateCamera;
  39106. }
  39107. }
  39108. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39109. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39110. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39111. /**
  39112. * Default Inputs manager for the FlyCamera.
  39113. * It groups all the default supported inputs for ease of use.
  39114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39115. */
  39116. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39117. /**
  39118. * Instantiates a new FlyCameraInputsManager.
  39119. * @param camera Defines the camera the inputs belong to.
  39120. */
  39121. constructor(camera: FlyCamera);
  39122. /**
  39123. * Add keyboard input support to the input manager.
  39124. * @returns the new FlyCameraKeyboardMoveInput().
  39125. */
  39126. addKeyboard(): FlyCameraInputsManager;
  39127. /**
  39128. * Add mouse input support to the input manager.
  39129. * @param touchEnabled Enable touch screen support.
  39130. * @returns the new FlyCameraMouseInput().
  39131. */
  39132. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39133. }
  39134. }
  39135. declare module "babylonjs/Cameras/flyCamera" {
  39136. import { Scene } from "babylonjs/scene";
  39137. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39139. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39140. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39141. /**
  39142. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39143. * such as in a 3D Space Shooter or a Flight Simulator.
  39144. */
  39145. export class FlyCamera extends TargetCamera {
  39146. /**
  39147. * Define the collision ellipsoid of the camera.
  39148. * This is helpful for simulating a camera body, like a player's body.
  39149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39150. */
  39151. ellipsoid: Vector3;
  39152. /**
  39153. * Define an offset for the position of the ellipsoid around the camera.
  39154. * This can be helpful if the camera is attached away from the player's body center,
  39155. * such as at its head.
  39156. */
  39157. ellipsoidOffset: Vector3;
  39158. /**
  39159. * Enable or disable collisions of the camera with the rest of the scene objects.
  39160. */
  39161. checkCollisions: boolean;
  39162. /**
  39163. * Enable or disable gravity on the camera.
  39164. */
  39165. applyGravity: boolean;
  39166. /**
  39167. * Define the current direction the camera is moving to.
  39168. */
  39169. cameraDirection: Vector3;
  39170. /**
  39171. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39172. * This overrides and empties cameraRotation.
  39173. */
  39174. rotationQuaternion: Quaternion;
  39175. /**
  39176. * Track Roll to maintain the wanted Rolling when looking around.
  39177. */
  39178. _trackRoll: number;
  39179. /**
  39180. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39181. */
  39182. rollCorrect: number;
  39183. /**
  39184. * Mimic a banked turn, Rolling the camera when Yawing.
  39185. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39186. */
  39187. bankedTurn: boolean;
  39188. /**
  39189. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39190. */
  39191. bankedTurnLimit: number;
  39192. /**
  39193. * Value of 0 disables the banked Roll.
  39194. * Value of 1 is equal to the Yaw angle in radians.
  39195. */
  39196. bankedTurnMultiplier: number;
  39197. /**
  39198. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39199. */
  39200. inputs: FlyCameraInputsManager;
  39201. /**
  39202. * Gets the input sensibility for mouse input.
  39203. * Higher values reduce sensitivity.
  39204. */
  39205. /**
  39206. * Sets the input sensibility for a mouse input.
  39207. * Higher values reduce sensitivity.
  39208. */
  39209. angularSensibility: number;
  39210. /**
  39211. * Get the keys for camera movement forward.
  39212. */
  39213. /**
  39214. * Set the keys for camera movement forward.
  39215. */
  39216. keysForward: number[];
  39217. /**
  39218. * Get the keys for camera movement backward.
  39219. */
  39220. keysBackward: number[];
  39221. /**
  39222. * Get the keys for camera movement up.
  39223. */
  39224. /**
  39225. * Set the keys for camera movement up.
  39226. */
  39227. keysUp: number[];
  39228. /**
  39229. * Get the keys for camera movement down.
  39230. */
  39231. /**
  39232. * Set the keys for camera movement down.
  39233. */
  39234. keysDown: number[];
  39235. /**
  39236. * Get the keys for camera movement left.
  39237. */
  39238. /**
  39239. * Set the keys for camera movement left.
  39240. */
  39241. keysLeft: number[];
  39242. /**
  39243. * Set the keys for camera movement right.
  39244. */
  39245. /**
  39246. * Set the keys for camera movement right.
  39247. */
  39248. keysRight: number[];
  39249. /**
  39250. * Event raised when the camera collides with a mesh in the scene.
  39251. */
  39252. onCollide: (collidedMesh: AbstractMesh) => void;
  39253. private _collider;
  39254. private _needMoveForGravity;
  39255. private _oldPosition;
  39256. private _diffPosition;
  39257. private _newPosition;
  39258. /** @hidden */
  39259. _localDirection: Vector3;
  39260. /** @hidden */
  39261. _transformedDirection: Vector3;
  39262. /**
  39263. * Instantiates a FlyCamera.
  39264. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39265. * such as in a 3D Space Shooter or a Flight Simulator.
  39266. * @param name Define the name of the camera in the scene.
  39267. * @param position Define the starting position of the camera in the scene.
  39268. * @param scene Define the scene the camera belongs to.
  39269. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39270. */
  39271. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39272. /**
  39273. * Attach a control to the HTML DOM element.
  39274. * @param element Defines the element that listens to the input events.
  39275. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39276. */
  39277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39278. /**
  39279. * Detach a control from the HTML DOM element.
  39280. * The camera will stop reacting to that input.
  39281. * @param element Defines the element that listens to the input events.
  39282. */
  39283. detachControl(element: HTMLElement): void;
  39284. private _collisionMask;
  39285. /**
  39286. * Get the mask that the camera ignores in collision events.
  39287. */
  39288. /**
  39289. * Set the mask that the camera ignores in collision events.
  39290. */
  39291. collisionMask: number;
  39292. /** @hidden */
  39293. _collideWithWorld(displacement: Vector3): void;
  39294. /** @hidden */
  39295. private _onCollisionPositionChange;
  39296. /** @hidden */
  39297. _checkInputs(): void;
  39298. /** @hidden */
  39299. _decideIfNeedsToMove(): boolean;
  39300. /** @hidden */
  39301. _updatePosition(): void;
  39302. /**
  39303. * Restore the Roll to its target value at the rate specified.
  39304. * @param rate - Higher means slower restoring.
  39305. * @hidden
  39306. */
  39307. restoreRoll(rate: number): void;
  39308. /**
  39309. * Destroy the camera and release the current resources held by it.
  39310. */
  39311. dispose(): void;
  39312. /**
  39313. * Get the current object class name.
  39314. * @returns the class name.
  39315. */
  39316. getClassName(): string;
  39317. }
  39318. }
  39319. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39320. import { Nullable } from "babylonjs/types";
  39321. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39322. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39323. /**
  39324. * Listen to keyboard events to control the camera.
  39325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39326. */
  39327. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39328. /**
  39329. * Defines the camera the input is attached to.
  39330. */
  39331. camera: FlyCamera;
  39332. /**
  39333. * The list of keyboard keys used to control the forward move of the camera.
  39334. */
  39335. keysForward: number[];
  39336. /**
  39337. * The list of keyboard keys used to control the backward move of the camera.
  39338. */
  39339. keysBackward: number[];
  39340. /**
  39341. * The list of keyboard keys used to control the forward move of the camera.
  39342. */
  39343. keysUp: number[];
  39344. /**
  39345. * The list of keyboard keys used to control the backward move of the camera.
  39346. */
  39347. keysDown: number[];
  39348. /**
  39349. * The list of keyboard keys used to control the right strafe move of the camera.
  39350. */
  39351. keysRight: number[];
  39352. /**
  39353. * The list of keyboard keys used to control the left strafe move of the camera.
  39354. */
  39355. keysLeft: number[];
  39356. private _keys;
  39357. private _onCanvasBlurObserver;
  39358. private _onKeyboardObserver;
  39359. private _engine;
  39360. private _scene;
  39361. /**
  39362. * Attach the input controls to a specific dom element to get the input from.
  39363. * @param element Defines the element the controls should be listened from
  39364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39365. */
  39366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39367. /**
  39368. * Detach the current controls from the specified dom element.
  39369. * @param element Defines the element to stop listening the inputs from
  39370. */
  39371. detachControl(element: Nullable<HTMLElement>): void;
  39372. /**
  39373. * Gets the class name of the current intput.
  39374. * @returns the class name
  39375. */
  39376. getClassName(): string;
  39377. /** @hidden */
  39378. _onLostFocus(e: FocusEvent): void;
  39379. /**
  39380. * Get the friendly name associated with the input class.
  39381. * @returns the input friendly name
  39382. */
  39383. getSimpleName(): string;
  39384. /**
  39385. * Update the current camera state depending on the inputs that have been used this frame.
  39386. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39387. */
  39388. checkInputs(): void;
  39389. }
  39390. }
  39391. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39392. import { Nullable } from "babylonjs/types";
  39393. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39394. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39395. /**
  39396. * Manage the mouse wheel inputs to control a follow camera.
  39397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39398. */
  39399. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39400. /**
  39401. * Defines the camera the input is attached to.
  39402. */
  39403. camera: FollowCamera;
  39404. /**
  39405. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39406. */
  39407. axisControlRadius: boolean;
  39408. /**
  39409. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39410. */
  39411. axisControlHeight: boolean;
  39412. /**
  39413. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39414. */
  39415. axisControlRotation: boolean;
  39416. /**
  39417. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39418. * relation to mouseWheel events.
  39419. */
  39420. wheelPrecision: number;
  39421. /**
  39422. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39423. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39424. */
  39425. wheelDeltaPercentage: number;
  39426. private _wheel;
  39427. private _observer;
  39428. /**
  39429. * Attach the input controls to a specific dom element to get the input from.
  39430. * @param element Defines the element the controls should be listened from
  39431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39432. */
  39433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39434. /**
  39435. * Detach the current controls from the specified dom element.
  39436. * @param element Defines the element to stop listening the inputs from
  39437. */
  39438. detachControl(element: Nullable<HTMLElement>): void;
  39439. /**
  39440. * Gets the class name of the current intput.
  39441. * @returns the class name
  39442. */
  39443. getClassName(): string;
  39444. /**
  39445. * Get the friendly name associated with the input class.
  39446. * @returns the input friendly name
  39447. */
  39448. getSimpleName(): string;
  39449. }
  39450. }
  39451. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39452. import { Nullable } from "babylonjs/types";
  39453. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39454. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39455. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39456. /**
  39457. * Manage the pointers inputs to control an follow camera.
  39458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39459. */
  39460. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39461. /**
  39462. * Defines the camera the input is attached to.
  39463. */
  39464. camera: FollowCamera;
  39465. /**
  39466. * Gets the class name of the current input.
  39467. * @returns the class name
  39468. */
  39469. getClassName(): string;
  39470. /**
  39471. * Defines the pointer angular sensibility along the X axis or how fast is
  39472. * the camera rotating.
  39473. * A negative number will reverse the axis direction.
  39474. */
  39475. angularSensibilityX: number;
  39476. /**
  39477. * Defines the pointer angular sensibility along the Y axis or how fast is
  39478. * the camera rotating.
  39479. * A negative number will reverse the axis direction.
  39480. */
  39481. angularSensibilityY: number;
  39482. /**
  39483. * Defines the pointer pinch precision or how fast is the camera zooming.
  39484. * A negative number will reverse the axis direction.
  39485. */
  39486. pinchPrecision: number;
  39487. /**
  39488. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39489. * from 0.
  39490. * It defines the percentage of current camera.radius to use as delta when
  39491. * pinch zoom is used.
  39492. */
  39493. pinchDeltaPercentage: number;
  39494. /**
  39495. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39496. */
  39497. axisXControlRadius: boolean;
  39498. /**
  39499. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39500. */
  39501. axisXControlHeight: boolean;
  39502. /**
  39503. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39504. */
  39505. axisXControlRotation: boolean;
  39506. /**
  39507. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39508. */
  39509. axisYControlRadius: boolean;
  39510. /**
  39511. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39512. */
  39513. axisYControlHeight: boolean;
  39514. /**
  39515. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39516. */
  39517. axisYControlRotation: boolean;
  39518. /**
  39519. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39520. */
  39521. axisPinchControlRadius: boolean;
  39522. /**
  39523. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39524. */
  39525. axisPinchControlHeight: boolean;
  39526. /**
  39527. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39528. */
  39529. axisPinchControlRotation: boolean;
  39530. /**
  39531. * Log error messages if basic misconfiguration has occurred.
  39532. */
  39533. warningEnable: boolean;
  39534. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39535. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39536. private _warningCounter;
  39537. private _warning;
  39538. }
  39539. }
  39540. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39541. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39542. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39543. /**
  39544. * Default Inputs manager for the FollowCamera.
  39545. * It groups all the default supported inputs for ease of use.
  39546. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39547. */
  39548. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39549. /**
  39550. * Instantiates a new FollowCameraInputsManager.
  39551. * @param camera Defines the camera the inputs belong to
  39552. */
  39553. constructor(camera: FollowCamera);
  39554. /**
  39555. * Add keyboard input support to the input manager.
  39556. * @returns the current input manager
  39557. */
  39558. addKeyboard(): FollowCameraInputsManager;
  39559. /**
  39560. * Add mouse wheel input support to the input manager.
  39561. * @returns the current input manager
  39562. */
  39563. addMouseWheel(): FollowCameraInputsManager;
  39564. /**
  39565. * Add pointers input support to the input manager.
  39566. * @returns the current input manager
  39567. */
  39568. addPointers(): FollowCameraInputsManager;
  39569. /**
  39570. * Add orientation input support to the input manager.
  39571. * @returns the current input manager
  39572. */
  39573. addVRDeviceOrientation(): FollowCameraInputsManager;
  39574. }
  39575. }
  39576. declare module "babylonjs/Cameras/followCamera" {
  39577. import { Nullable } from "babylonjs/types";
  39578. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39579. import { Scene } from "babylonjs/scene";
  39580. import { Vector3 } from "babylonjs/Maths/math.vector";
  39581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39582. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39583. /**
  39584. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39585. * an arc rotate version arcFollowCamera are available.
  39586. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39587. */
  39588. export class FollowCamera extends TargetCamera {
  39589. /**
  39590. * Distance the follow camera should follow an object at
  39591. */
  39592. radius: number;
  39593. /**
  39594. * Minimum allowed distance of the camera to the axis of rotation
  39595. * (The camera can not get closer).
  39596. * This can help limiting how the Camera is able to move in the scene.
  39597. */
  39598. lowerRadiusLimit: Nullable<number>;
  39599. /**
  39600. * Maximum allowed distance of the camera to the axis of rotation
  39601. * (The camera can not get further).
  39602. * This can help limiting how the Camera is able to move in the scene.
  39603. */
  39604. upperRadiusLimit: Nullable<number>;
  39605. /**
  39606. * Define a rotation offset between the camera and the object it follows
  39607. */
  39608. rotationOffset: number;
  39609. /**
  39610. * Minimum allowed angle to camera position relative to target object.
  39611. * This can help limiting how the Camera is able to move in the scene.
  39612. */
  39613. lowerRotationOffsetLimit: Nullable<number>;
  39614. /**
  39615. * Maximum allowed angle to camera position relative to target object.
  39616. * This can help limiting how the Camera is able to move in the scene.
  39617. */
  39618. upperRotationOffsetLimit: Nullable<number>;
  39619. /**
  39620. * Define a height offset between the camera and the object it follows.
  39621. * It can help following an object from the top (like a car chaing a plane)
  39622. */
  39623. heightOffset: number;
  39624. /**
  39625. * Minimum allowed height of camera position relative to target object.
  39626. * This can help limiting how the Camera is able to move in the scene.
  39627. */
  39628. lowerHeightOffsetLimit: Nullable<number>;
  39629. /**
  39630. * Maximum allowed height of camera position relative to target object.
  39631. * This can help limiting how the Camera is able to move in the scene.
  39632. */
  39633. upperHeightOffsetLimit: Nullable<number>;
  39634. /**
  39635. * Define how fast the camera can accelerate to follow it s target.
  39636. */
  39637. cameraAcceleration: number;
  39638. /**
  39639. * Define the speed limit of the camera following an object.
  39640. */
  39641. maxCameraSpeed: number;
  39642. /**
  39643. * Define the target of the camera.
  39644. */
  39645. lockedTarget: Nullable<AbstractMesh>;
  39646. /**
  39647. * Defines the input associated with the camera.
  39648. */
  39649. inputs: FollowCameraInputsManager;
  39650. /**
  39651. * Instantiates the follow camera.
  39652. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39653. * @param name Define the name of the camera in the scene
  39654. * @param position Define the position of the camera
  39655. * @param scene Define the scene the camera belong to
  39656. * @param lockedTarget Define the target of the camera
  39657. */
  39658. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39659. private _follow;
  39660. /**
  39661. * Attached controls to the current camera.
  39662. * @param element Defines the element the controls should be listened from
  39663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39664. */
  39665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39666. /**
  39667. * Detach the current controls from the camera.
  39668. * The camera will stop reacting to inputs.
  39669. * @param element Defines the element to stop listening the inputs from
  39670. */
  39671. detachControl(element: HTMLElement): void;
  39672. /** @hidden */
  39673. _checkInputs(): void;
  39674. private _checkLimits;
  39675. /**
  39676. * Gets the camera class name.
  39677. * @returns the class name
  39678. */
  39679. getClassName(): string;
  39680. }
  39681. /**
  39682. * Arc Rotate version of the follow camera.
  39683. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39684. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39685. */
  39686. export class ArcFollowCamera extends TargetCamera {
  39687. /** The longitudinal angle of the camera */
  39688. alpha: number;
  39689. /** The latitudinal angle of the camera */
  39690. beta: number;
  39691. /** The radius of the camera from its target */
  39692. radius: number;
  39693. /** Define the camera target (the messh it should follow) */
  39694. target: Nullable<AbstractMesh>;
  39695. private _cartesianCoordinates;
  39696. /**
  39697. * Instantiates a new ArcFollowCamera
  39698. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39699. * @param name Define the name of the camera
  39700. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39701. * @param beta Define the rotation angle of the camera around the elevation axis
  39702. * @param radius Define the radius of the camera from its target point
  39703. * @param target Define the target of the camera
  39704. * @param scene Define the scene the camera belongs to
  39705. */
  39706. constructor(name: string,
  39707. /** The longitudinal angle of the camera */
  39708. alpha: number,
  39709. /** The latitudinal angle of the camera */
  39710. beta: number,
  39711. /** The radius of the camera from its target */
  39712. radius: number,
  39713. /** Define the camera target (the messh it should follow) */
  39714. target: Nullable<AbstractMesh>, scene: Scene);
  39715. private _follow;
  39716. /** @hidden */
  39717. _checkInputs(): void;
  39718. /**
  39719. * Returns the class name of the object.
  39720. * It is mostly used internally for serialization purposes.
  39721. */
  39722. getClassName(): string;
  39723. }
  39724. }
  39725. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39726. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39727. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39728. import { Nullable } from "babylonjs/types";
  39729. /**
  39730. * Manage the keyboard inputs to control the movement of a follow camera.
  39731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39732. */
  39733. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39734. /**
  39735. * Defines the camera the input is attached to.
  39736. */
  39737. camera: FollowCamera;
  39738. /**
  39739. * Defines the list of key codes associated with the up action (increase heightOffset)
  39740. */
  39741. keysHeightOffsetIncr: number[];
  39742. /**
  39743. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39744. */
  39745. keysHeightOffsetDecr: number[];
  39746. /**
  39747. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39748. */
  39749. keysHeightOffsetModifierAlt: boolean;
  39750. /**
  39751. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39752. */
  39753. keysHeightOffsetModifierCtrl: boolean;
  39754. /**
  39755. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39756. */
  39757. keysHeightOffsetModifierShift: boolean;
  39758. /**
  39759. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39760. */
  39761. keysRotationOffsetIncr: number[];
  39762. /**
  39763. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39764. */
  39765. keysRotationOffsetDecr: number[];
  39766. /**
  39767. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39768. */
  39769. keysRotationOffsetModifierAlt: boolean;
  39770. /**
  39771. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39772. */
  39773. keysRotationOffsetModifierCtrl: boolean;
  39774. /**
  39775. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39776. */
  39777. keysRotationOffsetModifierShift: boolean;
  39778. /**
  39779. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39780. */
  39781. keysRadiusIncr: number[];
  39782. /**
  39783. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39784. */
  39785. keysRadiusDecr: number[];
  39786. /**
  39787. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39788. */
  39789. keysRadiusModifierAlt: boolean;
  39790. /**
  39791. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39792. */
  39793. keysRadiusModifierCtrl: boolean;
  39794. /**
  39795. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39796. */
  39797. keysRadiusModifierShift: boolean;
  39798. /**
  39799. * Defines the rate of change of heightOffset.
  39800. */
  39801. heightSensibility: number;
  39802. /**
  39803. * Defines the rate of change of rotationOffset.
  39804. */
  39805. rotationSensibility: number;
  39806. /**
  39807. * Defines the rate of change of radius.
  39808. */
  39809. radiusSensibility: number;
  39810. private _keys;
  39811. private _ctrlPressed;
  39812. private _altPressed;
  39813. private _shiftPressed;
  39814. private _onCanvasBlurObserver;
  39815. private _onKeyboardObserver;
  39816. private _engine;
  39817. private _scene;
  39818. /**
  39819. * Attach the input controls to a specific dom element to get the input from.
  39820. * @param element Defines the element the controls should be listened from
  39821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39822. */
  39823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39824. /**
  39825. * Detach the current controls from the specified dom element.
  39826. * @param element Defines the element to stop listening the inputs from
  39827. */
  39828. detachControl(element: Nullable<HTMLElement>): void;
  39829. /**
  39830. * Update the current camera state depending on the inputs that have been used this frame.
  39831. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39832. */
  39833. checkInputs(): void;
  39834. /**
  39835. * Gets the class name of the current input.
  39836. * @returns the class name
  39837. */
  39838. getClassName(): string;
  39839. /**
  39840. * Get the friendly name associated with the input class.
  39841. * @returns the input friendly name
  39842. */
  39843. getSimpleName(): string;
  39844. /**
  39845. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39846. * allow modification of the heightOffset value.
  39847. */
  39848. private _modifierHeightOffset;
  39849. /**
  39850. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39851. * allow modification of the rotationOffset value.
  39852. */
  39853. private _modifierRotationOffset;
  39854. /**
  39855. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39856. * allow modification of the radius value.
  39857. */
  39858. private _modifierRadius;
  39859. }
  39860. }
  39861. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39862. import { Nullable } from "babylonjs/types";
  39863. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39864. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39865. import { Observable } from "babylonjs/Misc/observable";
  39866. module "babylonjs/Cameras/freeCameraInputsManager" {
  39867. interface FreeCameraInputsManager {
  39868. /**
  39869. * @hidden
  39870. */
  39871. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39872. /**
  39873. * Add orientation input support to the input manager.
  39874. * @returns the current input manager
  39875. */
  39876. addDeviceOrientation(): FreeCameraInputsManager;
  39877. }
  39878. }
  39879. /**
  39880. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39881. * Screen rotation is taken into account.
  39882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39883. */
  39884. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39885. private _camera;
  39886. private _screenOrientationAngle;
  39887. private _constantTranform;
  39888. private _screenQuaternion;
  39889. private _alpha;
  39890. private _beta;
  39891. private _gamma;
  39892. /**
  39893. * Can be used to detect if a device orientation sensor is availible on a device
  39894. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39895. * @returns a promise that will resolve on orientation change
  39896. */
  39897. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39898. /**
  39899. * @hidden
  39900. */
  39901. _onDeviceOrientationChangedObservable: Observable<void>;
  39902. /**
  39903. * Instantiates a new input
  39904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39905. */
  39906. constructor();
  39907. /**
  39908. * Define the camera controlled by the input.
  39909. */
  39910. camera: FreeCamera;
  39911. /**
  39912. * Attach the input controls to a specific dom element to get the input from.
  39913. * @param element Defines the element the controls should be listened from
  39914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39915. */
  39916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39917. private _orientationChanged;
  39918. private _deviceOrientation;
  39919. /**
  39920. * Detach the current controls from the specified dom element.
  39921. * @param element Defines the element to stop listening the inputs from
  39922. */
  39923. detachControl(element: Nullable<HTMLElement>): void;
  39924. /**
  39925. * Update the current camera state depending on the inputs that have been used this frame.
  39926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39927. */
  39928. checkInputs(): void;
  39929. /**
  39930. * Gets the class name of the current intput.
  39931. * @returns the class name
  39932. */
  39933. getClassName(): string;
  39934. /**
  39935. * Get the friendly name associated with the input class.
  39936. * @returns the input friendly name
  39937. */
  39938. getSimpleName(): string;
  39939. }
  39940. }
  39941. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39942. import { Nullable } from "babylonjs/types";
  39943. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39944. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39945. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39946. /**
  39947. * Manage the gamepad inputs to control a free camera.
  39948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39949. */
  39950. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39951. /**
  39952. * Define the camera the input is attached to.
  39953. */
  39954. camera: FreeCamera;
  39955. /**
  39956. * Define the Gamepad controlling the input
  39957. */
  39958. gamepad: Nullable<Gamepad>;
  39959. /**
  39960. * Defines the gamepad rotation sensiblity.
  39961. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39962. */
  39963. gamepadAngularSensibility: number;
  39964. /**
  39965. * Defines the gamepad move sensiblity.
  39966. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39967. */
  39968. gamepadMoveSensibility: number;
  39969. private _yAxisScale;
  39970. /**
  39971. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39972. */
  39973. invertYAxis: boolean;
  39974. private _onGamepadConnectedObserver;
  39975. private _onGamepadDisconnectedObserver;
  39976. private _cameraTransform;
  39977. private _deltaTransform;
  39978. private _vector3;
  39979. private _vector2;
  39980. /**
  39981. * Attach the input controls to a specific dom element to get the input from.
  39982. * @param element Defines the element the controls should be listened from
  39983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39984. */
  39985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39986. /**
  39987. * Detach the current controls from the specified dom element.
  39988. * @param element Defines the element to stop listening the inputs from
  39989. */
  39990. detachControl(element: Nullable<HTMLElement>): void;
  39991. /**
  39992. * Update the current camera state depending on the inputs that have been used this frame.
  39993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39994. */
  39995. checkInputs(): void;
  39996. /**
  39997. * Gets the class name of the current intput.
  39998. * @returns the class name
  39999. */
  40000. getClassName(): string;
  40001. /**
  40002. * Get the friendly name associated with the input class.
  40003. * @returns the input friendly name
  40004. */
  40005. getSimpleName(): string;
  40006. }
  40007. }
  40008. declare module "babylonjs/Misc/virtualJoystick" {
  40009. import { Nullable } from "babylonjs/types";
  40010. import { Vector3 } from "babylonjs/Maths/math.vector";
  40011. /**
  40012. * Defines the potential axis of a Joystick
  40013. */
  40014. export enum JoystickAxis {
  40015. /** X axis */
  40016. X = 0,
  40017. /** Y axis */
  40018. Y = 1,
  40019. /** Z axis */
  40020. Z = 2
  40021. }
  40022. /**
  40023. * Class used to define virtual joystick (used in touch mode)
  40024. */
  40025. export class VirtualJoystick {
  40026. /**
  40027. * Gets or sets a boolean indicating that left and right values must be inverted
  40028. */
  40029. reverseLeftRight: boolean;
  40030. /**
  40031. * Gets or sets a boolean indicating that up and down values must be inverted
  40032. */
  40033. reverseUpDown: boolean;
  40034. /**
  40035. * Gets the offset value for the position (ie. the change of the position value)
  40036. */
  40037. deltaPosition: Vector3;
  40038. /**
  40039. * Gets a boolean indicating if the virtual joystick was pressed
  40040. */
  40041. pressed: boolean;
  40042. /**
  40043. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40044. */
  40045. static Canvas: Nullable<HTMLCanvasElement>;
  40046. private static _globalJoystickIndex;
  40047. private static vjCanvasContext;
  40048. private static vjCanvasWidth;
  40049. private static vjCanvasHeight;
  40050. private static halfWidth;
  40051. private _action;
  40052. private _axisTargetedByLeftAndRight;
  40053. private _axisTargetedByUpAndDown;
  40054. private _joystickSensibility;
  40055. private _inversedSensibility;
  40056. private _joystickPointerID;
  40057. private _joystickColor;
  40058. private _joystickPointerPos;
  40059. private _joystickPreviousPointerPos;
  40060. private _joystickPointerStartPos;
  40061. private _deltaJoystickVector;
  40062. private _leftJoystick;
  40063. private _touches;
  40064. private _onPointerDownHandlerRef;
  40065. private _onPointerMoveHandlerRef;
  40066. private _onPointerUpHandlerRef;
  40067. private _onResize;
  40068. /**
  40069. * Creates a new virtual joystick
  40070. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40071. */
  40072. constructor(leftJoystick?: boolean);
  40073. /**
  40074. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40075. * @param newJoystickSensibility defines the new sensibility
  40076. */
  40077. setJoystickSensibility(newJoystickSensibility: number): void;
  40078. private _onPointerDown;
  40079. private _onPointerMove;
  40080. private _onPointerUp;
  40081. /**
  40082. * Change the color of the virtual joystick
  40083. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40084. */
  40085. setJoystickColor(newColor: string): void;
  40086. /**
  40087. * Defines a callback to call when the joystick is touched
  40088. * @param action defines the callback
  40089. */
  40090. setActionOnTouch(action: () => any): void;
  40091. /**
  40092. * Defines which axis you'd like to control for left & right
  40093. * @param axis defines the axis to use
  40094. */
  40095. setAxisForLeftRight(axis: JoystickAxis): void;
  40096. /**
  40097. * Defines which axis you'd like to control for up & down
  40098. * @param axis defines the axis to use
  40099. */
  40100. setAxisForUpDown(axis: JoystickAxis): void;
  40101. private _drawVirtualJoystick;
  40102. /**
  40103. * Release internal HTML canvas
  40104. */
  40105. releaseCanvas(): void;
  40106. }
  40107. }
  40108. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40109. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40110. import { Nullable } from "babylonjs/types";
  40111. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40112. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40113. module "babylonjs/Cameras/freeCameraInputsManager" {
  40114. interface FreeCameraInputsManager {
  40115. /**
  40116. * Add virtual joystick input support to the input manager.
  40117. * @returns the current input manager
  40118. */
  40119. addVirtualJoystick(): FreeCameraInputsManager;
  40120. }
  40121. }
  40122. /**
  40123. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40125. */
  40126. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40127. /**
  40128. * Defines the camera the input is attached to.
  40129. */
  40130. camera: FreeCamera;
  40131. private _leftjoystick;
  40132. private _rightjoystick;
  40133. /**
  40134. * Gets the left stick of the virtual joystick.
  40135. * @returns The virtual Joystick
  40136. */
  40137. getLeftJoystick(): VirtualJoystick;
  40138. /**
  40139. * Gets the right stick of the virtual joystick.
  40140. * @returns The virtual Joystick
  40141. */
  40142. getRightJoystick(): VirtualJoystick;
  40143. /**
  40144. * Update the current camera state depending on the inputs that have been used this frame.
  40145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40146. */
  40147. checkInputs(): void;
  40148. /**
  40149. * Attach the input controls to a specific dom element to get the input from.
  40150. * @param element Defines the element the controls should be listened from
  40151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40152. */
  40153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40154. /**
  40155. * Detach the current controls from the specified dom element.
  40156. * @param element Defines the element to stop listening the inputs from
  40157. */
  40158. detachControl(element: Nullable<HTMLElement>): void;
  40159. /**
  40160. * Gets the class name of the current intput.
  40161. * @returns the class name
  40162. */
  40163. getClassName(): string;
  40164. /**
  40165. * Get the friendly name associated with the input class.
  40166. * @returns the input friendly name
  40167. */
  40168. getSimpleName(): string;
  40169. }
  40170. }
  40171. declare module "babylonjs/Cameras/Inputs/index" {
  40172. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40173. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40174. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40175. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40176. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40177. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40178. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40179. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40180. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40181. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40182. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40183. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40184. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40185. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40186. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40187. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40188. }
  40189. declare module "babylonjs/Cameras/touchCamera" {
  40190. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40191. import { Scene } from "babylonjs/scene";
  40192. import { Vector3 } from "babylonjs/Maths/math.vector";
  40193. /**
  40194. * This represents a FPS type of camera controlled by touch.
  40195. * This is like a universal camera minus the Gamepad controls.
  40196. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40197. */
  40198. export class TouchCamera extends FreeCamera {
  40199. /**
  40200. * Defines the touch sensibility for rotation.
  40201. * The higher the faster.
  40202. */
  40203. touchAngularSensibility: number;
  40204. /**
  40205. * Defines the touch sensibility for move.
  40206. * The higher the faster.
  40207. */
  40208. touchMoveSensibility: number;
  40209. /**
  40210. * Instantiates a new touch camera.
  40211. * This represents a FPS type of camera controlled by touch.
  40212. * This is like a universal camera minus the Gamepad controls.
  40213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40214. * @param name Define the name of the camera in the scene
  40215. * @param position Define the start position of the camera in the scene
  40216. * @param scene Define the scene the camera belongs to
  40217. */
  40218. constructor(name: string, position: Vector3, scene: Scene);
  40219. /**
  40220. * Gets the current object class name.
  40221. * @return the class name
  40222. */
  40223. getClassName(): string;
  40224. /** @hidden */
  40225. _setupInputs(): void;
  40226. }
  40227. }
  40228. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40229. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40230. import { Scene } from "babylonjs/scene";
  40231. import { Vector3 } from "babylonjs/Maths/math.vector";
  40232. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40233. import { Axis } from "babylonjs/Maths/math.axis";
  40234. /**
  40235. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40236. * being tilted forward or back and left or right.
  40237. */
  40238. export class DeviceOrientationCamera extends FreeCamera {
  40239. private _initialQuaternion;
  40240. private _quaternionCache;
  40241. private _tmpDragQuaternion;
  40242. private _disablePointerInputWhenUsingDeviceOrientation;
  40243. /**
  40244. * Creates a new device orientation camera
  40245. * @param name The name of the camera
  40246. * @param position The start position camera
  40247. * @param scene The scene the camera belongs to
  40248. */
  40249. constructor(name: string, position: Vector3, scene: Scene);
  40250. /**
  40251. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40252. */
  40253. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40254. private _dragFactor;
  40255. /**
  40256. * Enabled turning on the y axis when the orientation sensor is active
  40257. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40258. */
  40259. enableHorizontalDragging(dragFactor?: number): void;
  40260. /**
  40261. * Gets the current instance class name ("DeviceOrientationCamera").
  40262. * This helps avoiding instanceof at run time.
  40263. * @returns the class name
  40264. */
  40265. getClassName(): string;
  40266. /**
  40267. * @hidden
  40268. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40269. */
  40270. _checkInputs(): void;
  40271. /**
  40272. * Reset the camera to its default orientation on the specified axis only.
  40273. * @param axis The axis to reset
  40274. */
  40275. resetToCurrentRotation(axis?: Axis): void;
  40276. }
  40277. }
  40278. declare module "babylonjs/Gamepads/xboxGamepad" {
  40279. import { Observable } from "babylonjs/Misc/observable";
  40280. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40281. /**
  40282. * Defines supported buttons for XBox360 compatible gamepads
  40283. */
  40284. export enum Xbox360Button {
  40285. /** A */
  40286. A = 0,
  40287. /** B */
  40288. B = 1,
  40289. /** X */
  40290. X = 2,
  40291. /** Y */
  40292. Y = 3,
  40293. /** Start */
  40294. Start = 4,
  40295. /** Back */
  40296. Back = 5,
  40297. /** Left button */
  40298. LB = 6,
  40299. /** Right button */
  40300. RB = 7,
  40301. /** Left stick */
  40302. LeftStick = 8,
  40303. /** Right stick */
  40304. RightStick = 9
  40305. }
  40306. /** Defines values for XBox360 DPad */
  40307. export enum Xbox360Dpad {
  40308. /** Up */
  40309. Up = 0,
  40310. /** Down */
  40311. Down = 1,
  40312. /** Left */
  40313. Left = 2,
  40314. /** Right */
  40315. Right = 3
  40316. }
  40317. /**
  40318. * Defines a XBox360 gamepad
  40319. */
  40320. export class Xbox360Pad extends Gamepad {
  40321. private _leftTrigger;
  40322. private _rightTrigger;
  40323. private _onlefttriggerchanged;
  40324. private _onrighttriggerchanged;
  40325. private _onbuttondown;
  40326. private _onbuttonup;
  40327. private _ondpaddown;
  40328. private _ondpadup;
  40329. /** Observable raised when a button is pressed */
  40330. onButtonDownObservable: Observable<Xbox360Button>;
  40331. /** Observable raised when a button is released */
  40332. onButtonUpObservable: Observable<Xbox360Button>;
  40333. /** Observable raised when a pad is pressed */
  40334. onPadDownObservable: Observable<Xbox360Dpad>;
  40335. /** Observable raised when a pad is released */
  40336. onPadUpObservable: Observable<Xbox360Dpad>;
  40337. private _buttonA;
  40338. private _buttonB;
  40339. private _buttonX;
  40340. private _buttonY;
  40341. private _buttonBack;
  40342. private _buttonStart;
  40343. private _buttonLB;
  40344. private _buttonRB;
  40345. private _buttonLeftStick;
  40346. private _buttonRightStick;
  40347. private _dPadUp;
  40348. private _dPadDown;
  40349. private _dPadLeft;
  40350. private _dPadRight;
  40351. private _isXboxOnePad;
  40352. /**
  40353. * Creates a new XBox360 gamepad object
  40354. * @param id defines the id of this gamepad
  40355. * @param index defines its index
  40356. * @param gamepad defines the internal HTML gamepad object
  40357. * @param xboxOne defines if it is a XBox One gamepad
  40358. */
  40359. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40360. /**
  40361. * Defines the callback to call when left trigger is pressed
  40362. * @param callback defines the callback to use
  40363. */
  40364. onlefttriggerchanged(callback: (value: number) => void): void;
  40365. /**
  40366. * Defines the callback to call when right trigger is pressed
  40367. * @param callback defines the callback to use
  40368. */
  40369. onrighttriggerchanged(callback: (value: number) => void): void;
  40370. /**
  40371. * Gets the left trigger value
  40372. */
  40373. /**
  40374. * Sets the left trigger value
  40375. */
  40376. leftTrigger: number;
  40377. /**
  40378. * Gets the right trigger value
  40379. */
  40380. /**
  40381. * Sets the right trigger value
  40382. */
  40383. rightTrigger: number;
  40384. /**
  40385. * Defines the callback to call when a button is pressed
  40386. * @param callback defines the callback to use
  40387. */
  40388. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40389. /**
  40390. * Defines the callback to call when a button is released
  40391. * @param callback defines the callback to use
  40392. */
  40393. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40394. /**
  40395. * Defines the callback to call when a pad is pressed
  40396. * @param callback defines the callback to use
  40397. */
  40398. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40399. /**
  40400. * Defines the callback to call when a pad is released
  40401. * @param callback defines the callback to use
  40402. */
  40403. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40404. private _setButtonValue;
  40405. private _setDPadValue;
  40406. /**
  40407. * Gets the value of the `A` button
  40408. */
  40409. /**
  40410. * Sets the value of the `A` button
  40411. */
  40412. buttonA: number;
  40413. /**
  40414. * Gets the value of the `B` button
  40415. */
  40416. /**
  40417. * Sets the value of the `B` button
  40418. */
  40419. buttonB: number;
  40420. /**
  40421. * Gets the value of the `X` button
  40422. */
  40423. /**
  40424. * Sets the value of the `X` button
  40425. */
  40426. buttonX: number;
  40427. /**
  40428. * Gets the value of the `Y` button
  40429. */
  40430. /**
  40431. * Sets the value of the `Y` button
  40432. */
  40433. buttonY: number;
  40434. /**
  40435. * Gets the value of the `Start` button
  40436. */
  40437. /**
  40438. * Sets the value of the `Start` button
  40439. */
  40440. buttonStart: number;
  40441. /**
  40442. * Gets the value of the `Back` button
  40443. */
  40444. /**
  40445. * Sets the value of the `Back` button
  40446. */
  40447. buttonBack: number;
  40448. /**
  40449. * Gets the value of the `Left` button
  40450. */
  40451. /**
  40452. * Sets the value of the `Left` button
  40453. */
  40454. buttonLB: number;
  40455. /**
  40456. * Gets the value of the `Right` button
  40457. */
  40458. /**
  40459. * Sets the value of the `Right` button
  40460. */
  40461. buttonRB: number;
  40462. /**
  40463. * Gets the value of the Left joystick
  40464. */
  40465. /**
  40466. * Sets the value of the Left joystick
  40467. */
  40468. buttonLeftStick: number;
  40469. /**
  40470. * Gets the value of the Right joystick
  40471. */
  40472. /**
  40473. * Sets the value of the Right joystick
  40474. */
  40475. buttonRightStick: number;
  40476. /**
  40477. * Gets the value of D-pad up
  40478. */
  40479. /**
  40480. * Sets the value of D-pad up
  40481. */
  40482. dPadUp: number;
  40483. /**
  40484. * Gets the value of D-pad down
  40485. */
  40486. /**
  40487. * Sets the value of D-pad down
  40488. */
  40489. dPadDown: number;
  40490. /**
  40491. * Gets the value of D-pad left
  40492. */
  40493. /**
  40494. * Sets the value of D-pad left
  40495. */
  40496. dPadLeft: number;
  40497. /**
  40498. * Gets the value of D-pad right
  40499. */
  40500. /**
  40501. * Sets the value of D-pad right
  40502. */
  40503. dPadRight: number;
  40504. /**
  40505. * Force the gamepad to synchronize with device values
  40506. */
  40507. update(): void;
  40508. /**
  40509. * Disposes the gamepad
  40510. */
  40511. dispose(): void;
  40512. }
  40513. }
  40514. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40515. import { Observable } from "babylonjs/Misc/observable";
  40516. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40517. /**
  40518. * Defines supported buttons for DualShock compatible gamepads
  40519. */
  40520. export enum DualShockButton {
  40521. /** Cross */
  40522. Cross = 0,
  40523. /** Circle */
  40524. Circle = 1,
  40525. /** Square */
  40526. Square = 2,
  40527. /** Triangle */
  40528. Triangle = 3,
  40529. /** Options */
  40530. Options = 4,
  40531. /** Share */
  40532. Share = 5,
  40533. /** L1 */
  40534. L1 = 6,
  40535. /** R1 */
  40536. R1 = 7,
  40537. /** Left stick */
  40538. LeftStick = 8,
  40539. /** Right stick */
  40540. RightStick = 9
  40541. }
  40542. /** Defines values for DualShock DPad */
  40543. export enum DualShockDpad {
  40544. /** Up */
  40545. Up = 0,
  40546. /** Down */
  40547. Down = 1,
  40548. /** Left */
  40549. Left = 2,
  40550. /** Right */
  40551. Right = 3
  40552. }
  40553. /**
  40554. * Defines a DualShock gamepad
  40555. */
  40556. export class DualShockPad extends Gamepad {
  40557. private _leftTrigger;
  40558. private _rightTrigger;
  40559. private _onlefttriggerchanged;
  40560. private _onrighttriggerchanged;
  40561. private _onbuttondown;
  40562. private _onbuttonup;
  40563. private _ondpaddown;
  40564. private _ondpadup;
  40565. /** Observable raised when a button is pressed */
  40566. onButtonDownObservable: Observable<DualShockButton>;
  40567. /** Observable raised when a button is released */
  40568. onButtonUpObservable: Observable<DualShockButton>;
  40569. /** Observable raised when a pad is pressed */
  40570. onPadDownObservable: Observable<DualShockDpad>;
  40571. /** Observable raised when a pad is released */
  40572. onPadUpObservable: Observable<DualShockDpad>;
  40573. private _buttonCross;
  40574. private _buttonCircle;
  40575. private _buttonSquare;
  40576. private _buttonTriangle;
  40577. private _buttonShare;
  40578. private _buttonOptions;
  40579. private _buttonL1;
  40580. private _buttonR1;
  40581. private _buttonLeftStick;
  40582. private _buttonRightStick;
  40583. private _dPadUp;
  40584. private _dPadDown;
  40585. private _dPadLeft;
  40586. private _dPadRight;
  40587. /**
  40588. * Creates a new DualShock gamepad object
  40589. * @param id defines the id of this gamepad
  40590. * @param index defines its index
  40591. * @param gamepad defines the internal HTML gamepad object
  40592. */
  40593. constructor(id: string, index: number, gamepad: any);
  40594. /**
  40595. * Defines the callback to call when left trigger is pressed
  40596. * @param callback defines the callback to use
  40597. */
  40598. onlefttriggerchanged(callback: (value: number) => void): void;
  40599. /**
  40600. * Defines the callback to call when right trigger is pressed
  40601. * @param callback defines the callback to use
  40602. */
  40603. onrighttriggerchanged(callback: (value: number) => void): void;
  40604. /**
  40605. * Gets the left trigger value
  40606. */
  40607. /**
  40608. * Sets the left trigger value
  40609. */
  40610. leftTrigger: number;
  40611. /**
  40612. * Gets the right trigger value
  40613. */
  40614. /**
  40615. * Sets the right trigger value
  40616. */
  40617. rightTrigger: number;
  40618. /**
  40619. * Defines the callback to call when a button is pressed
  40620. * @param callback defines the callback to use
  40621. */
  40622. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40623. /**
  40624. * Defines the callback to call when a button is released
  40625. * @param callback defines the callback to use
  40626. */
  40627. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40628. /**
  40629. * Defines the callback to call when a pad is pressed
  40630. * @param callback defines the callback to use
  40631. */
  40632. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40633. /**
  40634. * Defines the callback to call when a pad is released
  40635. * @param callback defines the callback to use
  40636. */
  40637. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40638. private _setButtonValue;
  40639. private _setDPadValue;
  40640. /**
  40641. * Gets the value of the `Cross` button
  40642. */
  40643. /**
  40644. * Sets the value of the `Cross` button
  40645. */
  40646. buttonCross: number;
  40647. /**
  40648. * Gets the value of the `Circle` button
  40649. */
  40650. /**
  40651. * Sets the value of the `Circle` button
  40652. */
  40653. buttonCircle: number;
  40654. /**
  40655. * Gets the value of the `Square` button
  40656. */
  40657. /**
  40658. * Sets the value of the `Square` button
  40659. */
  40660. buttonSquare: number;
  40661. /**
  40662. * Gets the value of the `Triangle` button
  40663. */
  40664. /**
  40665. * Sets the value of the `Triangle` button
  40666. */
  40667. buttonTriangle: number;
  40668. /**
  40669. * Gets the value of the `Options` button
  40670. */
  40671. /**
  40672. * Sets the value of the `Options` button
  40673. */
  40674. buttonOptions: number;
  40675. /**
  40676. * Gets the value of the `Share` button
  40677. */
  40678. /**
  40679. * Sets the value of the `Share` button
  40680. */
  40681. buttonShare: number;
  40682. /**
  40683. * Gets the value of the `L1` button
  40684. */
  40685. /**
  40686. * Sets the value of the `L1` button
  40687. */
  40688. buttonL1: number;
  40689. /**
  40690. * Gets the value of the `R1` button
  40691. */
  40692. /**
  40693. * Sets the value of the `R1` button
  40694. */
  40695. buttonR1: number;
  40696. /**
  40697. * Gets the value of the Left joystick
  40698. */
  40699. /**
  40700. * Sets the value of the Left joystick
  40701. */
  40702. buttonLeftStick: number;
  40703. /**
  40704. * Gets the value of the Right joystick
  40705. */
  40706. /**
  40707. * Sets the value of the Right joystick
  40708. */
  40709. buttonRightStick: number;
  40710. /**
  40711. * Gets the value of D-pad up
  40712. */
  40713. /**
  40714. * Sets the value of D-pad up
  40715. */
  40716. dPadUp: number;
  40717. /**
  40718. * Gets the value of D-pad down
  40719. */
  40720. /**
  40721. * Sets the value of D-pad down
  40722. */
  40723. dPadDown: number;
  40724. /**
  40725. * Gets the value of D-pad left
  40726. */
  40727. /**
  40728. * Sets the value of D-pad left
  40729. */
  40730. dPadLeft: number;
  40731. /**
  40732. * Gets the value of D-pad right
  40733. */
  40734. /**
  40735. * Sets the value of D-pad right
  40736. */
  40737. dPadRight: number;
  40738. /**
  40739. * Force the gamepad to synchronize with device values
  40740. */
  40741. update(): void;
  40742. /**
  40743. * Disposes the gamepad
  40744. */
  40745. dispose(): void;
  40746. }
  40747. }
  40748. declare module "babylonjs/Gamepads/gamepadManager" {
  40749. import { Observable } from "babylonjs/Misc/observable";
  40750. import { Nullable } from "babylonjs/types";
  40751. import { Scene } from "babylonjs/scene";
  40752. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40753. /**
  40754. * Manager for handling gamepads
  40755. */
  40756. export class GamepadManager {
  40757. private _scene?;
  40758. private _babylonGamepads;
  40759. private _oneGamepadConnected;
  40760. /** @hidden */
  40761. _isMonitoring: boolean;
  40762. private _gamepadEventSupported;
  40763. private _gamepadSupport;
  40764. /**
  40765. * observable to be triggered when the gamepad controller has been connected
  40766. */
  40767. onGamepadConnectedObservable: Observable<Gamepad>;
  40768. /**
  40769. * observable to be triggered when the gamepad controller has been disconnected
  40770. */
  40771. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40772. private _onGamepadConnectedEvent;
  40773. private _onGamepadDisconnectedEvent;
  40774. /**
  40775. * Initializes the gamepad manager
  40776. * @param _scene BabylonJS scene
  40777. */
  40778. constructor(_scene?: Scene | undefined);
  40779. /**
  40780. * The gamepads in the game pad manager
  40781. */
  40782. readonly gamepads: Gamepad[];
  40783. /**
  40784. * Get the gamepad controllers based on type
  40785. * @param type The type of gamepad controller
  40786. * @returns Nullable gamepad
  40787. */
  40788. getGamepadByType(type?: number): Nullable<Gamepad>;
  40789. /**
  40790. * Disposes the gamepad manager
  40791. */
  40792. dispose(): void;
  40793. private _addNewGamepad;
  40794. private _startMonitoringGamepads;
  40795. private _stopMonitoringGamepads;
  40796. /** @hidden */
  40797. _checkGamepadsStatus(): void;
  40798. private _updateGamepadObjects;
  40799. }
  40800. }
  40801. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40802. import { Nullable } from "babylonjs/types";
  40803. import { Scene } from "babylonjs/scene";
  40804. import { ISceneComponent } from "babylonjs/sceneComponent";
  40805. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40806. module "babylonjs/scene" {
  40807. interface Scene {
  40808. /** @hidden */
  40809. _gamepadManager: Nullable<GamepadManager>;
  40810. /**
  40811. * Gets the gamepad manager associated with the scene
  40812. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40813. */
  40814. gamepadManager: GamepadManager;
  40815. }
  40816. }
  40817. module "babylonjs/Cameras/freeCameraInputsManager" {
  40818. /**
  40819. * Interface representing a free camera inputs manager
  40820. */
  40821. interface FreeCameraInputsManager {
  40822. /**
  40823. * Adds gamepad input support to the FreeCameraInputsManager.
  40824. * @returns the FreeCameraInputsManager
  40825. */
  40826. addGamepad(): FreeCameraInputsManager;
  40827. }
  40828. }
  40829. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40830. /**
  40831. * Interface representing an arc rotate camera inputs manager
  40832. */
  40833. interface ArcRotateCameraInputsManager {
  40834. /**
  40835. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40836. * @returns the camera inputs manager
  40837. */
  40838. addGamepad(): ArcRotateCameraInputsManager;
  40839. }
  40840. }
  40841. /**
  40842. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40843. */
  40844. export class GamepadSystemSceneComponent implements ISceneComponent {
  40845. /**
  40846. * The component name helpfull to identify the component in the list of scene components.
  40847. */
  40848. readonly name: string;
  40849. /**
  40850. * The scene the component belongs to.
  40851. */
  40852. scene: Scene;
  40853. /**
  40854. * Creates a new instance of the component for the given scene
  40855. * @param scene Defines the scene to register the component in
  40856. */
  40857. constructor(scene: Scene);
  40858. /**
  40859. * Registers the component in a given scene
  40860. */
  40861. register(): void;
  40862. /**
  40863. * Rebuilds the elements related to this component in case of
  40864. * context lost for instance.
  40865. */
  40866. rebuild(): void;
  40867. /**
  40868. * Disposes the component and the associated ressources
  40869. */
  40870. dispose(): void;
  40871. private _beforeCameraUpdate;
  40872. }
  40873. }
  40874. declare module "babylonjs/Cameras/universalCamera" {
  40875. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40876. import { Scene } from "babylonjs/scene";
  40877. import { Vector3 } from "babylonjs/Maths/math.vector";
  40878. import "babylonjs/Gamepads/gamepadSceneComponent";
  40879. /**
  40880. * 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,
  40881. * which still works and will still be found in many Playgrounds.
  40882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40883. */
  40884. export class UniversalCamera extends TouchCamera {
  40885. /**
  40886. * Defines the gamepad rotation sensiblity.
  40887. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40888. */
  40889. gamepadAngularSensibility: number;
  40890. /**
  40891. * Defines the gamepad move sensiblity.
  40892. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40893. */
  40894. gamepadMoveSensibility: number;
  40895. /**
  40896. * 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,
  40897. * which still works and will still be found in many Playgrounds.
  40898. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40899. * @param name Define the name of the camera in the scene
  40900. * @param position Define the start position of the camera in the scene
  40901. * @param scene Define the scene the camera belongs to
  40902. */
  40903. constructor(name: string, position: Vector3, scene: Scene);
  40904. /**
  40905. * Gets the current object class name.
  40906. * @return the class name
  40907. */
  40908. getClassName(): string;
  40909. }
  40910. }
  40911. declare module "babylonjs/Cameras/gamepadCamera" {
  40912. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40913. import { Scene } from "babylonjs/scene";
  40914. import { Vector3 } from "babylonjs/Maths/math.vector";
  40915. /**
  40916. * This represents a FPS type of camera. This is only here for back compat purpose.
  40917. * Please use the UniversalCamera instead as both are identical.
  40918. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40919. */
  40920. export class GamepadCamera extends UniversalCamera {
  40921. /**
  40922. * Instantiates a new Gamepad Camera
  40923. * This represents a FPS type of camera. This is only here for back compat purpose.
  40924. * Please use the UniversalCamera instead as both are identical.
  40925. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40926. * @param name Define the name of the camera in the scene
  40927. * @param position Define the start position of the camera in the scene
  40928. * @param scene Define the scene the camera belongs to
  40929. */
  40930. constructor(name: string, position: Vector3, scene: Scene);
  40931. /**
  40932. * Gets the current object class name.
  40933. * @return the class name
  40934. */
  40935. getClassName(): string;
  40936. }
  40937. }
  40938. declare module "babylonjs/Shaders/pass.fragment" {
  40939. /** @hidden */
  40940. export var passPixelShader: {
  40941. name: string;
  40942. shader: string;
  40943. };
  40944. }
  40945. declare module "babylonjs/Shaders/passCube.fragment" {
  40946. /** @hidden */
  40947. export var passCubePixelShader: {
  40948. name: string;
  40949. shader: string;
  40950. };
  40951. }
  40952. declare module "babylonjs/PostProcesses/passPostProcess" {
  40953. import { Nullable } from "babylonjs/types";
  40954. import { Camera } from "babylonjs/Cameras/camera";
  40955. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40956. import { Engine } from "babylonjs/Engines/engine";
  40957. import "babylonjs/Shaders/pass.fragment";
  40958. import "babylonjs/Shaders/passCube.fragment";
  40959. /**
  40960. * PassPostProcess which produces an output the same as it's input
  40961. */
  40962. export class PassPostProcess extends PostProcess {
  40963. /**
  40964. * Creates the PassPostProcess
  40965. * @param name The name of the effect.
  40966. * @param options The required width/height ratio to downsize to before computing the render pass.
  40967. * @param camera The camera to apply the render pass to.
  40968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40969. * @param engine The engine which the post process will be applied. (default: current engine)
  40970. * @param reusable If the post process can be reused on the same frame. (default: false)
  40971. * @param textureType The type of texture to be used when performing the post processing.
  40972. * @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)
  40973. */
  40974. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40975. }
  40976. /**
  40977. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40978. */
  40979. export class PassCubePostProcess extends PostProcess {
  40980. private _face;
  40981. /**
  40982. * Gets or sets the cube face to display.
  40983. * * 0 is +X
  40984. * * 1 is -X
  40985. * * 2 is +Y
  40986. * * 3 is -Y
  40987. * * 4 is +Z
  40988. * * 5 is -Z
  40989. */
  40990. face: number;
  40991. /**
  40992. * Creates the PassCubePostProcess
  40993. * @param name The name of the effect.
  40994. * @param options The required width/height ratio to downsize to before computing the render pass.
  40995. * @param camera The camera to apply the render pass to.
  40996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40997. * @param engine The engine which the post process will be applied. (default: current engine)
  40998. * @param reusable If the post process can be reused on the same frame. (default: false)
  40999. * @param textureType The type of texture to be used when performing the post processing.
  41000. * @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)
  41001. */
  41002. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41003. }
  41004. }
  41005. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41006. /** @hidden */
  41007. export var anaglyphPixelShader: {
  41008. name: string;
  41009. shader: string;
  41010. };
  41011. }
  41012. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41013. import { Engine } from "babylonjs/Engines/engine";
  41014. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41015. import { Camera } from "babylonjs/Cameras/camera";
  41016. import "babylonjs/Shaders/anaglyph.fragment";
  41017. /**
  41018. * Postprocess used to generate anaglyphic rendering
  41019. */
  41020. export class AnaglyphPostProcess extends PostProcess {
  41021. private _passedProcess;
  41022. /**
  41023. * Creates a new AnaglyphPostProcess
  41024. * @param name defines postprocess name
  41025. * @param options defines creation options or target ratio scale
  41026. * @param rigCameras defines cameras using this postprocess
  41027. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41028. * @param engine defines hosting engine
  41029. * @param reusable defines if the postprocess will be reused multiple times per frame
  41030. */
  41031. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41032. }
  41033. }
  41034. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41035. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41036. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41037. import { Scene } from "babylonjs/scene";
  41038. import { Vector3 } from "babylonjs/Maths/math.vector";
  41039. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41040. /**
  41041. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41042. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41043. */
  41044. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41045. /**
  41046. * Creates a new AnaglyphArcRotateCamera
  41047. * @param name defines camera name
  41048. * @param alpha defines alpha angle (in radians)
  41049. * @param beta defines beta angle (in radians)
  41050. * @param radius defines radius
  41051. * @param target defines camera target
  41052. * @param interaxialDistance defines distance between each color axis
  41053. * @param scene defines the hosting scene
  41054. */
  41055. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41056. /**
  41057. * Gets camera class name
  41058. * @returns AnaglyphArcRotateCamera
  41059. */
  41060. getClassName(): string;
  41061. }
  41062. }
  41063. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41064. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41065. import { Scene } from "babylonjs/scene";
  41066. import { Vector3 } from "babylonjs/Maths/math.vector";
  41067. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41068. /**
  41069. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41070. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41071. */
  41072. export class AnaglyphFreeCamera extends FreeCamera {
  41073. /**
  41074. * Creates a new AnaglyphFreeCamera
  41075. * @param name defines camera name
  41076. * @param position defines initial position
  41077. * @param interaxialDistance defines distance between each color axis
  41078. * @param scene defines the hosting scene
  41079. */
  41080. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41081. /**
  41082. * Gets camera class name
  41083. * @returns AnaglyphFreeCamera
  41084. */
  41085. getClassName(): string;
  41086. }
  41087. }
  41088. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41089. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41090. import { Scene } from "babylonjs/scene";
  41091. import { Vector3 } from "babylonjs/Maths/math.vector";
  41092. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41093. /**
  41094. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41095. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41096. */
  41097. export class AnaglyphGamepadCamera extends GamepadCamera {
  41098. /**
  41099. * Creates a new AnaglyphGamepadCamera
  41100. * @param name defines camera name
  41101. * @param position defines initial position
  41102. * @param interaxialDistance defines distance between each color axis
  41103. * @param scene defines the hosting scene
  41104. */
  41105. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41106. /**
  41107. * Gets camera class name
  41108. * @returns AnaglyphGamepadCamera
  41109. */
  41110. getClassName(): string;
  41111. }
  41112. }
  41113. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41114. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41115. import { Scene } from "babylonjs/scene";
  41116. import { Vector3 } from "babylonjs/Maths/math.vector";
  41117. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41118. /**
  41119. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41120. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41121. */
  41122. export class AnaglyphUniversalCamera extends UniversalCamera {
  41123. /**
  41124. * Creates a new AnaglyphUniversalCamera
  41125. * @param name defines camera name
  41126. * @param position defines initial position
  41127. * @param interaxialDistance defines distance between each color axis
  41128. * @param scene defines the hosting scene
  41129. */
  41130. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41131. /**
  41132. * Gets camera class name
  41133. * @returns AnaglyphUniversalCamera
  41134. */
  41135. getClassName(): string;
  41136. }
  41137. }
  41138. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41139. /** @hidden */
  41140. export var stereoscopicInterlacePixelShader: {
  41141. name: string;
  41142. shader: string;
  41143. };
  41144. }
  41145. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41146. import { Camera } from "babylonjs/Cameras/camera";
  41147. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41148. import { Engine } from "babylonjs/Engines/engine";
  41149. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41150. /**
  41151. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41152. */
  41153. export class StereoscopicInterlacePostProcess extends PostProcess {
  41154. private _stepSize;
  41155. private _passedProcess;
  41156. /**
  41157. * Initializes a StereoscopicInterlacePostProcess
  41158. * @param name The name of the effect.
  41159. * @param rigCameras The rig cameras to be appled to the post process
  41160. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41162. * @param engine The engine which the post process will be applied. (default: current engine)
  41163. * @param reusable If the post process can be reused on the same frame. (default: false)
  41164. */
  41165. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41166. }
  41167. }
  41168. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41169. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41170. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41171. import { Scene } from "babylonjs/scene";
  41172. import { Vector3 } from "babylonjs/Maths/math.vector";
  41173. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41174. /**
  41175. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41176. * @see http://doc.babylonjs.com/features/cameras
  41177. */
  41178. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41179. /**
  41180. * Creates a new StereoscopicArcRotateCamera
  41181. * @param name defines camera name
  41182. * @param alpha defines alpha angle (in radians)
  41183. * @param beta defines beta angle (in radians)
  41184. * @param radius defines radius
  41185. * @param target defines camera target
  41186. * @param interaxialDistance defines distance between each color axis
  41187. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41188. * @param scene defines the hosting scene
  41189. */
  41190. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41191. /**
  41192. * Gets camera class name
  41193. * @returns StereoscopicArcRotateCamera
  41194. */
  41195. getClassName(): string;
  41196. }
  41197. }
  41198. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41199. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41200. import { Scene } from "babylonjs/scene";
  41201. import { Vector3 } from "babylonjs/Maths/math.vector";
  41202. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41203. /**
  41204. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41205. * @see http://doc.babylonjs.com/features/cameras
  41206. */
  41207. export class StereoscopicFreeCamera extends FreeCamera {
  41208. /**
  41209. * Creates a new StereoscopicFreeCamera
  41210. * @param name defines camera name
  41211. * @param position defines initial position
  41212. * @param interaxialDistance defines distance between each color axis
  41213. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41214. * @param scene defines the hosting scene
  41215. */
  41216. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41217. /**
  41218. * Gets camera class name
  41219. * @returns StereoscopicFreeCamera
  41220. */
  41221. getClassName(): string;
  41222. }
  41223. }
  41224. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41225. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41226. import { Scene } from "babylonjs/scene";
  41227. import { Vector3 } from "babylonjs/Maths/math.vector";
  41228. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41229. /**
  41230. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41231. * @see http://doc.babylonjs.com/features/cameras
  41232. */
  41233. export class StereoscopicGamepadCamera extends GamepadCamera {
  41234. /**
  41235. * Creates a new StereoscopicGamepadCamera
  41236. * @param name defines camera name
  41237. * @param position defines initial position
  41238. * @param interaxialDistance defines distance between each color axis
  41239. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41240. * @param scene defines the hosting scene
  41241. */
  41242. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41243. /**
  41244. * Gets camera class name
  41245. * @returns StereoscopicGamepadCamera
  41246. */
  41247. getClassName(): string;
  41248. }
  41249. }
  41250. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41251. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41252. import { Scene } from "babylonjs/scene";
  41253. import { Vector3 } from "babylonjs/Maths/math.vector";
  41254. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41255. /**
  41256. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41257. * @see http://doc.babylonjs.com/features/cameras
  41258. */
  41259. export class StereoscopicUniversalCamera extends UniversalCamera {
  41260. /**
  41261. * Creates a new StereoscopicUniversalCamera
  41262. * @param name defines camera name
  41263. * @param position defines initial position
  41264. * @param interaxialDistance defines distance between each color axis
  41265. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41266. * @param scene defines the hosting scene
  41267. */
  41268. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41269. /**
  41270. * Gets camera class name
  41271. * @returns StereoscopicUniversalCamera
  41272. */
  41273. getClassName(): string;
  41274. }
  41275. }
  41276. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41277. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41278. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41279. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41280. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41281. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41282. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41283. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41284. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41285. }
  41286. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41287. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41288. import { Scene } from "babylonjs/scene";
  41289. import { Vector3 } from "babylonjs/Maths/math.vector";
  41290. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41291. /**
  41292. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41293. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41294. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41295. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41296. */
  41297. export class VirtualJoysticksCamera extends FreeCamera {
  41298. /**
  41299. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41300. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41301. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41302. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41303. * @param name Define the name of the camera in the scene
  41304. * @param position Define the start position of the camera in the scene
  41305. * @param scene Define the scene the camera belongs to
  41306. */
  41307. constructor(name: string, position: Vector3, scene: Scene);
  41308. /**
  41309. * Gets the current object class name.
  41310. * @return the class name
  41311. */
  41312. getClassName(): string;
  41313. }
  41314. }
  41315. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41316. import { Matrix } from "babylonjs/Maths/math.vector";
  41317. /**
  41318. * This represents all the required metrics to create a VR camera.
  41319. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41320. */
  41321. export class VRCameraMetrics {
  41322. /**
  41323. * Define the horizontal resolution off the screen.
  41324. */
  41325. hResolution: number;
  41326. /**
  41327. * Define the vertical resolution off the screen.
  41328. */
  41329. vResolution: number;
  41330. /**
  41331. * Define the horizontal screen size.
  41332. */
  41333. hScreenSize: number;
  41334. /**
  41335. * Define the vertical screen size.
  41336. */
  41337. vScreenSize: number;
  41338. /**
  41339. * Define the vertical screen center position.
  41340. */
  41341. vScreenCenter: number;
  41342. /**
  41343. * Define the distance of the eyes to the screen.
  41344. */
  41345. eyeToScreenDistance: number;
  41346. /**
  41347. * Define the distance between both lenses
  41348. */
  41349. lensSeparationDistance: number;
  41350. /**
  41351. * Define the distance between both viewer's eyes.
  41352. */
  41353. interpupillaryDistance: number;
  41354. /**
  41355. * Define the distortion factor of the VR postprocess.
  41356. * Please, touch with care.
  41357. */
  41358. distortionK: number[];
  41359. /**
  41360. * Define the chromatic aberration correction factors for the VR post process.
  41361. */
  41362. chromaAbCorrection: number[];
  41363. /**
  41364. * Define the scale factor of the post process.
  41365. * The smaller the better but the slower.
  41366. */
  41367. postProcessScaleFactor: number;
  41368. /**
  41369. * Define an offset for the lens center.
  41370. */
  41371. lensCenterOffset: number;
  41372. /**
  41373. * Define if the current vr camera should compensate the distortion of the lense or not.
  41374. */
  41375. compensateDistortion: boolean;
  41376. /**
  41377. * Defines if multiview should be enabled when rendering (Default: false)
  41378. */
  41379. multiviewEnabled: boolean;
  41380. /**
  41381. * Gets the rendering aspect ratio based on the provided resolutions.
  41382. */
  41383. readonly aspectRatio: number;
  41384. /**
  41385. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41386. */
  41387. readonly aspectRatioFov: number;
  41388. /**
  41389. * @hidden
  41390. */
  41391. readonly leftHMatrix: Matrix;
  41392. /**
  41393. * @hidden
  41394. */
  41395. readonly rightHMatrix: Matrix;
  41396. /**
  41397. * @hidden
  41398. */
  41399. readonly leftPreViewMatrix: Matrix;
  41400. /**
  41401. * @hidden
  41402. */
  41403. readonly rightPreViewMatrix: Matrix;
  41404. /**
  41405. * Get the default VRMetrics based on the most generic setup.
  41406. * @returns the default vr metrics
  41407. */
  41408. static GetDefault(): VRCameraMetrics;
  41409. }
  41410. }
  41411. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41412. /** @hidden */
  41413. export var vrDistortionCorrectionPixelShader: {
  41414. name: string;
  41415. shader: string;
  41416. };
  41417. }
  41418. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41419. import { Camera } from "babylonjs/Cameras/camera";
  41420. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41421. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41422. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41423. /**
  41424. * VRDistortionCorrectionPostProcess used for mobile VR
  41425. */
  41426. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41427. private _isRightEye;
  41428. private _distortionFactors;
  41429. private _postProcessScaleFactor;
  41430. private _lensCenterOffset;
  41431. private _scaleIn;
  41432. private _scaleFactor;
  41433. private _lensCenter;
  41434. /**
  41435. * Initializes the VRDistortionCorrectionPostProcess
  41436. * @param name The name of the effect.
  41437. * @param camera The camera to apply the render pass to.
  41438. * @param isRightEye If this is for the right eye distortion
  41439. * @param vrMetrics All the required metrics for the VR camera
  41440. */
  41441. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41442. }
  41443. }
  41444. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41445. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41446. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41447. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41448. import { Scene } from "babylonjs/scene";
  41449. import { Vector3 } from "babylonjs/Maths/math.vector";
  41450. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41451. import "babylonjs/Cameras/RigModes/vrRigMode";
  41452. /**
  41453. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41454. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41455. */
  41456. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41457. /**
  41458. * Creates a new VRDeviceOrientationArcRotateCamera
  41459. * @param name defines camera name
  41460. * @param alpha defines the camera rotation along the logitudinal axis
  41461. * @param beta defines the camera rotation along the latitudinal axis
  41462. * @param radius defines the camera distance from its target
  41463. * @param target defines the camera target
  41464. * @param scene defines the scene the camera belongs to
  41465. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41466. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41467. */
  41468. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41469. /**
  41470. * Gets camera class name
  41471. * @returns VRDeviceOrientationArcRotateCamera
  41472. */
  41473. getClassName(): string;
  41474. }
  41475. }
  41476. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41477. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41478. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41479. import { Scene } from "babylonjs/scene";
  41480. import { Vector3 } from "babylonjs/Maths/math.vector";
  41481. import "babylonjs/Cameras/RigModes/vrRigMode";
  41482. /**
  41483. * Camera used to simulate VR rendering (based on FreeCamera)
  41484. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41485. */
  41486. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41487. /**
  41488. * Creates a new VRDeviceOrientationFreeCamera
  41489. * @param name defines camera name
  41490. * @param position defines the start position of the camera
  41491. * @param scene defines the scene the camera belongs to
  41492. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41493. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41494. */
  41495. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41496. /**
  41497. * Gets camera class name
  41498. * @returns VRDeviceOrientationFreeCamera
  41499. */
  41500. getClassName(): string;
  41501. }
  41502. }
  41503. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41504. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41505. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41506. import { Scene } from "babylonjs/scene";
  41507. import { Vector3 } from "babylonjs/Maths/math.vector";
  41508. import "babylonjs/Gamepads/gamepadSceneComponent";
  41509. /**
  41510. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41511. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41512. */
  41513. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41514. /**
  41515. * Creates a new VRDeviceOrientationGamepadCamera
  41516. * @param name defines camera name
  41517. * @param position defines the start position of the camera
  41518. * @param scene defines the scene the camera belongs to
  41519. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41520. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41521. */
  41522. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41523. /**
  41524. * Gets camera class name
  41525. * @returns VRDeviceOrientationGamepadCamera
  41526. */
  41527. getClassName(): string;
  41528. }
  41529. }
  41530. declare module "babylonjs/Materials/pushMaterial" {
  41531. import { Nullable } from "babylonjs/types";
  41532. import { Scene } from "babylonjs/scene";
  41533. import { Matrix } from "babylonjs/Maths/math.vector";
  41534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41535. import { Mesh } from "babylonjs/Meshes/mesh";
  41536. import { Material } from "babylonjs/Materials/material";
  41537. import { Effect } from "babylonjs/Materials/effect";
  41538. /**
  41539. * Base class of materials working in push mode in babylon JS
  41540. * @hidden
  41541. */
  41542. export class PushMaterial extends Material {
  41543. protected _activeEffect: Effect;
  41544. protected _normalMatrix: Matrix;
  41545. /**
  41546. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41547. * This means that the material can keep using a previous shader while a new one is being compiled.
  41548. * This is mostly used when shader parallel compilation is supported (true by default)
  41549. */
  41550. allowShaderHotSwapping: boolean;
  41551. constructor(name: string, scene: Scene);
  41552. getEffect(): Effect;
  41553. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41554. /**
  41555. * Binds the given world matrix to the active effect
  41556. *
  41557. * @param world the matrix to bind
  41558. */
  41559. bindOnlyWorldMatrix(world: Matrix): void;
  41560. /**
  41561. * Binds the given normal matrix to the active effect
  41562. *
  41563. * @param normalMatrix the matrix to bind
  41564. */
  41565. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41566. bind(world: Matrix, mesh?: Mesh): void;
  41567. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41568. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41569. }
  41570. }
  41571. declare module "babylonjs/Materials/materialFlags" {
  41572. /**
  41573. * This groups all the flags used to control the materials channel.
  41574. */
  41575. export class MaterialFlags {
  41576. private static _DiffuseTextureEnabled;
  41577. /**
  41578. * Are diffuse textures enabled in the application.
  41579. */
  41580. static DiffuseTextureEnabled: boolean;
  41581. private static _AmbientTextureEnabled;
  41582. /**
  41583. * Are ambient textures enabled in the application.
  41584. */
  41585. static AmbientTextureEnabled: boolean;
  41586. private static _OpacityTextureEnabled;
  41587. /**
  41588. * Are opacity textures enabled in the application.
  41589. */
  41590. static OpacityTextureEnabled: boolean;
  41591. private static _ReflectionTextureEnabled;
  41592. /**
  41593. * Are reflection textures enabled in the application.
  41594. */
  41595. static ReflectionTextureEnabled: boolean;
  41596. private static _EmissiveTextureEnabled;
  41597. /**
  41598. * Are emissive textures enabled in the application.
  41599. */
  41600. static EmissiveTextureEnabled: boolean;
  41601. private static _SpecularTextureEnabled;
  41602. /**
  41603. * Are specular textures enabled in the application.
  41604. */
  41605. static SpecularTextureEnabled: boolean;
  41606. private static _BumpTextureEnabled;
  41607. /**
  41608. * Are bump textures enabled in the application.
  41609. */
  41610. static BumpTextureEnabled: boolean;
  41611. private static _LightmapTextureEnabled;
  41612. /**
  41613. * Are lightmap textures enabled in the application.
  41614. */
  41615. static LightmapTextureEnabled: boolean;
  41616. private static _RefractionTextureEnabled;
  41617. /**
  41618. * Are refraction textures enabled in the application.
  41619. */
  41620. static RefractionTextureEnabled: boolean;
  41621. private static _ColorGradingTextureEnabled;
  41622. /**
  41623. * Are color grading textures enabled in the application.
  41624. */
  41625. static ColorGradingTextureEnabled: boolean;
  41626. private static _FresnelEnabled;
  41627. /**
  41628. * Are fresnels enabled in the application.
  41629. */
  41630. static FresnelEnabled: boolean;
  41631. private static _ClearCoatTextureEnabled;
  41632. /**
  41633. * Are clear coat textures enabled in the application.
  41634. */
  41635. static ClearCoatTextureEnabled: boolean;
  41636. private static _ClearCoatBumpTextureEnabled;
  41637. /**
  41638. * Are clear coat bump textures enabled in the application.
  41639. */
  41640. static ClearCoatBumpTextureEnabled: boolean;
  41641. private static _ClearCoatTintTextureEnabled;
  41642. /**
  41643. * Are clear coat tint textures enabled in the application.
  41644. */
  41645. static ClearCoatTintTextureEnabled: boolean;
  41646. private static _SheenTextureEnabled;
  41647. /**
  41648. * Are sheen textures enabled in the application.
  41649. */
  41650. static SheenTextureEnabled: boolean;
  41651. private static _AnisotropicTextureEnabled;
  41652. /**
  41653. * Are anisotropic textures enabled in the application.
  41654. */
  41655. static AnisotropicTextureEnabled: boolean;
  41656. private static _ThicknessTextureEnabled;
  41657. /**
  41658. * Are thickness textures enabled in the application.
  41659. */
  41660. static ThicknessTextureEnabled: boolean;
  41661. }
  41662. }
  41663. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41664. /** @hidden */
  41665. export var defaultFragmentDeclaration: {
  41666. name: string;
  41667. shader: string;
  41668. };
  41669. }
  41670. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41671. /** @hidden */
  41672. export var defaultUboDeclaration: {
  41673. name: string;
  41674. shader: string;
  41675. };
  41676. }
  41677. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41678. /** @hidden */
  41679. export var lightFragmentDeclaration: {
  41680. name: string;
  41681. shader: string;
  41682. };
  41683. }
  41684. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41685. /** @hidden */
  41686. export var lightUboDeclaration: {
  41687. name: string;
  41688. shader: string;
  41689. };
  41690. }
  41691. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41692. /** @hidden */
  41693. export var lightsFragmentFunctions: {
  41694. name: string;
  41695. shader: string;
  41696. };
  41697. }
  41698. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41699. /** @hidden */
  41700. export var shadowsFragmentFunctions: {
  41701. name: string;
  41702. shader: string;
  41703. };
  41704. }
  41705. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41706. /** @hidden */
  41707. export var fresnelFunction: {
  41708. name: string;
  41709. shader: string;
  41710. };
  41711. }
  41712. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41713. /** @hidden */
  41714. export var reflectionFunction: {
  41715. name: string;
  41716. shader: string;
  41717. };
  41718. }
  41719. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41720. /** @hidden */
  41721. export var bumpFragmentFunctions: {
  41722. name: string;
  41723. shader: string;
  41724. };
  41725. }
  41726. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41727. /** @hidden */
  41728. export var logDepthDeclaration: {
  41729. name: string;
  41730. shader: string;
  41731. };
  41732. }
  41733. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41734. /** @hidden */
  41735. export var bumpFragment: {
  41736. name: string;
  41737. shader: string;
  41738. };
  41739. }
  41740. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41741. /** @hidden */
  41742. export var depthPrePass: {
  41743. name: string;
  41744. shader: string;
  41745. };
  41746. }
  41747. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41748. /** @hidden */
  41749. export var lightFragment: {
  41750. name: string;
  41751. shader: string;
  41752. };
  41753. }
  41754. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41755. /** @hidden */
  41756. export var logDepthFragment: {
  41757. name: string;
  41758. shader: string;
  41759. };
  41760. }
  41761. declare module "babylonjs/Shaders/default.fragment" {
  41762. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41763. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41764. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41765. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41766. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41767. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41768. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41769. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41770. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41771. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41772. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41773. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41774. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41775. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41776. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41778. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41779. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41780. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41781. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41782. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41783. /** @hidden */
  41784. export var defaultPixelShader: {
  41785. name: string;
  41786. shader: string;
  41787. };
  41788. }
  41789. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41790. /** @hidden */
  41791. export var defaultVertexDeclaration: {
  41792. name: string;
  41793. shader: string;
  41794. };
  41795. }
  41796. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41797. /** @hidden */
  41798. export var bumpVertexDeclaration: {
  41799. name: string;
  41800. shader: string;
  41801. };
  41802. }
  41803. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41804. /** @hidden */
  41805. export var bumpVertex: {
  41806. name: string;
  41807. shader: string;
  41808. };
  41809. }
  41810. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41811. /** @hidden */
  41812. export var fogVertex: {
  41813. name: string;
  41814. shader: string;
  41815. };
  41816. }
  41817. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41818. /** @hidden */
  41819. export var shadowsVertex: {
  41820. name: string;
  41821. shader: string;
  41822. };
  41823. }
  41824. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41825. /** @hidden */
  41826. export var pointCloudVertex: {
  41827. name: string;
  41828. shader: string;
  41829. };
  41830. }
  41831. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41832. /** @hidden */
  41833. export var logDepthVertex: {
  41834. name: string;
  41835. shader: string;
  41836. };
  41837. }
  41838. declare module "babylonjs/Shaders/default.vertex" {
  41839. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41840. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41841. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41842. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41843. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41844. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41845. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41846. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41847. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41848. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41849. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41850. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41851. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41852. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41853. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41854. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41855. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41856. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41857. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41858. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41859. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41860. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41861. /** @hidden */
  41862. export var defaultVertexShader: {
  41863. name: string;
  41864. shader: string;
  41865. };
  41866. }
  41867. declare module "babylonjs/Materials/standardMaterial" {
  41868. import { SmartArray } from "babylonjs/Misc/smartArray";
  41869. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41870. import { Nullable } from "babylonjs/types";
  41871. import { Scene } from "babylonjs/scene";
  41872. import { Matrix } from "babylonjs/Maths/math.vector";
  41873. import { Color3 } from "babylonjs/Maths/math.color";
  41874. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41876. import { Mesh } from "babylonjs/Meshes/mesh";
  41877. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41878. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41879. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41880. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41881. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41882. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41883. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41884. import "babylonjs/Shaders/default.fragment";
  41885. import "babylonjs/Shaders/default.vertex";
  41886. /** @hidden */
  41887. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41888. MAINUV1: boolean;
  41889. MAINUV2: boolean;
  41890. DIFFUSE: boolean;
  41891. DIFFUSEDIRECTUV: number;
  41892. AMBIENT: boolean;
  41893. AMBIENTDIRECTUV: number;
  41894. OPACITY: boolean;
  41895. OPACITYDIRECTUV: number;
  41896. OPACITYRGB: boolean;
  41897. REFLECTION: boolean;
  41898. EMISSIVE: boolean;
  41899. EMISSIVEDIRECTUV: number;
  41900. SPECULAR: boolean;
  41901. SPECULARDIRECTUV: number;
  41902. BUMP: boolean;
  41903. BUMPDIRECTUV: number;
  41904. PARALLAX: boolean;
  41905. PARALLAXOCCLUSION: boolean;
  41906. SPECULAROVERALPHA: boolean;
  41907. CLIPPLANE: boolean;
  41908. CLIPPLANE2: boolean;
  41909. CLIPPLANE3: boolean;
  41910. CLIPPLANE4: boolean;
  41911. ALPHATEST: boolean;
  41912. DEPTHPREPASS: boolean;
  41913. ALPHAFROMDIFFUSE: boolean;
  41914. POINTSIZE: boolean;
  41915. FOG: boolean;
  41916. SPECULARTERM: boolean;
  41917. DIFFUSEFRESNEL: boolean;
  41918. OPACITYFRESNEL: boolean;
  41919. REFLECTIONFRESNEL: boolean;
  41920. REFRACTIONFRESNEL: boolean;
  41921. EMISSIVEFRESNEL: boolean;
  41922. FRESNEL: boolean;
  41923. NORMAL: boolean;
  41924. UV1: boolean;
  41925. UV2: boolean;
  41926. VERTEXCOLOR: boolean;
  41927. VERTEXALPHA: boolean;
  41928. NUM_BONE_INFLUENCERS: number;
  41929. BonesPerMesh: number;
  41930. BONETEXTURE: boolean;
  41931. INSTANCES: boolean;
  41932. GLOSSINESS: boolean;
  41933. ROUGHNESS: boolean;
  41934. EMISSIVEASILLUMINATION: boolean;
  41935. LINKEMISSIVEWITHDIFFUSE: boolean;
  41936. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41937. LIGHTMAP: boolean;
  41938. LIGHTMAPDIRECTUV: number;
  41939. OBJECTSPACE_NORMALMAP: boolean;
  41940. USELIGHTMAPASSHADOWMAP: boolean;
  41941. REFLECTIONMAP_3D: boolean;
  41942. REFLECTIONMAP_SPHERICAL: boolean;
  41943. REFLECTIONMAP_PLANAR: boolean;
  41944. REFLECTIONMAP_CUBIC: boolean;
  41945. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41946. REFLECTIONMAP_PROJECTION: boolean;
  41947. REFLECTIONMAP_SKYBOX: boolean;
  41948. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41949. REFLECTIONMAP_EXPLICIT: boolean;
  41950. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41951. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41952. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41953. INVERTCUBICMAP: boolean;
  41954. LOGARITHMICDEPTH: boolean;
  41955. REFRACTION: boolean;
  41956. REFRACTIONMAP_3D: boolean;
  41957. REFLECTIONOVERALPHA: boolean;
  41958. TWOSIDEDLIGHTING: boolean;
  41959. SHADOWFLOAT: boolean;
  41960. MORPHTARGETS: boolean;
  41961. MORPHTARGETS_NORMAL: boolean;
  41962. MORPHTARGETS_TANGENT: boolean;
  41963. MORPHTARGETS_UV: boolean;
  41964. NUM_MORPH_INFLUENCERS: number;
  41965. NONUNIFORMSCALING: boolean;
  41966. PREMULTIPLYALPHA: boolean;
  41967. IMAGEPROCESSING: boolean;
  41968. VIGNETTE: boolean;
  41969. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41970. VIGNETTEBLENDMODEOPAQUE: boolean;
  41971. TONEMAPPING: boolean;
  41972. TONEMAPPING_ACES: boolean;
  41973. CONTRAST: boolean;
  41974. COLORCURVES: boolean;
  41975. COLORGRADING: boolean;
  41976. COLORGRADING3D: boolean;
  41977. SAMPLER3DGREENDEPTH: boolean;
  41978. SAMPLER3DBGRMAP: boolean;
  41979. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41980. MULTIVIEW: boolean;
  41981. /**
  41982. * If the reflection texture on this material is in linear color space
  41983. * @hidden
  41984. */
  41985. IS_REFLECTION_LINEAR: boolean;
  41986. /**
  41987. * If the refraction texture on this material is in linear color space
  41988. * @hidden
  41989. */
  41990. IS_REFRACTION_LINEAR: boolean;
  41991. EXPOSURE: boolean;
  41992. constructor();
  41993. setReflectionMode(modeToEnable: string): void;
  41994. }
  41995. /**
  41996. * This is the default material used in Babylon. It is the best trade off between quality
  41997. * and performances.
  41998. * @see http://doc.babylonjs.com/babylon101/materials
  41999. */
  42000. export class StandardMaterial extends PushMaterial {
  42001. private _diffuseTexture;
  42002. /**
  42003. * The basic texture of the material as viewed under a light.
  42004. */
  42005. diffuseTexture: Nullable<BaseTexture>;
  42006. private _ambientTexture;
  42007. /**
  42008. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42009. */
  42010. ambientTexture: Nullable<BaseTexture>;
  42011. private _opacityTexture;
  42012. /**
  42013. * Define the transparency of the material from a texture.
  42014. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42015. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42016. */
  42017. opacityTexture: Nullable<BaseTexture>;
  42018. private _reflectionTexture;
  42019. /**
  42020. * Define the texture used to display the reflection.
  42021. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42022. */
  42023. reflectionTexture: Nullable<BaseTexture>;
  42024. private _emissiveTexture;
  42025. /**
  42026. * Define texture of the material as if self lit.
  42027. * This will be mixed in the final result even in the absence of light.
  42028. */
  42029. emissiveTexture: Nullable<BaseTexture>;
  42030. private _specularTexture;
  42031. /**
  42032. * Define how the color and intensity of the highlight given by the light in the material.
  42033. */
  42034. specularTexture: Nullable<BaseTexture>;
  42035. private _bumpTexture;
  42036. /**
  42037. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42038. * 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.
  42039. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42040. */
  42041. bumpTexture: Nullable<BaseTexture>;
  42042. private _lightmapTexture;
  42043. /**
  42044. * Complex lighting can be computationally expensive to compute at runtime.
  42045. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42046. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42047. */
  42048. lightmapTexture: Nullable<BaseTexture>;
  42049. private _refractionTexture;
  42050. /**
  42051. * Define the texture used to display the refraction.
  42052. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42053. */
  42054. refractionTexture: Nullable<BaseTexture>;
  42055. /**
  42056. * The color of the material lit by the environmental background lighting.
  42057. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42058. */
  42059. ambientColor: Color3;
  42060. /**
  42061. * The basic color of the material as viewed under a light.
  42062. */
  42063. diffuseColor: Color3;
  42064. /**
  42065. * Define how the color and intensity of the highlight given by the light in the material.
  42066. */
  42067. specularColor: Color3;
  42068. /**
  42069. * Define the color of the material as if self lit.
  42070. * This will be mixed in the final result even in the absence of light.
  42071. */
  42072. emissiveColor: Color3;
  42073. /**
  42074. * Defines how sharp are the highlights in the material.
  42075. * The bigger the value the sharper giving a more glossy feeling to the result.
  42076. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42077. */
  42078. specularPower: number;
  42079. private _useAlphaFromDiffuseTexture;
  42080. /**
  42081. * Does the transparency come from the diffuse texture alpha channel.
  42082. */
  42083. useAlphaFromDiffuseTexture: boolean;
  42084. private _useEmissiveAsIllumination;
  42085. /**
  42086. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42087. */
  42088. useEmissiveAsIllumination: boolean;
  42089. private _linkEmissiveWithDiffuse;
  42090. /**
  42091. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42092. * the emissive level when the final color is close to one.
  42093. */
  42094. linkEmissiveWithDiffuse: boolean;
  42095. private _useSpecularOverAlpha;
  42096. /**
  42097. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42098. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42099. */
  42100. useSpecularOverAlpha: boolean;
  42101. private _useReflectionOverAlpha;
  42102. /**
  42103. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42104. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42105. */
  42106. useReflectionOverAlpha: boolean;
  42107. private _disableLighting;
  42108. /**
  42109. * Does lights from the scene impacts this material.
  42110. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42111. */
  42112. disableLighting: boolean;
  42113. private _useObjectSpaceNormalMap;
  42114. /**
  42115. * Allows using an object space normal map (instead of tangent space).
  42116. */
  42117. useObjectSpaceNormalMap: boolean;
  42118. private _useParallax;
  42119. /**
  42120. * Is parallax enabled or not.
  42121. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42122. */
  42123. useParallax: boolean;
  42124. private _useParallaxOcclusion;
  42125. /**
  42126. * Is parallax occlusion enabled or not.
  42127. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42128. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42129. */
  42130. useParallaxOcclusion: boolean;
  42131. /**
  42132. * 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.
  42133. */
  42134. parallaxScaleBias: number;
  42135. private _roughness;
  42136. /**
  42137. * Helps to define how blurry the reflections should appears in the material.
  42138. */
  42139. roughness: number;
  42140. /**
  42141. * In case of refraction, define the value of the index of refraction.
  42142. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42143. */
  42144. indexOfRefraction: number;
  42145. /**
  42146. * Invert the refraction texture alongside the y axis.
  42147. * It can be useful with procedural textures or probe for instance.
  42148. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42149. */
  42150. invertRefractionY: boolean;
  42151. /**
  42152. * Defines the alpha limits in alpha test mode.
  42153. */
  42154. alphaCutOff: number;
  42155. private _useLightmapAsShadowmap;
  42156. /**
  42157. * In case of light mapping, define whether the map contains light or shadow informations.
  42158. */
  42159. useLightmapAsShadowmap: boolean;
  42160. private _diffuseFresnelParameters;
  42161. /**
  42162. * Define the diffuse fresnel parameters of the material.
  42163. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42164. */
  42165. diffuseFresnelParameters: FresnelParameters;
  42166. private _opacityFresnelParameters;
  42167. /**
  42168. * Define the opacity fresnel parameters of the material.
  42169. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42170. */
  42171. opacityFresnelParameters: FresnelParameters;
  42172. private _reflectionFresnelParameters;
  42173. /**
  42174. * Define the reflection fresnel parameters of the material.
  42175. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42176. */
  42177. reflectionFresnelParameters: FresnelParameters;
  42178. private _refractionFresnelParameters;
  42179. /**
  42180. * Define the refraction fresnel parameters of the material.
  42181. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42182. */
  42183. refractionFresnelParameters: FresnelParameters;
  42184. private _emissiveFresnelParameters;
  42185. /**
  42186. * Define the emissive fresnel parameters of the material.
  42187. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42188. */
  42189. emissiveFresnelParameters: FresnelParameters;
  42190. private _useReflectionFresnelFromSpecular;
  42191. /**
  42192. * If true automatically deducts the fresnels values from the material specularity.
  42193. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42194. */
  42195. useReflectionFresnelFromSpecular: boolean;
  42196. private _useGlossinessFromSpecularMapAlpha;
  42197. /**
  42198. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42199. */
  42200. useGlossinessFromSpecularMapAlpha: boolean;
  42201. private _maxSimultaneousLights;
  42202. /**
  42203. * Defines the maximum number of lights that can be used in the material
  42204. */
  42205. maxSimultaneousLights: number;
  42206. private _invertNormalMapX;
  42207. /**
  42208. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42209. */
  42210. invertNormalMapX: boolean;
  42211. private _invertNormalMapY;
  42212. /**
  42213. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42214. */
  42215. invertNormalMapY: boolean;
  42216. private _twoSidedLighting;
  42217. /**
  42218. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42219. */
  42220. twoSidedLighting: boolean;
  42221. /**
  42222. * Default configuration related to image processing available in the standard Material.
  42223. */
  42224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42225. /**
  42226. * Gets the image processing configuration used either in this material.
  42227. */
  42228. /**
  42229. * Sets the Default image processing configuration used either in the this material.
  42230. *
  42231. * If sets to null, the scene one is in use.
  42232. */
  42233. imageProcessingConfiguration: ImageProcessingConfiguration;
  42234. /**
  42235. * Keep track of the image processing observer to allow dispose and replace.
  42236. */
  42237. private _imageProcessingObserver;
  42238. /**
  42239. * Attaches a new image processing configuration to the Standard Material.
  42240. * @param configuration
  42241. */
  42242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42243. /**
  42244. * Gets wether the color curves effect is enabled.
  42245. */
  42246. /**
  42247. * Sets wether the color curves effect is enabled.
  42248. */
  42249. cameraColorCurvesEnabled: boolean;
  42250. /**
  42251. * Gets wether the color grading effect is enabled.
  42252. */
  42253. /**
  42254. * Gets wether the color grading effect is enabled.
  42255. */
  42256. cameraColorGradingEnabled: boolean;
  42257. /**
  42258. * Gets wether tonemapping is enabled or not.
  42259. */
  42260. /**
  42261. * Sets wether tonemapping is enabled or not
  42262. */
  42263. cameraToneMappingEnabled: boolean;
  42264. /**
  42265. * The camera exposure used on this material.
  42266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42267. * This corresponds to a photographic exposure.
  42268. */
  42269. /**
  42270. * The camera exposure used on this material.
  42271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42272. * This corresponds to a photographic exposure.
  42273. */
  42274. cameraExposure: number;
  42275. /**
  42276. * Gets The camera contrast used on this material.
  42277. */
  42278. /**
  42279. * Sets The camera contrast used on this material.
  42280. */
  42281. cameraContrast: number;
  42282. /**
  42283. * Gets the Color Grading 2D Lookup Texture.
  42284. */
  42285. /**
  42286. * Sets the Color Grading 2D Lookup Texture.
  42287. */
  42288. cameraColorGradingTexture: Nullable<BaseTexture>;
  42289. /**
  42290. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42291. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42292. * 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;
  42293. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42294. */
  42295. /**
  42296. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42297. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42298. * 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;
  42299. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42300. */
  42301. cameraColorCurves: Nullable<ColorCurves>;
  42302. /**
  42303. * Custom callback helping to override the default shader used in the material.
  42304. */
  42305. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42306. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42307. protected _worldViewProjectionMatrix: Matrix;
  42308. protected _globalAmbientColor: Color3;
  42309. protected _useLogarithmicDepth: boolean;
  42310. protected _rebuildInParallel: boolean;
  42311. /**
  42312. * Instantiates a new standard material.
  42313. * This is the default material used in Babylon. It is the best trade off between quality
  42314. * and performances.
  42315. * @see http://doc.babylonjs.com/babylon101/materials
  42316. * @param name Define the name of the material in the scene
  42317. * @param scene Define the scene the material belong to
  42318. */
  42319. constructor(name: string, scene: Scene);
  42320. /**
  42321. * Gets a boolean indicating that current material needs to register RTT
  42322. */
  42323. readonly hasRenderTargetTextures: boolean;
  42324. /**
  42325. * Gets the current class name of the material e.g. "StandardMaterial"
  42326. * Mainly use in serialization.
  42327. * @returns the class name
  42328. */
  42329. getClassName(): string;
  42330. /**
  42331. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42332. * You can try switching to logarithmic depth.
  42333. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42334. */
  42335. useLogarithmicDepth: boolean;
  42336. /**
  42337. * Specifies if the material will require alpha blending
  42338. * @returns a boolean specifying if alpha blending is needed
  42339. */
  42340. needAlphaBlending(): boolean;
  42341. /**
  42342. * Specifies if this material should be rendered in alpha test mode
  42343. * @returns a boolean specifying if an alpha test is needed.
  42344. */
  42345. needAlphaTesting(): boolean;
  42346. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42347. /**
  42348. * Get the texture used for alpha test purpose.
  42349. * @returns the diffuse texture in case of the standard material.
  42350. */
  42351. getAlphaTestTexture(): Nullable<BaseTexture>;
  42352. /**
  42353. * Get if the submesh is ready to be used and all its information available.
  42354. * Child classes can use it to update shaders
  42355. * @param mesh defines the mesh to check
  42356. * @param subMesh defines which submesh to check
  42357. * @param useInstances specifies that instances should be used
  42358. * @returns a boolean indicating that the submesh is ready or not
  42359. */
  42360. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42361. /**
  42362. * Builds the material UBO layouts.
  42363. * Used internally during the effect preparation.
  42364. */
  42365. buildUniformLayout(): void;
  42366. /**
  42367. * Unbinds the material from the mesh
  42368. */
  42369. unbind(): void;
  42370. /**
  42371. * Binds the submesh to this material by preparing the effect and shader to draw
  42372. * @param world defines the world transformation matrix
  42373. * @param mesh defines the mesh containing the submesh
  42374. * @param subMesh defines the submesh to bind the material to
  42375. */
  42376. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42377. /**
  42378. * Get the list of animatables in the material.
  42379. * @returns the list of animatables object used in the material
  42380. */
  42381. getAnimatables(): IAnimatable[];
  42382. /**
  42383. * Gets the active textures from the material
  42384. * @returns an array of textures
  42385. */
  42386. getActiveTextures(): BaseTexture[];
  42387. /**
  42388. * Specifies if the material uses a texture
  42389. * @param texture defines the texture to check against the material
  42390. * @returns a boolean specifying if the material uses the texture
  42391. */
  42392. hasTexture(texture: BaseTexture): boolean;
  42393. /**
  42394. * Disposes the material
  42395. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42396. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42397. */
  42398. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42399. /**
  42400. * Makes a duplicate of the material, and gives it a new name
  42401. * @param name defines the new name for the duplicated material
  42402. * @returns the cloned material
  42403. */
  42404. clone(name: string): StandardMaterial;
  42405. /**
  42406. * Serializes this material in a JSON representation
  42407. * @returns the serialized material object
  42408. */
  42409. serialize(): any;
  42410. /**
  42411. * Creates a standard material from parsed material data
  42412. * @param source defines the JSON representation of the material
  42413. * @param scene defines the hosting scene
  42414. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42415. * @returns a new standard material
  42416. */
  42417. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42418. /**
  42419. * Are diffuse textures enabled in the application.
  42420. */
  42421. static DiffuseTextureEnabled: boolean;
  42422. /**
  42423. * Are ambient textures enabled in the application.
  42424. */
  42425. static AmbientTextureEnabled: boolean;
  42426. /**
  42427. * Are opacity textures enabled in the application.
  42428. */
  42429. static OpacityTextureEnabled: boolean;
  42430. /**
  42431. * Are reflection textures enabled in the application.
  42432. */
  42433. static ReflectionTextureEnabled: boolean;
  42434. /**
  42435. * Are emissive textures enabled in the application.
  42436. */
  42437. static EmissiveTextureEnabled: boolean;
  42438. /**
  42439. * Are specular textures enabled in the application.
  42440. */
  42441. static SpecularTextureEnabled: boolean;
  42442. /**
  42443. * Are bump textures enabled in the application.
  42444. */
  42445. static BumpTextureEnabled: boolean;
  42446. /**
  42447. * Are lightmap textures enabled in the application.
  42448. */
  42449. static LightmapTextureEnabled: boolean;
  42450. /**
  42451. * Are refraction textures enabled in the application.
  42452. */
  42453. static RefractionTextureEnabled: boolean;
  42454. /**
  42455. * Are color grading textures enabled in the application.
  42456. */
  42457. static ColorGradingTextureEnabled: boolean;
  42458. /**
  42459. * Are fresnels enabled in the application.
  42460. */
  42461. static FresnelEnabled: boolean;
  42462. }
  42463. }
  42464. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42465. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42466. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42467. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42468. /** @hidden */
  42469. export var imageProcessingPixelShader: {
  42470. name: string;
  42471. shader: string;
  42472. };
  42473. }
  42474. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42475. import { Nullable } from "babylonjs/types";
  42476. import { Color4 } from "babylonjs/Maths/math.color";
  42477. import { Camera } from "babylonjs/Cameras/camera";
  42478. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42479. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42480. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42482. import { Engine } from "babylonjs/Engines/engine";
  42483. import "babylonjs/Shaders/imageProcessing.fragment";
  42484. import "babylonjs/Shaders/postprocess.vertex";
  42485. /**
  42486. * ImageProcessingPostProcess
  42487. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42488. */
  42489. export class ImageProcessingPostProcess extends PostProcess {
  42490. /**
  42491. * Default configuration related to image processing available in the PBR Material.
  42492. */
  42493. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42494. /**
  42495. * Gets the image processing configuration used either in this material.
  42496. */
  42497. /**
  42498. * Sets the Default image processing configuration used either in the this material.
  42499. *
  42500. * If sets to null, the scene one is in use.
  42501. */
  42502. imageProcessingConfiguration: ImageProcessingConfiguration;
  42503. /**
  42504. * Keep track of the image processing observer to allow dispose and replace.
  42505. */
  42506. private _imageProcessingObserver;
  42507. /**
  42508. * Attaches a new image processing configuration to the PBR Material.
  42509. * @param configuration
  42510. */
  42511. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42512. /**
  42513. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42514. */
  42515. /**
  42516. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42517. */
  42518. colorCurves: Nullable<ColorCurves>;
  42519. /**
  42520. * Gets wether the color curves effect is enabled.
  42521. */
  42522. /**
  42523. * Sets wether the color curves effect is enabled.
  42524. */
  42525. colorCurvesEnabled: boolean;
  42526. /**
  42527. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42528. */
  42529. /**
  42530. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42531. */
  42532. colorGradingTexture: Nullable<BaseTexture>;
  42533. /**
  42534. * Gets wether the color grading effect is enabled.
  42535. */
  42536. /**
  42537. * Gets wether the color grading effect is enabled.
  42538. */
  42539. colorGradingEnabled: boolean;
  42540. /**
  42541. * Gets exposure used in the effect.
  42542. */
  42543. /**
  42544. * Sets exposure used in the effect.
  42545. */
  42546. exposure: number;
  42547. /**
  42548. * Gets wether tonemapping is enabled or not.
  42549. */
  42550. /**
  42551. * Sets wether tonemapping is enabled or not
  42552. */
  42553. toneMappingEnabled: boolean;
  42554. /**
  42555. * Gets the type of tone mapping effect.
  42556. */
  42557. /**
  42558. * Sets the type of tone mapping effect.
  42559. */
  42560. toneMappingType: number;
  42561. /**
  42562. * Gets contrast used in the effect.
  42563. */
  42564. /**
  42565. * Sets contrast used in the effect.
  42566. */
  42567. contrast: number;
  42568. /**
  42569. * Gets Vignette stretch size.
  42570. */
  42571. /**
  42572. * Sets Vignette stretch size.
  42573. */
  42574. vignetteStretch: number;
  42575. /**
  42576. * Gets Vignette centre X Offset.
  42577. */
  42578. /**
  42579. * Sets Vignette centre X Offset.
  42580. */
  42581. vignetteCentreX: number;
  42582. /**
  42583. * Gets Vignette centre Y Offset.
  42584. */
  42585. /**
  42586. * Sets Vignette centre Y Offset.
  42587. */
  42588. vignetteCentreY: number;
  42589. /**
  42590. * Gets Vignette weight or intensity of the vignette effect.
  42591. */
  42592. /**
  42593. * Sets Vignette weight or intensity of the vignette effect.
  42594. */
  42595. vignetteWeight: number;
  42596. /**
  42597. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42598. * if vignetteEnabled is set to true.
  42599. */
  42600. /**
  42601. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42602. * if vignetteEnabled is set to true.
  42603. */
  42604. vignetteColor: Color4;
  42605. /**
  42606. * Gets Camera field of view used by the Vignette effect.
  42607. */
  42608. /**
  42609. * Sets Camera field of view used by the Vignette effect.
  42610. */
  42611. vignetteCameraFov: number;
  42612. /**
  42613. * Gets the vignette blend mode allowing different kind of effect.
  42614. */
  42615. /**
  42616. * Sets the vignette blend mode allowing different kind of effect.
  42617. */
  42618. vignetteBlendMode: number;
  42619. /**
  42620. * Gets wether the vignette effect is enabled.
  42621. */
  42622. /**
  42623. * Sets wether the vignette effect is enabled.
  42624. */
  42625. vignetteEnabled: boolean;
  42626. private _fromLinearSpace;
  42627. /**
  42628. * Gets wether the input of the processing is in Gamma or Linear Space.
  42629. */
  42630. /**
  42631. * Sets wether the input of the processing is in Gamma or Linear Space.
  42632. */
  42633. fromLinearSpace: boolean;
  42634. /**
  42635. * Defines cache preventing GC.
  42636. */
  42637. private _defines;
  42638. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42639. /**
  42640. * "ImageProcessingPostProcess"
  42641. * @returns "ImageProcessingPostProcess"
  42642. */
  42643. getClassName(): string;
  42644. protected _updateParameters(): void;
  42645. dispose(camera?: Camera): void;
  42646. }
  42647. }
  42648. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42649. import { Scene } from "babylonjs/scene";
  42650. import { Color3 } from "babylonjs/Maths/math.color";
  42651. import { Mesh } from "babylonjs/Meshes/mesh";
  42652. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42653. import { Nullable } from "babylonjs/types";
  42654. /**
  42655. * Class containing static functions to help procedurally build meshes
  42656. */
  42657. export class GroundBuilder {
  42658. /**
  42659. * Creates a ground mesh
  42660. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42661. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42663. * @param name defines the name of the mesh
  42664. * @param options defines the options used to create the mesh
  42665. * @param scene defines the hosting scene
  42666. * @returns the ground mesh
  42667. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42668. */
  42669. static CreateGround(name: string, options: {
  42670. width?: number;
  42671. height?: number;
  42672. subdivisions?: number;
  42673. subdivisionsX?: number;
  42674. subdivisionsY?: number;
  42675. updatable?: boolean;
  42676. }, scene: any): Mesh;
  42677. /**
  42678. * Creates a tiled ground mesh
  42679. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42680. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42681. * * 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
  42682. * * 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
  42683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42684. * @param name defines the name of the mesh
  42685. * @param options defines the options used to create the mesh
  42686. * @param scene defines the hosting scene
  42687. * @returns the tiled ground mesh
  42688. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42689. */
  42690. static CreateTiledGround(name: string, options: {
  42691. xmin: number;
  42692. zmin: number;
  42693. xmax: number;
  42694. zmax: number;
  42695. subdivisions?: {
  42696. w: number;
  42697. h: number;
  42698. };
  42699. precision?: {
  42700. w: number;
  42701. h: number;
  42702. };
  42703. updatable?: boolean;
  42704. }, scene?: Nullable<Scene>): Mesh;
  42705. /**
  42706. * Creates a ground mesh from a height map
  42707. * * The parameter `url` sets the URL of the height map image resource.
  42708. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42709. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42710. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42711. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42712. * * 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.
  42713. * * 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).
  42714. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42716. * @param name defines the name of the mesh
  42717. * @param url defines the url to the height map
  42718. * @param options defines the options used to create the mesh
  42719. * @param scene defines the hosting scene
  42720. * @returns the ground mesh
  42721. * @see https://doc.babylonjs.com/babylon101/height_map
  42722. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42723. */
  42724. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42725. width?: number;
  42726. height?: number;
  42727. subdivisions?: number;
  42728. minHeight?: number;
  42729. maxHeight?: number;
  42730. colorFilter?: Color3;
  42731. alphaFilter?: number;
  42732. updatable?: boolean;
  42733. onReady?: (mesh: GroundMesh) => void;
  42734. }, scene?: Nullable<Scene>): GroundMesh;
  42735. }
  42736. }
  42737. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42738. import { Vector4 } from "babylonjs/Maths/math.vector";
  42739. import { Mesh } from "babylonjs/Meshes/mesh";
  42740. /**
  42741. * Class containing static functions to help procedurally build meshes
  42742. */
  42743. export class TorusBuilder {
  42744. /**
  42745. * Creates a torus mesh
  42746. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42747. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42748. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42752. * @param name defines the name of the mesh
  42753. * @param options defines the options used to create the mesh
  42754. * @param scene defines the hosting scene
  42755. * @returns the torus mesh
  42756. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42757. */
  42758. static CreateTorus(name: string, options: {
  42759. diameter?: number;
  42760. thickness?: number;
  42761. tessellation?: number;
  42762. updatable?: boolean;
  42763. sideOrientation?: number;
  42764. frontUVs?: Vector4;
  42765. backUVs?: Vector4;
  42766. }, scene: any): Mesh;
  42767. }
  42768. }
  42769. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42770. import { Vector4 } from "babylonjs/Maths/math.vector";
  42771. import { Color4 } from "babylonjs/Maths/math.color";
  42772. import { Mesh } from "babylonjs/Meshes/mesh";
  42773. /**
  42774. * Class containing static functions to help procedurally build meshes
  42775. */
  42776. export class CylinderBuilder {
  42777. /**
  42778. * Creates a cylinder or a cone mesh
  42779. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42780. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42781. * * 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.
  42782. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42783. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42784. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42785. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42786. * * 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).
  42787. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42788. * * 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).
  42789. * * 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
  42790. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42791. * * 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
  42792. * * 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.
  42793. * * If `enclose` is false, a ring surface is one element.
  42794. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42795. * * 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
  42796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42799. * @param name defines the name of the mesh
  42800. * @param options defines the options used to create the mesh
  42801. * @param scene defines the hosting scene
  42802. * @returns the cylinder mesh
  42803. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42804. */
  42805. static CreateCylinder(name: string, options: {
  42806. height?: number;
  42807. diameterTop?: number;
  42808. diameterBottom?: number;
  42809. diameter?: number;
  42810. tessellation?: number;
  42811. subdivisions?: number;
  42812. arc?: number;
  42813. faceColors?: Color4[];
  42814. faceUV?: Vector4[];
  42815. updatable?: boolean;
  42816. hasRings?: boolean;
  42817. enclose?: boolean;
  42818. cap?: number;
  42819. sideOrientation?: number;
  42820. frontUVs?: Vector4;
  42821. backUVs?: Vector4;
  42822. }, scene: any): Mesh;
  42823. }
  42824. }
  42825. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42826. import { Observable } from "babylonjs/Misc/observable";
  42827. import { Nullable } from "babylonjs/types";
  42828. import { Camera } from "babylonjs/Cameras/camera";
  42829. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42830. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42831. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42832. import { Scene } from "babylonjs/scene";
  42833. import { Vector3 } from "babylonjs/Maths/math.vector";
  42834. import { Color3 } from "babylonjs/Maths/math.color";
  42835. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42837. import { Mesh } from "babylonjs/Meshes/mesh";
  42838. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42839. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42840. import "babylonjs/Meshes/Builders/groundBuilder";
  42841. import "babylonjs/Meshes/Builders/torusBuilder";
  42842. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42843. import "babylonjs/Gamepads/gamepadSceneComponent";
  42844. import "babylonjs/Animations/animatable";
  42845. /**
  42846. * Options to modify the vr teleportation behavior.
  42847. */
  42848. export interface VRTeleportationOptions {
  42849. /**
  42850. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42851. */
  42852. floorMeshName?: string;
  42853. /**
  42854. * A list of meshes to be used as the teleportation floor. (default: empty)
  42855. */
  42856. floorMeshes?: Mesh[];
  42857. }
  42858. /**
  42859. * Options to modify the vr experience helper's behavior.
  42860. */
  42861. export interface VRExperienceHelperOptions extends WebVROptions {
  42862. /**
  42863. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42864. */
  42865. createDeviceOrientationCamera?: boolean;
  42866. /**
  42867. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42868. */
  42869. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42870. /**
  42871. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42872. */
  42873. laserToggle?: boolean;
  42874. /**
  42875. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42876. */
  42877. floorMeshes?: Mesh[];
  42878. /**
  42879. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42880. */
  42881. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42882. }
  42883. /**
  42884. * Event containing information after VR has been entered
  42885. */
  42886. export class OnAfterEnteringVRObservableEvent {
  42887. /**
  42888. * If entering vr was successful
  42889. */
  42890. success: boolean;
  42891. }
  42892. /**
  42893. * Helps to quickly add VR support to an existing scene.
  42894. * See http://doc.babylonjs.com/how_to/webvr_helper
  42895. */
  42896. export class VRExperienceHelper {
  42897. /** Options to modify the vr experience helper's behavior. */
  42898. webVROptions: VRExperienceHelperOptions;
  42899. private _scene;
  42900. private _position;
  42901. private _btnVR;
  42902. private _btnVRDisplayed;
  42903. private _webVRsupported;
  42904. private _webVRready;
  42905. private _webVRrequesting;
  42906. private _webVRpresenting;
  42907. private _hasEnteredVR;
  42908. private _fullscreenVRpresenting;
  42909. private _inputElement;
  42910. private _webVRCamera;
  42911. private _vrDeviceOrientationCamera;
  42912. private _deviceOrientationCamera;
  42913. private _existingCamera;
  42914. private _onKeyDown;
  42915. private _onVrDisplayPresentChange;
  42916. private _onVRDisplayChanged;
  42917. private _onVRRequestPresentStart;
  42918. private _onVRRequestPresentComplete;
  42919. /**
  42920. * 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)
  42921. */
  42922. enableGazeEvenWhenNoPointerLock: boolean;
  42923. /**
  42924. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42925. */
  42926. exitVROnDoubleTap: boolean;
  42927. /**
  42928. * Observable raised right before entering VR.
  42929. */
  42930. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42931. /**
  42932. * Observable raised when entering VR has completed.
  42933. */
  42934. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42935. /**
  42936. * Observable raised when exiting VR.
  42937. */
  42938. onExitingVRObservable: Observable<VRExperienceHelper>;
  42939. /**
  42940. * Observable raised when controller mesh is loaded.
  42941. */
  42942. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42943. /** Return this.onEnteringVRObservable
  42944. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42945. */
  42946. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42947. /** Return this.onExitingVRObservable
  42948. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42949. */
  42950. readonly onExitingVR: Observable<VRExperienceHelper>;
  42951. /** Return this.onControllerMeshLoadedObservable
  42952. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42953. */
  42954. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42955. private _rayLength;
  42956. private _useCustomVRButton;
  42957. private _teleportationRequested;
  42958. private _teleportActive;
  42959. private _floorMeshName;
  42960. private _floorMeshesCollection;
  42961. private _rotationAllowed;
  42962. private _teleportBackwardsVector;
  42963. private _teleportationTarget;
  42964. private _isDefaultTeleportationTarget;
  42965. private _postProcessMove;
  42966. private _teleportationFillColor;
  42967. private _teleportationBorderColor;
  42968. private _rotationAngle;
  42969. private _haloCenter;
  42970. private _cameraGazer;
  42971. private _padSensibilityUp;
  42972. private _padSensibilityDown;
  42973. private _leftController;
  42974. private _rightController;
  42975. /**
  42976. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42977. */
  42978. onNewMeshSelected: Observable<AbstractMesh>;
  42979. /**
  42980. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42981. * This observable will provide the mesh and the controller used to select the mesh
  42982. */
  42983. onMeshSelectedWithController: Observable<{
  42984. mesh: AbstractMesh;
  42985. controller: WebVRController;
  42986. }>;
  42987. /**
  42988. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42989. */
  42990. onNewMeshPicked: Observable<PickingInfo>;
  42991. private _circleEase;
  42992. /**
  42993. * Observable raised before camera teleportation
  42994. */
  42995. onBeforeCameraTeleport: Observable<Vector3>;
  42996. /**
  42997. * Observable raised after camera teleportation
  42998. */
  42999. onAfterCameraTeleport: Observable<Vector3>;
  43000. /**
  43001. * Observable raised when current selected mesh gets unselected
  43002. */
  43003. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43004. private _raySelectionPredicate;
  43005. /**
  43006. * To be optionaly changed by user to define custom ray selection
  43007. */
  43008. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43009. /**
  43010. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43011. */
  43012. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43013. /**
  43014. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43015. */
  43016. teleportationEnabled: boolean;
  43017. private _defaultHeight;
  43018. private _teleportationInitialized;
  43019. private _interactionsEnabled;
  43020. private _interactionsRequested;
  43021. private _displayGaze;
  43022. private _displayLaserPointer;
  43023. /**
  43024. * The mesh used to display where the user is going to teleport.
  43025. */
  43026. /**
  43027. * Sets the mesh to be used to display where the user is going to teleport.
  43028. */
  43029. teleportationTarget: Mesh;
  43030. /**
  43031. * 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
  43032. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43033. * See http://doc.babylonjs.com/resources/baking_transformations
  43034. */
  43035. gazeTrackerMesh: Mesh;
  43036. /**
  43037. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43038. */
  43039. updateGazeTrackerScale: boolean;
  43040. /**
  43041. * If the gaze trackers color should be updated when selecting meshes
  43042. */
  43043. updateGazeTrackerColor: boolean;
  43044. /**
  43045. * If the controller laser color should be updated when selecting meshes
  43046. */
  43047. updateControllerLaserColor: boolean;
  43048. /**
  43049. * The gaze tracking mesh corresponding to the left controller
  43050. */
  43051. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43052. /**
  43053. * The gaze tracking mesh corresponding to the right controller
  43054. */
  43055. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43056. /**
  43057. * If the ray of the gaze should be displayed.
  43058. */
  43059. /**
  43060. * Sets if the ray of the gaze should be displayed.
  43061. */
  43062. displayGaze: boolean;
  43063. /**
  43064. * If the ray of the LaserPointer should be displayed.
  43065. */
  43066. /**
  43067. * Sets if the ray of the LaserPointer should be displayed.
  43068. */
  43069. displayLaserPointer: boolean;
  43070. /**
  43071. * The deviceOrientationCamera used as the camera when not in VR.
  43072. */
  43073. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43074. /**
  43075. * Based on the current WebVR support, returns the current VR camera used.
  43076. */
  43077. readonly currentVRCamera: Nullable<Camera>;
  43078. /**
  43079. * The webVRCamera which is used when in VR.
  43080. */
  43081. readonly webVRCamera: WebVRFreeCamera;
  43082. /**
  43083. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43084. */
  43085. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43086. /**
  43087. * The html button that is used to trigger entering into VR.
  43088. */
  43089. readonly vrButton: Nullable<HTMLButtonElement>;
  43090. private readonly _teleportationRequestInitiated;
  43091. /**
  43092. * Defines wether or not Pointer lock should be requested when switching to
  43093. * full screen.
  43094. */
  43095. requestPointerLockOnFullScreen: boolean;
  43096. /**
  43097. * Instantiates a VRExperienceHelper.
  43098. * Helps to quickly add VR support to an existing scene.
  43099. * @param scene The scene the VRExperienceHelper belongs to.
  43100. * @param webVROptions Options to modify the vr experience helper's behavior.
  43101. */
  43102. constructor(scene: Scene,
  43103. /** Options to modify the vr experience helper's behavior. */
  43104. webVROptions?: VRExperienceHelperOptions);
  43105. private _onDefaultMeshLoaded;
  43106. private _onResize;
  43107. private _onFullscreenChange;
  43108. /**
  43109. * Gets a value indicating if we are currently in VR mode.
  43110. */
  43111. readonly isInVRMode: boolean;
  43112. private onVrDisplayPresentChange;
  43113. private onVRDisplayChanged;
  43114. private moveButtonToBottomRight;
  43115. private displayVRButton;
  43116. private updateButtonVisibility;
  43117. private _cachedAngularSensibility;
  43118. /**
  43119. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43120. * Otherwise, will use the fullscreen API.
  43121. */
  43122. enterVR(): void;
  43123. /**
  43124. * Attempt to exit VR, or fullscreen.
  43125. */
  43126. exitVR(): void;
  43127. /**
  43128. * The position of the vr experience helper.
  43129. */
  43130. /**
  43131. * Sets the position of the vr experience helper.
  43132. */
  43133. position: Vector3;
  43134. /**
  43135. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43136. */
  43137. enableInteractions(): void;
  43138. private readonly _noControllerIsActive;
  43139. private beforeRender;
  43140. private _isTeleportationFloor;
  43141. /**
  43142. * Adds a floor mesh to be used for teleportation.
  43143. * @param floorMesh the mesh to be used for teleportation.
  43144. */
  43145. addFloorMesh(floorMesh: Mesh): void;
  43146. /**
  43147. * Removes a floor mesh from being used for teleportation.
  43148. * @param floorMesh the mesh to be removed.
  43149. */
  43150. removeFloorMesh(floorMesh: Mesh): void;
  43151. /**
  43152. * Enables interactions and teleportation using the VR controllers and gaze.
  43153. * @param vrTeleportationOptions options to modify teleportation behavior.
  43154. */
  43155. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43156. private _onNewGamepadConnected;
  43157. private _tryEnableInteractionOnController;
  43158. private _onNewGamepadDisconnected;
  43159. private _enableInteractionOnController;
  43160. private _checkTeleportWithRay;
  43161. private _checkRotate;
  43162. private _checkTeleportBackwards;
  43163. private _enableTeleportationOnController;
  43164. private _createTeleportationCircles;
  43165. private _displayTeleportationTarget;
  43166. private _hideTeleportationTarget;
  43167. private _rotateCamera;
  43168. private _moveTeleportationSelectorTo;
  43169. private _workingVector;
  43170. private _workingQuaternion;
  43171. private _workingMatrix;
  43172. /**
  43173. * Teleports the users feet to the desired location
  43174. * @param location The location where the user's feet should be placed
  43175. */
  43176. teleportCamera(location: Vector3): void;
  43177. private _convertNormalToDirectionOfRay;
  43178. private _castRayAndSelectObject;
  43179. private _notifySelectedMeshUnselected;
  43180. /**
  43181. * Sets the color of the laser ray from the vr controllers.
  43182. * @param color new color for the ray.
  43183. */
  43184. changeLaserColor(color: Color3): void;
  43185. /**
  43186. * Sets the color of the ray from the vr headsets gaze.
  43187. * @param color new color for the ray.
  43188. */
  43189. changeGazeColor(color: Color3): void;
  43190. /**
  43191. * Exits VR and disposes of the vr experience helper
  43192. */
  43193. dispose(): void;
  43194. /**
  43195. * Gets the name of the VRExperienceHelper class
  43196. * @returns "VRExperienceHelper"
  43197. */
  43198. getClassName(): string;
  43199. }
  43200. }
  43201. declare module "babylonjs/Cameras/VR/index" {
  43202. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43203. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43204. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43205. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43206. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43207. export * from "babylonjs/Cameras/VR/webVRCamera";
  43208. }
  43209. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43210. import { Nullable } from "babylonjs/types";
  43211. import { IDisposable } from "babylonjs/scene";
  43212. /**
  43213. * States of the webXR experience
  43214. */
  43215. export enum WebXRState {
  43216. /**
  43217. * Transitioning to being in XR mode
  43218. */
  43219. ENTERING_XR = 0,
  43220. /**
  43221. * Transitioning to non XR mode
  43222. */
  43223. EXITING_XR = 1,
  43224. /**
  43225. * In XR mode and presenting
  43226. */
  43227. IN_XR = 2,
  43228. /**
  43229. * Not entered XR mode
  43230. */
  43231. NOT_IN_XR = 3
  43232. }
  43233. /**
  43234. * Abstraction of the XR render target
  43235. */
  43236. export interface WebXRRenderTarget extends IDisposable {
  43237. /**
  43238. * xrpresent context of the canvas which can be used to display/mirror xr content
  43239. */
  43240. canvasContext: WebGLRenderingContext;
  43241. /**
  43242. * xr layer for the canvas
  43243. */
  43244. xrLayer: Nullable<XRWebGLLayer>;
  43245. /**
  43246. * Initializes the xr layer for the session
  43247. * @param xrSession xr session
  43248. * @returns a promise that will resolve once the XR Layer has been created
  43249. */
  43250. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43251. }
  43252. }
  43253. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43254. import { Nullable } from "babylonjs/types";
  43255. import { Observable } from "babylonjs/Misc/observable";
  43256. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43257. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43258. /**
  43259. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43260. */
  43261. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43262. private _engine;
  43263. private _canvas;
  43264. /**
  43265. * xrpresent context of the canvas which can be used to display/mirror xr content
  43266. */
  43267. canvasContext: WebGLRenderingContext;
  43268. /**
  43269. * xr layer for the canvas
  43270. */
  43271. xrLayer: Nullable<XRWebGLLayer>;
  43272. /**
  43273. * Initializes the xr layer for the session
  43274. * @param xrSession xr session
  43275. * @returns a promise that will resolve once the XR Layer has been created
  43276. */
  43277. initializeXRLayerAsync(xrSession: any): any;
  43278. /**
  43279. * Initializes the canvas to be added/removed upon entering/exiting xr
  43280. * @param engine the Babylon engine
  43281. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43282. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43283. */
  43284. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  43285. /**
  43286. * Disposes of the object
  43287. */
  43288. dispose(): void;
  43289. private _setManagedOutputCanvas;
  43290. private _addCanvas;
  43291. private _removeCanvas;
  43292. }
  43293. }
  43294. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43295. import { Observable } from "babylonjs/Misc/observable";
  43296. import { Nullable } from "babylonjs/types";
  43297. import { IDisposable, Scene } from "babylonjs/scene";
  43298. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43299. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43300. /**
  43301. * Manages an XRSession to work with Babylon's engine
  43302. * @see https://doc.babylonjs.com/how_to/webxr
  43303. */
  43304. export class WebXRSessionManager implements IDisposable {
  43305. private scene;
  43306. /**
  43307. * Fires every time a new xrFrame arrives which can be used to update the camera
  43308. */
  43309. onXRFrameObservable: Observable<any>;
  43310. /**
  43311. * Fires when the xr session is ended either by the device or manually done
  43312. */
  43313. onXRSessionEnded: Observable<any>;
  43314. /**
  43315. * Underlying xr session
  43316. */
  43317. session: XRSession;
  43318. /**
  43319. * Type of reference space used when creating the session
  43320. */
  43321. referenceSpace: XRReferenceSpace;
  43322. /**
  43323. * Current XR frame
  43324. */
  43325. currentFrame: Nullable<XRFrame>;
  43326. private _xrNavigator;
  43327. private baseLayer;
  43328. private _rttProvider;
  43329. private _sessionEnded;
  43330. /**
  43331. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43332. * @param scene The scene which the session should be created for
  43333. */
  43334. constructor(scene: Scene);
  43335. /**
  43336. * Initializes the manager
  43337. * After initialization enterXR can be called to start an XR session
  43338. * @returns Promise which resolves after it is initialized
  43339. */
  43340. initializeAsync(): Promise<void>;
  43341. /**
  43342. * Initializes an xr session
  43343. * @param xrSessionMode mode to initialize
  43344. * @param optionalFeatures defines optional values to pass to the session builder
  43345. * @returns a promise which will resolve once the session has been initialized
  43346. */
  43347. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43348. /**
  43349. * Sets the reference space on the xr session
  43350. * @param referenceSpace space to set
  43351. * @returns a promise that will resolve once the reference space has been set
  43352. */
  43353. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43354. /**
  43355. * Updates the render state of the session
  43356. * @param state state to set
  43357. * @returns a promise that resolves once the render state has been updated
  43358. */
  43359. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43360. /**
  43361. * Starts rendering to the xr layer
  43362. * @returns a promise that will resolve once rendering has started
  43363. */
  43364. startRenderingToXRAsync(): Promise<void>;
  43365. /**
  43366. * Gets the correct render target texture to be rendered this frame for this eye
  43367. * @param eye the eye for which to get the render target
  43368. * @returns the render target for the specified eye
  43369. */
  43370. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43371. /**
  43372. * Stops the xrSession and restores the renderloop
  43373. * @returns Promise which resolves after it exits XR
  43374. */
  43375. exitXRAsync(): Promise<void>;
  43376. /**
  43377. * Checks if a session would be supported for the creation options specified
  43378. * @param sessionMode session mode to check if supported eg. immersive-vr
  43379. * @returns true if supported
  43380. */
  43381. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43382. /**
  43383. * Creates a WebXRRenderTarget object for the XR session
  43384. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43385. * @returns a WebXR render target to which the session can render
  43386. */
  43387. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  43388. /**
  43389. * @hidden
  43390. * Converts the render layer of xrSession to a render target
  43391. * @param session session to create render target for
  43392. * @param scene scene the new render target should be created for
  43393. */
  43394. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43395. /**
  43396. * Disposes of the session manager
  43397. */
  43398. dispose(): void;
  43399. }
  43400. }
  43401. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43402. import { Scene } from "babylonjs/scene";
  43403. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43404. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43405. /**
  43406. * WebXR Camera which holds the views for the xrSession
  43407. * @see https://doc.babylonjs.com/how_to/webxr
  43408. */
  43409. export class WebXRCamera extends FreeCamera {
  43410. private static _TmpMatrix;
  43411. /**
  43412. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43413. * @param name the name of the camera
  43414. * @param scene the scene to add the camera to
  43415. */
  43416. constructor(name: string, scene: Scene);
  43417. private _updateNumberOfRigCameras;
  43418. /** @hidden */
  43419. _updateForDualEyeDebugging(): void;
  43420. /**
  43421. * Updates the cameras position from the current pose information of the XR session
  43422. * @param xrSessionManager the session containing pose information
  43423. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43424. */
  43425. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43426. }
  43427. }
  43428. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43429. import { Observable } from "babylonjs/Misc/observable";
  43430. import { IDisposable, Scene } from "babylonjs/scene";
  43431. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43433. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43434. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43435. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43436. /**
  43437. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43438. * @see https://doc.babylonjs.com/how_to/webxr
  43439. */
  43440. export class WebXRExperienceHelper implements IDisposable {
  43441. private scene;
  43442. /**
  43443. * 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
  43444. */
  43445. container: AbstractMesh;
  43446. /**
  43447. * Camera used to render xr content
  43448. */
  43449. camera: WebXRCamera;
  43450. /**
  43451. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43452. */
  43453. state: WebXRState;
  43454. private _setState;
  43455. private static _TmpVector;
  43456. /**
  43457. * Fires when the state of the experience helper has changed
  43458. */
  43459. onStateChangedObservable: Observable<WebXRState>;
  43460. /** Session manager used to keep track of xr session */
  43461. sessionManager: WebXRSessionManager;
  43462. private _nonVRCamera;
  43463. private _originalSceneAutoClear;
  43464. private _supported;
  43465. /**
  43466. * Creates the experience helper
  43467. * @param scene the scene to attach the experience helper to
  43468. * @returns a promise for the experience helper
  43469. */
  43470. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43471. /**
  43472. * Creates a WebXRExperienceHelper
  43473. * @param scene The scene the helper should be created in
  43474. */
  43475. private constructor();
  43476. /**
  43477. * Exits XR mode and returns the scene to its original state
  43478. * @returns promise that resolves after xr mode has exited
  43479. */
  43480. exitXRAsync(): Promise<void>;
  43481. /**
  43482. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43483. * @param sessionMode options for the XR session
  43484. * @param referenceSpaceType frame of reference of the XR session
  43485. * @param renderTarget the output canvas that will be used to enter XR mode
  43486. * @returns promise that resolves after xr mode has entered
  43487. */
  43488. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43489. /**
  43490. * Updates the global position of the camera by moving the camera's container
  43491. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43492. * @param position The desired global position of the camera
  43493. */
  43494. setPositionOfCameraUsingContainer(position: Vector3): void;
  43495. /**
  43496. * Rotates the xr camera by rotating the camera's container around the camera's position
  43497. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43498. * @param rotation the desired quaternion rotation to apply to the camera
  43499. */
  43500. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43501. /**
  43502. * Disposes of the experience helper
  43503. */
  43504. dispose(): void;
  43505. }
  43506. }
  43507. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43508. import { Nullable } from "babylonjs/types";
  43509. import { Observable } from "babylonjs/Misc/observable";
  43510. import { IDisposable, Scene } from "babylonjs/scene";
  43511. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43512. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43513. /**
  43514. * Button which can be used to enter a different mode of XR
  43515. */
  43516. export class WebXREnterExitUIButton {
  43517. /** button element */
  43518. element: HTMLElement;
  43519. /** XR initialization options for the button */
  43520. sessionMode: XRSessionMode;
  43521. /** Reference space type */
  43522. referenceSpaceType: XRReferenceSpaceType;
  43523. /**
  43524. * Creates a WebXREnterExitUIButton
  43525. * @param element button element
  43526. * @param sessionMode XR initialization session mode
  43527. * @param referenceSpaceType the type of reference space to be used
  43528. */
  43529. constructor(
  43530. /** button element */
  43531. element: HTMLElement,
  43532. /** XR initialization options for the button */
  43533. sessionMode: XRSessionMode,
  43534. /** Reference space type */
  43535. referenceSpaceType: XRReferenceSpaceType);
  43536. /**
  43537. * Overwritable function which can be used to update the button's visuals when the state changes
  43538. * @param activeButton the current active button in the UI
  43539. */
  43540. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43541. }
  43542. /**
  43543. * Options to create the webXR UI
  43544. */
  43545. export class WebXREnterExitUIOptions {
  43546. /**
  43547. * Context to enter xr with
  43548. */
  43549. renderTarget?: Nullable<WebXRRenderTarget>;
  43550. /**
  43551. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43552. */
  43553. customButtons?: Array<WebXREnterExitUIButton>;
  43554. }
  43555. /**
  43556. * UI to allow the user to enter/exit XR mode
  43557. */
  43558. export class WebXREnterExitUI implements IDisposable {
  43559. private scene;
  43560. private _overlay;
  43561. private _buttons;
  43562. private _activeButton;
  43563. /**
  43564. * Fired every time the active button is changed.
  43565. *
  43566. * When xr is entered via a button that launches xr that button will be the callback parameter
  43567. *
  43568. * When exiting xr the callback parameter will be null)
  43569. */
  43570. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43571. /**
  43572. * Creates UI to allow the user to enter/exit XR mode
  43573. * @param scene the scene to add the ui to
  43574. * @param helper the xr experience helper to enter/exit xr with
  43575. * @param options options to configure the UI
  43576. * @returns the created ui
  43577. */
  43578. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43579. private constructor();
  43580. private _updateButtons;
  43581. /**
  43582. * Disposes of the object
  43583. */
  43584. dispose(): void;
  43585. }
  43586. }
  43587. declare module "babylonjs/Cameras/XR/webXRController" {
  43588. import { Nullable } from "babylonjs/types";
  43589. import { Observable } from "babylonjs/Misc/observable";
  43590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43591. import { Ray } from "babylonjs/Culling/ray";
  43592. import { Scene } from "babylonjs/scene";
  43593. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43594. /**
  43595. * Represents an XR input
  43596. */
  43597. export class WebXRController {
  43598. private scene;
  43599. /** The underlying input source for the controller */
  43600. inputSource: XRInputSource;
  43601. private parentContainer;
  43602. /**
  43603. * 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
  43604. */
  43605. grip?: AbstractMesh;
  43606. /**
  43607. * Pointer which can be used to select objects or attach a visible laser to
  43608. */
  43609. pointer: AbstractMesh;
  43610. private _gamepadMode;
  43611. /**
  43612. * If available, this is the gamepad object related to this controller.
  43613. * Using this object it is possible to get click events and trackpad changes of the
  43614. * webxr controller that is currently being used.
  43615. */
  43616. gamepadController?: WebVRController;
  43617. /**
  43618. * Event that fires when the controller is removed/disposed
  43619. */
  43620. onDisposeObservable: Observable<{}>;
  43621. private _tmpMatrix;
  43622. private _tmpQuaternion;
  43623. private _tmpVector;
  43624. /**
  43625. * Creates the controller
  43626. * @see https://doc.babylonjs.com/how_to/webxr
  43627. * @param scene the scene which the controller should be associated to
  43628. * @param inputSource the underlying input source for the controller
  43629. * @param parentContainer parent that the controller meshes should be children of
  43630. */
  43631. constructor(scene: Scene,
  43632. /** The underlying input source for the controller */
  43633. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43634. /**
  43635. * Updates the controller pose based on the given XRFrame
  43636. * @param xrFrame xr frame to update the pose with
  43637. * @param referenceSpace reference space to use
  43638. */
  43639. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43640. /**
  43641. * Gets a world space ray coming from the controller
  43642. * @param result the resulting ray
  43643. */
  43644. getWorldPointerRayToRef(result: Ray): void;
  43645. /**
  43646. * Get the scene associated with this controller
  43647. * @returns the scene object
  43648. */
  43649. getScene(): Scene;
  43650. /**
  43651. * Disposes of the object
  43652. */
  43653. dispose(): void;
  43654. }
  43655. }
  43656. declare module "babylonjs/Cameras/XR/webXRInput" {
  43657. import { Observable } from "babylonjs/Misc/observable";
  43658. import { IDisposable } from "babylonjs/scene";
  43659. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43660. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43661. /**
  43662. * XR input used to track XR inputs such as controllers/rays
  43663. */
  43664. export class WebXRInput implements IDisposable {
  43665. /**
  43666. * Base experience the input listens to
  43667. */
  43668. baseExperience: WebXRExperienceHelper;
  43669. /**
  43670. * XR controllers being tracked
  43671. */
  43672. controllers: Array<WebXRController>;
  43673. private _frameObserver;
  43674. private _stateObserver;
  43675. /**
  43676. * Event when a controller has been connected/added
  43677. */
  43678. onControllerAddedObservable: Observable<WebXRController>;
  43679. /**
  43680. * Event when a controller has been removed/disconnected
  43681. */
  43682. onControllerRemovedObservable: Observable<WebXRController>;
  43683. /**
  43684. * Initializes the WebXRInput
  43685. * @param baseExperience experience helper which the input should be created for
  43686. */
  43687. constructor(
  43688. /**
  43689. * Base experience the input listens to
  43690. */
  43691. baseExperience: WebXRExperienceHelper);
  43692. private _onInputSourcesChange;
  43693. private _addAndRemoveControllers;
  43694. /**
  43695. * Disposes of the object
  43696. */
  43697. dispose(): void;
  43698. }
  43699. }
  43700. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43702. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43703. /**
  43704. * Enables teleportation
  43705. */
  43706. export class WebXRControllerTeleportation {
  43707. private _teleportationFillColor;
  43708. private _teleportationBorderColor;
  43709. private _tmpRay;
  43710. private _tmpVector;
  43711. /**
  43712. * Creates a WebXRControllerTeleportation
  43713. * @param input input manager to add teleportation to
  43714. * @param floorMeshes floormeshes which can be teleported to
  43715. */
  43716. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43717. }
  43718. }
  43719. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43720. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43721. /**
  43722. * Handles pointer input automatically for the pointer of XR controllers
  43723. */
  43724. export class WebXRControllerPointerSelection {
  43725. private static _idCounter;
  43726. private _tmpRay;
  43727. /**
  43728. * Creates a WebXRControllerPointerSelection
  43729. * @param input input manager to setup pointer selection
  43730. */
  43731. constructor(input: WebXRInput);
  43732. private _convertNormalToDirectionOfRay;
  43733. private _updatePointerDistance;
  43734. }
  43735. }
  43736. declare module "babylonjs/Loading/sceneLoader" {
  43737. import { Observable } from "babylonjs/Misc/observable";
  43738. import { Nullable } from "babylonjs/types";
  43739. import { Scene } from "babylonjs/scene";
  43740. import { Engine } from "babylonjs/Engines/engine";
  43741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43742. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43743. import { AssetContainer } from "babylonjs/assetContainer";
  43744. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43745. import { Skeleton } from "babylonjs/Bones/skeleton";
  43746. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43747. import { WebRequest } from "babylonjs/Misc/webRequest";
  43748. /**
  43749. * Class used to represent data loading progression
  43750. */
  43751. export class SceneLoaderProgressEvent {
  43752. /** defines if data length to load can be evaluated */
  43753. readonly lengthComputable: boolean;
  43754. /** defines the loaded data length */
  43755. readonly loaded: number;
  43756. /** defines the data length to load */
  43757. readonly total: number;
  43758. /**
  43759. * Create a new progress event
  43760. * @param lengthComputable defines if data length to load can be evaluated
  43761. * @param loaded defines the loaded data length
  43762. * @param total defines the data length to load
  43763. */
  43764. constructor(
  43765. /** defines if data length to load can be evaluated */
  43766. lengthComputable: boolean,
  43767. /** defines the loaded data length */
  43768. loaded: number,
  43769. /** defines the data length to load */
  43770. total: number);
  43771. /**
  43772. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43773. * @param event defines the source event
  43774. * @returns a new SceneLoaderProgressEvent
  43775. */
  43776. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43777. }
  43778. /**
  43779. * Interface used by SceneLoader plugins to define supported file extensions
  43780. */
  43781. export interface ISceneLoaderPluginExtensions {
  43782. /**
  43783. * Defines the list of supported extensions
  43784. */
  43785. [extension: string]: {
  43786. isBinary: boolean;
  43787. };
  43788. }
  43789. /**
  43790. * Interface used by SceneLoader plugin factory
  43791. */
  43792. export interface ISceneLoaderPluginFactory {
  43793. /**
  43794. * Defines the name of the factory
  43795. */
  43796. name: string;
  43797. /**
  43798. * Function called to create a new plugin
  43799. * @return the new plugin
  43800. */
  43801. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43802. /**
  43803. * The callback that returns true if the data can be directly loaded.
  43804. * @param data string containing the file data
  43805. * @returns if the data can be loaded directly
  43806. */
  43807. canDirectLoad?(data: string): boolean;
  43808. }
  43809. /**
  43810. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43811. */
  43812. export interface ISceneLoaderPluginBase {
  43813. /**
  43814. * The friendly name of this plugin.
  43815. */
  43816. name: string;
  43817. /**
  43818. * The file extensions supported by this plugin.
  43819. */
  43820. extensions: string | ISceneLoaderPluginExtensions;
  43821. /**
  43822. * The callback called when loading from a url.
  43823. * @param scene scene loading this url
  43824. * @param url url to load
  43825. * @param onSuccess callback called when the file successfully loads
  43826. * @param onProgress callback called while file is loading (if the server supports this mode)
  43827. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43828. * @param onError callback called when the file fails to load
  43829. * @returns a file request object
  43830. */
  43831. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43832. /**
  43833. * The callback called when loading from a file object.
  43834. * @param scene scene loading this file
  43835. * @param file defines the file to load
  43836. * @param onSuccess defines the callback to call when data is loaded
  43837. * @param onProgress defines the callback to call during loading process
  43838. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43839. * @param onError defines the callback to call when an error occurs
  43840. * @returns a file request object
  43841. */
  43842. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43843. /**
  43844. * The callback that returns true if the data can be directly loaded.
  43845. * @param data string containing the file data
  43846. * @returns if the data can be loaded directly
  43847. */
  43848. canDirectLoad?(data: string): boolean;
  43849. /**
  43850. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43851. * @param scene scene loading this data
  43852. * @param data string containing the data
  43853. * @returns data to pass to the plugin
  43854. */
  43855. directLoad?(scene: Scene, data: string): any;
  43856. /**
  43857. * The callback that allows custom handling of the root url based on the response url.
  43858. * @param rootUrl the original root url
  43859. * @param responseURL the response url if available
  43860. * @returns the new root url
  43861. */
  43862. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43863. }
  43864. /**
  43865. * Interface used to define a SceneLoader plugin
  43866. */
  43867. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43868. /**
  43869. * Import meshes into a scene.
  43870. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43871. * @param scene The scene to import into
  43872. * @param data The data to import
  43873. * @param rootUrl The root url for scene and resources
  43874. * @param meshes The meshes array to import into
  43875. * @param particleSystems The particle systems array to import into
  43876. * @param skeletons The skeletons array to import into
  43877. * @param onError The callback when import fails
  43878. * @returns True if successful or false otherwise
  43879. */
  43880. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43881. /**
  43882. * Load into a scene.
  43883. * @param scene The scene to load into
  43884. * @param data The data to import
  43885. * @param rootUrl The root url for scene and resources
  43886. * @param onError The callback when import fails
  43887. * @returns True if successful or false otherwise
  43888. */
  43889. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43890. /**
  43891. * Load into an asset container.
  43892. * @param scene The scene to load into
  43893. * @param data The data to import
  43894. * @param rootUrl The root url for scene and resources
  43895. * @param onError The callback when import fails
  43896. * @returns The loaded asset container
  43897. */
  43898. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43899. }
  43900. /**
  43901. * Interface used to define an async SceneLoader plugin
  43902. */
  43903. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43904. /**
  43905. * Import meshes into a scene.
  43906. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43907. * @param scene The scene to import into
  43908. * @param data The data to import
  43909. * @param rootUrl The root url for scene and resources
  43910. * @param onProgress The callback when the load progresses
  43911. * @param fileName Defines the name of the file to load
  43912. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43913. */
  43914. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43915. meshes: AbstractMesh[];
  43916. particleSystems: IParticleSystem[];
  43917. skeletons: Skeleton[];
  43918. animationGroups: AnimationGroup[];
  43919. }>;
  43920. /**
  43921. * Load into a scene.
  43922. * @param scene The scene to load into
  43923. * @param data The data to import
  43924. * @param rootUrl The root url for scene and resources
  43925. * @param onProgress The callback when the load progresses
  43926. * @param fileName Defines the name of the file to load
  43927. * @returns Nothing
  43928. */
  43929. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43930. /**
  43931. * Load into an asset container.
  43932. * @param scene The scene to load into
  43933. * @param data The data to import
  43934. * @param rootUrl The root url for scene and resources
  43935. * @param onProgress The callback when the load progresses
  43936. * @param fileName Defines the name of the file to load
  43937. * @returns The loaded asset container
  43938. */
  43939. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43940. }
  43941. /**
  43942. * Class used to load scene from various file formats using registered plugins
  43943. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43944. */
  43945. export class SceneLoader {
  43946. /**
  43947. * No logging while loading
  43948. */
  43949. static readonly NO_LOGGING: number;
  43950. /**
  43951. * Minimal logging while loading
  43952. */
  43953. static readonly MINIMAL_LOGGING: number;
  43954. /**
  43955. * Summary logging while loading
  43956. */
  43957. static readonly SUMMARY_LOGGING: number;
  43958. /**
  43959. * Detailled logging while loading
  43960. */
  43961. static readonly DETAILED_LOGGING: number;
  43962. /**
  43963. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43964. */
  43965. static ForceFullSceneLoadingForIncremental: boolean;
  43966. /**
  43967. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43968. */
  43969. static ShowLoadingScreen: boolean;
  43970. /**
  43971. * Defines the current logging level (while loading the scene)
  43972. * @ignorenaming
  43973. */
  43974. static loggingLevel: number;
  43975. /**
  43976. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43977. */
  43978. static CleanBoneMatrixWeights: boolean;
  43979. /**
  43980. * Event raised when a plugin is used to load a scene
  43981. */
  43982. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43983. private static _registeredPlugins;
  43984. private static _getDefaultPlugin;
  43985. private static _getPluginForExtension;
  43986. private static _getPluginForDirectLoad;
  43987. private static _getPluginForFilename;
  43988. private static _getDirectLoad;
  43989. private static _loadData;
  43990. private static _getFileInfo;
  43991. /**
  43992. * Gets a plugin that can load the given extension
  43993. * @param extension defines the extension to load
  43994. * @returns a plugin or null if none works
  43995. */
  43996. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43997. /**
  43998. * Gets a boolean indicating that the given extension can be loaded
  43999. * @param extension defines the extension to load
  44000. * @returns true if the extension is supported
  44001. */
  44002. static IsPluginForExtensionAvailable(extension: string): boolean;
  44003. /**
  44004. * Adds a new plugin to the list of registered plugins
  44005. * @param plugin defines the plugin to add
  44006. */
  44007. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44008. /**
  44009. * Import meshes into a scene
  44010. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44011. * @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)
  44012. * @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)
  44013. * @param scene the instance of BABYLON.Scene to append to
  44014. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44015. * @param onProgress a callback with a progress event for each file being loaded
  44016. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44017. * @param pluginExtension the extension used to determine the plugin
  44018. * @returns The loaded plugin
  44019. */
  44020. 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>;
  44021. /**
  44022. * Import meshes into a scene
  44023. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44024. * @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)
  44025. * @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)
  44026. * @param scene the instance of BABYLON.Scene to append to
  44027. * @param onProgress a callback with a progress event for each file being loaded
  44028. * @param pluginExtension the extension used to determine the plugin
  44029. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44030. */
  44031. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44032. meshes: AbstractMesh[];
  44033. particleSystems: IParticleSystem[];
  44034. skeletons: Skeleton[];
  44035. animationGroups: AnimationGroup[];
  44036. }>;
  44037. /**
  44038. * Load a scene
  44039. * @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)
  44040. * @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)
  44041. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44042. * @param onSuccess a callback with the scene when import succeeds
  44043. * @param onProgress a callback with a progress event for each file being loaded
  44044. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44045. * @param pluginExtension the extension used to determine the plugin
  44046. * @returns The loaded plugin
  44047. */
  44048. 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>;
  44049. /**
  44050. * Load a scene
  44051. * @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)
  44052. * @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)
  44053. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44054. * @param onProgress a callback with a progress event for each file being loaded
  44055. * @param pluginExtension the extension used to determine the plugin
  44056. * @returns The loaded scene
  44057. */
  44058. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44059. /**
  44060. * Append a scene
  44061. * @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)
  44062. * @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)
  44063. * @param scene is the instance of BABYLON.Scene to append to
  44064. * @param onSuccess a callback with the scene when import succeeds
  44065. * @param onProgress a callback with a progress event for each file being loaded
  44066. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44067. * @param pluginExtension the extension used to determine the plugin
  44068. * @returns The loaded plugin
  44069. */
  44070. 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>;
  44071. /**
  44072. * Append a scene
  44073. * @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)
  44074. * @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)
  44075. * @param scene is the instance of BABYLON.Scene to append to
  44076. * @param onProgress a callback with a progress event for each file being loaded
  44077. * @param pluginExtension the extension used to determine the plugin
  44078. * @returns The given scene
  44079. */
  44080. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44081. /**
  44082. * Load a scene into an asset container
  44083. * @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)
  44084. * @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)
  44085. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44086. * @param onSuccess a callback with the scene when import succeeds
  44087. * @param onProgress a callback with a progress event for each file being loaded
  44088. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44089. * @param pluginExtension the extension used to determine the plugin
  44090. * @returns The loaded plugin
  44091. */
  44092. 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>;
  44093. /**
  44094. * Load a scene into an asset container
  44095. * @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)
  44096. * @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)
  44097. * @param scene is the instance of Scene to append to
  44098. * @param onProgress a callback with a progress event for each file being loaded
  44099. * @param pluginExtension the extension used to determine the plugin
  44100. * @returns The loaded asset container
  44101. */
  44102. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44103. }
  44104. }
  44105. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44106. import { Scene } from "babylonjs/scene";
  44107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44108. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44109. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44110. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44111. /**
  44112. * Generic Controller
  44113. */
  44114. export class GenericController extends WebVRController {
  44115. /**
  44116. * Base Url for the controller model.
  44117. */
  44118. static readonly MODEL_BASE_URL: string;
  44119. /**
  44120. * File name for the controller model.
  44121. */
  44122. static readonly MODEL_FILENAME: string;
  44123. /**
  44124. * Creates a new GenericController from a gamepad
  44125. * @param vrGamepad the gamepad that the controller should be created from
  44126. */
  44127. constructor(vrGamepad: any);
  44128. /**
  44129. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44130. * @param scene scene in which to add meshes
  44131. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44132. */
  44133. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44134. /**
  44135. * Called once for each button that changed state since the last frame
  44136. * @param buttonIdx Which button index changed
  44137. * @param state New state of the button
  44138. * @param changes Which properties on the state changed since last frame
  44139. */
  44140. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44141. }
  44142. }
  44143. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44144. import { Observable } from "babylonjs/Misc/observable";
  44145. import { Scene } from "babylonjs/scene";
  44146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44147. import { Ray } from "babylonjs/Culling/ray";
  44148. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44149. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44150. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44151. /**
  44152. * Defines the WindowsMotionController object that the state of the windows motion controller
  44153. */
  44154. export class WindowsMotionController extends WebVRController {
  44155. /**
  44156. * The base url used to load the left and right controller models
  44157. */
  44158. static MODEL_BASE_URL: string;
  44159. /**
  44160. * The name of the left controller model file
  44161. */
  44162. static MODEL_LEFT_FILENAME: string;
  44163. /**
  44164. * The name of the right controller model file
  44165. */
  44166. static MODEL_RIGHT_FILENAME: string;
  44167. /**
  44168. * The controller name prefix for this controller type
  44169. */
  44170. static readonly GAMEPAD_ID_PREFIX: string;
  44171. /**
  44172. * The controller id pattern for this controller type
  44173. */
  44174. private static readonly GAMEPAD_ID_PATTERN;
  44175. private _loadedMeshInfo;
  44176. private readonly _mapping;
  44177. /**
  44178. * Fired when the trackpad on this controller is clicked
  44179. */
  44180. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44181. /**
  44182. * Fired when the trackpad on this controller is modified
  44183. */
  44184. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44185. /**
  44186. * The current x and y values of this controller's trackpad
  44187. */
  44188. trackpad: StickValues;
  44189. /**
  44190. * Creates a new WindowsMotionController from a gamepad
  44191. * @param vrGamepad the gamepad that the controller should be created from
  44192. */
  44193. constructor(vrGamepad: any);
  44194. /**
  44195. * Fired when the trigger on this controller is modified
  44196. */
  44197. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44198. /**
  44199. * Fired when the menu button on this controller is modified
  44200. */
  44201. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44202. /**
  44203. * Fired when the grip button on this controller is modified
  44204. */
  44205. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44206. /**
  44207. * Fired when the thumbstick button on this controller is modified
  44208. */
  44209. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44210. /**
  44211. * Fired when the touchpad button on this controller is modified
  44212. */
  44213. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44214. /**
  44215. * Fired when the touchpad values on this controller are modified
  44216. */
  44217. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44218. private _updateTrackpad;
  44219. /**
  44220. * Called once per frame by the engine.
  44221. */
  44222. update(): void;
  44223. /**
  44224. * Called once for each button that changed state since the last frame
  44225. * @param buttonIdx Which button index changed
  44226. * @param state New state of the button
  44227. * @param changes Which properties on the state changed since last frame
  44228. */
  44229. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44230. /**
  44231. * Moves the buttons on the controller mesh based on their current state
  44232. * @param buttonName the name of the button to move
  44233. * @param buttonValue the value of the button which determines the buttons new position
  44234. */
  44235. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44236. /**
  44237. * Moves the axis on the controller mesh based on its current state
  44238. * @param axis the index of the axis
  44239. * @param axisValue the value of the axis which determines the meshes new position
  44240. * @hidden
  44241. */
  44242. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44243. /**
  44244. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44245. * @param scene scene in which to add meshes
  44246. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44247. */
  44248. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44249. /**
  44250. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44251. * can be transformed by button presses and axes values, based on this._mapping.
  44252. *
  44253. * @param scene scene in which the meshes exist
  44254. * @param meshes list of meshes that make up the controller model to process
  44255. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44256. */
  44257. private processModel;
  44258. private createMeshInfo;
  44259. /**
  44260. * Gets the ray of the controller in the direction the controller is pointing
  44261. * @param length the length the resulting ray should be
  44262. * @returns a ray in the direction the controller is pointing
  44263. */
  44264. getForwardRay(length?: number): Ray;
  44265. /**
  44266. * Disposes of the controller
  44267. */
  44268. dispose(): void;
  44269. }
  44270. }
  44271. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44272. import { Observable } from "babylonjs/Misc/observable";
  44273. import { Scene } from "babylonjs/scene";
  44274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44275. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44276. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44277. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44278. /**
  44279. * Oculus Touch Controller
  44280. */
  44281. export class OculusTouchController extends WebVRController {
  44282. /**
  44283. * Base Url for the controller model.
  44284. */
  44285. static MODEL_BASE_URL: string;
  44286. /**
  44287. * File name for the left controller model.
  44288. */
  44289. static MODEL_LEFT_FILENAME: string;
  44290. /**
  44291. * File name for the right controller model.
  44292. */
  44293. static MODEL_RIGHT_FILENAME: string;
  44294. /**
  44295. * Base Url for the Quest controller model.
  44296. */
  44297. static QUEST_MODEL_BASE_URL: string;
  44298. /**
  44299. * @hidden
  44300. * If the controllers are running on a device that needs the updated Quest controller models
  44301. */
  44302. static _IsQuest: boolean;
  44303. /**
  44304. * Fired when the secondary trigger on this controller is modified
  44305. */
  44306. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44307. /**
  44308. * Fired when the thumb rest on this controller is modified
  44309. */
  44310. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44311. /**
  44312. * Creates a new OculusTouchController from a gamepad
  44313. * @param vrGamepad the gamepad that the controller should be created from
  44314. */
  44315. constructor(vrGamepad: any);
  44316. /**
  44317. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44318. * @param scene scene in which to add meshes
  44319. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44320. */
  44321. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44322. /**
  44323. * Fired when the A button on this controller is modified
  44324. */
  44325. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44326. /**
  44327. * Fired when the B button on this controller is modified
  44328. */
  44329. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44330. /**
  44331. * Fired when the X button on this controller is modified
  44332. */
  44333. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44334. /**
  44335. * Fired when the Y button on this controller is modified
  44336. */
  44337. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44338. /**
  44339. * Called once for each button that changed state since the last frame
  44340. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44341. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44342. * 2) secondary trigger (same)
  44343. * 3) A (right) X (left), touch, pressed = value
  44344. * 4) B / Y
  44345. * 5) thumb rest
  44346. * @param buttonIdx Which button index changed
  44347. * @param state New state of the button
  44348. * @param changes Which properties on the state changed since last frame
  44349. */
  44350. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44351. }
  44352. }
  44353. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44354. import { Scene } from "babylonjs/scene";
  44355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44356. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44357. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44358. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44359. import { Observable } from "babylonjs/Misc/observable";
  44360. /**
  44361. * Vive Controller
  44362. */
  44363. export class ViveController extends WebVRController {
  44364. /**
  44365. * Base Url for the controller model.
  44366. */
  44367. static MODEL_BASE_URL: string;
  44368. /**
  44369. * File name for the controller model.
  44370. */
  44371. static MODEL_FILENAME: string;
  44372. /**
  44373. * Creates a new ViveController from a gamepad
  44374. * @param vrGamepad the gamepad that the controller should be created from
  44375. */
  44376. constructor(vrGamepad: any);
  44377. /**
  44378. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44379. * @param scene scene in which to add meshes
  44380. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44381. */
  44382. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44383. /**
  44384. * Fired when the left button on this controller is modified
  44385. */
  44386. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44387. /**
  44388. * Fired when the right button on this controller is modified
  44389. */
  44390. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44391. /**
  44392. * Fired when the menu button on this controller is modified
  44393. */
  44394. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44395. /**
  44396. * Called once for each button that changed state since the last frame
  44397. * Vive mapping:
  44398. * 0: touchpad
  44399. * 1: trigger
  44400. * 2: left AND right buttons
  44401. * 3: menu button
  44402. * @param buttonIdx Which button index changed
  44403. * @param state New state of the button
  44404. * @param changes Which properties on the state changed since last frame
  44405. */
  44406. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44407. }
  44408. }
  44409. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44410. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44411. /**
  44412. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44413. */
  44414. export class WebXRControllerModelLoader {
  44415. /**
  44416. * Creates the WebXRControllerModelLoader
  44417. * @param input xr input that creates the controllers
  44418. */
  44419. constructor(input: WebXRInput);
  44420. }
  44421. }
  44422. declare module "babylonjs/Cameras/XR/index" {
  44423. export * from "babylonjs/Cameras/XR/webXRCamera";
  44424. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44425. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44426. export * from "babylonjs/Cameras/XR/webXRInput";
  44427. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44428. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44429. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44430. export * from "babylonjs/Cameras/XR/webXRController";
  44431. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44432. export * from "babylonjs/Cameras/XR/webXRTypes";
  44433. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44434. }
  44435. declare module "babylonjs/Cameras/RigModes/index" {
  44436. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44437. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44438. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44439. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44440. }
  44441. declare module "babylonjs/Cameras/index" {
  44442. export * from "babylonjs/Cameras/Inputs/index";
  44443. export * from "babylonjs/Cameras/cameraInputsManager";
  44444. export * from "babylonjs/Cameras/camera";
  44445. export * from "babylonjs/Cameras/targetCamera";
  44446. export * from "babylonjs/Cameras/freeCamera";
  44447. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44448. export * from "babylonjs/Cameras/touchCamera";
  44449. export * from "babylonjs/Cameras/arcRotateCamera";
  44450. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44451. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44452. export * from "babylonjs/Cameras/flyCamera";
  44453. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44454. export * from "babylonjs/Cameras/followCamera";
  44455. export * from "babylonjs/Cameras/followCameraInputsManager";
  44456. export * from "babylonjs/Cameras/gamepadCamera";
  44457. export * from "babylonjs/Cameras/Stereoscopic/index";
  44458. export * from "babylonjs/Cameras/universalCamera";
  44459. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44460. export * from "babylonjs/Cameras/VR/index";
  44461. export * from "babylonjs/Cameras/XR/index";
  44462. export * from "babylonjs/Cameras/RigModes/index";
  44463. }
  44464. declare module "babylonjs/Collisions/index" {
  44465. export * from "babylonjs/Collisions/collider";
  44466. export * from "babylonjs/Collisions/collisionCoordinator";
  44467. export * from "babylonjs/Collisions/pickingInfo";
  44468. export * from "babylonjs/Collisions/intersectionInfo";
  44469. export * from "babylonjs/Collisions/meshCollisionData";
  44470. }
  44471. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44472. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44473. import { Vector3 } from "babylonjs/Maths/math.vector";
  44474. import { Ray } from "babylonjs/Culling/ray";
  44475. import { Plane } from "babylonjs/Maths/math.plane";
  44476. /**
  44477. * Contains an array of blocks representing the octree
  44478. */
  44479. export interface IOctreeContainer<T> {
  44480. /**
  44481. * Blocks within the octree
  44482. */
  44483. blocks: Array<OctreeBlock<T>>;
  44484. }
  44485. /**
  44486. * Class used to store a cell in an octree
  44487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44488. */
  44489. export class OctreeBlock<T> {
  44490. /**
  44491. * Gets the content of the current block
  44492. */
  44493. entries: T[];
  44494. /**
  44495. * Gets the list of block children
  44496. */
  44497. blocks: Array<OctreeBlock<T>>;
  44498. private _depth;
  44499. private _maxDepth;
  44500. private _capacity;
  44501. private _minPoint;
  44502. private _maxPoint;
  44503. private _boundingVectors;
  44504. private _creationFunc;
  44505. /**
  44506. * Creates a new block
  44507. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44508. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44509. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44510. * @param depth defines the current depth of this block in the octree
  44511. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44512. * @param creationFunc defines a callback to call when an element is added to the block
  44513. */
  44514. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44515. /**
  44516. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44517. */
  44518. readonly capacity: number;
  44519. /**
  44520. * Gets the minimum vector (in world space) of the block's bounding box
  44521. */
  44522. readonly minPoint: Vector3;
  44523. /**
  44524. * Gets the maximum vector (in world space) of the block's bounding box
  44525. */
  44526. readonly maxPoint: Vector3;
  44527. /**
  44528. * Add a new element to this block
  44529. * @param entry defines the element to add
  44530. */
  44531. addEntry(entry: T): void;
  44532. /**
  44533. * Remove an element from this block
  44534. * @param entry defines the element to remove
  44535. */
  44536. removeEntry(entry: T): void;
  44537. /**
  44538. * Add an array of elements to this block
  44539. * @param entries defines the array of elements to add
  44540. */
  44541. addEntries(entries: T[]): void;
  44542. /**
  44543. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44544. * @param frustumPlanes defines the frustum planes to test
  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. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44549. /**
  44550. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44551. * @param sphereCenter defines the bounding sphere center
  44552. * @param sphereRadius defines the bounding sphere radius
  44553. * @param selection defines the array to store current content if selection is positive
  44554. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44555. */
  44556. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44557. /**
  44558. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44559. * @param ray defines the ray to test with
  44560. * @param selection defines the array to store current content if selection is positive
  44561. */
  44562. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44563. /**
  44564. * Subdivide the content into child blocks (this block will then be empty)
  44565. */
  44566. createInnerBlocks(): void;
  44567. /**
  44568. * @hidden
  44569. */
  44570. 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;
  44571. }
  44572. }
  44573. declare module "babylonjs/Culling/Octrees/octree" {
  44574. import { SmartArray } from "babylonjs/Misc/smartArray";
  44575. import { Vector3 } from "babylonjs/Maths/math.vector";
  44576. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44578. import { Ray } from "babylonjs/Culling/ray";
  44579. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44580. import { Plane } from "babylonjs/Maths/math.plane";
  44581. /**
  44582. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44583. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44584. */
  44585. export class Octree<T> {
  44586. /** 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.) */
  44587. maxDepth: number;
  44588. /**
  44589. * Blocks within the octree containing objects
  44590. */
  44591. blocks: Array<OctreeBlock<T>>;
  44592. /**
  44593. * Content stored in the octree
  44594. */
  44595. dynamicContent: T[];
  44596. private _maxBlockCapacity;
  44597. private _selectionContent;
  44598. private _creationFunc;
  44599. /**
  44600. * Creates a octree
  44601. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44602. * @param creationFunc function to be used to instatiate the octree
  44603. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44604. * @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.)
  44605. */
  44606. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44607. /** 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.) */
  44608. maxDepth?: number);
  44609. /**
  44610. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44611. * @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);
  44612. * @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);
  44613. * @param entries meshes to be added to the octree blocks
  44614. */
  44615. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44616. /**
  44617. * Adds a mesh to the octree
  44618. * @param entry Mesh to add to the octree
  44619. */
  44620. addMesh(entry: T): void;
  44621. /**
  44622. * Remove an element from the octree
  44623. * @param entry defines the element to remove
  44624. */
  44625. removeMesh(entry: T): void;
  44626. /**
  44627. * Selects an array of meshes within the frustum
  44628. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44629. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44630. * @returns array of meshes within the frustum
  44631. */
  44632. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44633. /**
  44634. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44635. * @param sphereCenter defines the bounding sphere center
  44636. * @param sphereRadius defines the bounding sphere radius
  44637. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44638. * @returns an array of objects that intersect the sphere
  44639. */
  44640. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44641. /**
  44642. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44643. * @param ray defines the ray to test with
  44644. * @returns array of intersected objects
  44645. */
  44646. intersectsRay(ray: Ray): SmartArray<T>;
  44647. /**
  44648. * Adds a mesh into the octree block if it intersects the block
  44649. */
  44650. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44651. /**
  44652. * Adds a submesh into the octree block if it intersects the block
  44653. */
  44654. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44655. }
  44656. }
  44657. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44658. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44659. import { Scene } from "babylonjs/scene";
  44660. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44662. import { Ray } from "babylonjs/Culling/ray";
  44663. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44664. import { Collider } from "babylonjs/Collisions/collider";
  44665. module "babylonjs/scene" {
  44666. interface Scene {
  44667. /**
  44668. * @hidden
  44669. * Backing Filed
  44670. */
  44671. _selectionOctree: Octree<AbstractMesh>;
  44672. /**
  44673. * Gets the octree used to boost mesh selection (picking)
  44674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44675. */
  44676. selectionOctree: Octree<AbstractMesh>;
  44677. /**
  44678. * Creates or updates the octree used to boost selection (picking)
  44679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44680. * @param maxCapacity defines the maximum capacity per leaf
  44681. * @param maxDepth defines the maximum depth of the octree
  44682. * @returns an octree of AbstractMesh
  44683. */
  44684. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44685. }
  44686. }
  44687. module "babylonjs/Meshes/abstractMesh" {
  44688. interface AbstractMesh {
  44689. /**
  44690. * @hidden
  44691. * Backing Field
  44692. */
  44693. _submeshesOctree: Octree<SubMesh>;
  44694. /**
  44695. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44696. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44697. * @param maxCapacity defines the maximum size of each block (64 by default)
  44698. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44699. * @returns the new octree
  44700. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44702. */
  44703. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44704. }
  44705. }
  44706. /**
  44707. * Defines the octree scene component responsible to manage any octrees
  44708. * in a given scene.
  44709. */
  44710. export class OctreeSceneComponent {
  44711. /**
  44712. * The component name help to identify the component in the list of scene components.
  44713. */
  44714. readonly name: string;
  44715. /**
  44716. * The scene the component belongs to.
  44717. */
  44718. scene: Scene;
  44719. /**
  44720. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44721. */
  44722. readonly checksIsEnabled: boolean;
  44723. /**
  44724. * Creates a new instance of the component for the given scene
  44725. * @param scene Defines the scene to register the component in
  44726. */
  44727. constructor(scene: Scene);
  44728. /**
  44729. * Registers the component in a given scene
  44730. */
  44731. register(): void;
  44732. /**
  44733. * Return the list of active meshes
  44734. * @returns the list of active meshes
  44735. */
  44736. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44737. /**
  44738. * Return the list of active sub meshes
  44739. * @param mesh The mesh to get the candidates sub meshes from
  44740. * @returns the list of active sub meshes
  44741. */
  44742. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44743. private _tempRay;
  44744. /**
  44745. * Return the list of sub meshes intersecting with a given local ray
  44746. * @param mesh defines the mesh to find the submesh for
  44747. * @param localRay defines the ray in local space
  44748. * @returns the list of intersecting sub meshes
  44749. */
  44750. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44751. /**
  44752. * Return the list of sub meshes colliding with a collider
  44753. * @param mesh defines the mesh to find the submesh for
  44754. * @param collider defines the collider to evaluate the collision against
  44755. * @returns the list of colliding sub meshes
  44756. */
  44757. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44758. /**
  44759. * Rebuilds the elements related to this component in case of
  44760. * context lost for instance.
  44761. */
  44762. rebuild(): void;
  44763. /**
  44764. * Disposes the component and the associated ressources.
  44765. */
  44766. dispose(): void;
  44767. }
  44768. }
  44769. declare module "babylonjs/Culling/Octrees/index" {
  44770. export * from "babylonjs/Culling/Octrees/octree";
  44771. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44772. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44773. }
  44774. declare module "babylonjs/Culling/index" {
  44775. export * from "babylonjs/Culling/boundingBox";
  44776. export * from "babylonjs/Culling/boundingInfo";
  44777. export * from "babylonjs/Culling/boundingSphere";
  44778. export * from "babylonjs/Culling/Octrees/index";
  44779. export * from "babylonjs/Culling/ray";
  44780. }
  44781. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44782. import { IDisposable, Scene } from "babylonjs/scene";
  44783. import { Nullable } from "babylonjs/types";
  44784. import { Observable } from "babylonjs/Misc/observable";
  44785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44786. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44787. import { Camera } from "babylonjs/Cameras/camera";
  44788. /**
  44789. * Renders a layer on top of an existing scene
  44790. */
  44791. export class UtilityLayerRenderer implements IDisposable {
  44792. /** the original scene that will be rendered on top of */
  44793. originalScene: Scene;
  44794. private _pointerCaptures;
  44795. private _lastPointerEvents;
  44796. private static _DefaultUtilityLayer;
  44797. private static _DefaultKeepDepthUtilityLayer;
  44798. private _sharedGizmoLight;
  44799. private _renderCamera;
  44800. /**
  44801. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44802. * @returns the camera that is used when rendering the utility layer
  44803. */
  44804. getRenderCamera(): Nullable<Camera>;
  44805. /**
  44806. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44807. * @param cam the camera that should be used when rendering the utility layer
  44808. */
  44809. setRenderCamera(cam: Nullable<Camera>): void;
  44810. /**
  44811. * @hidden
  44812. * Light which used by gizmos to get light shading
  44813. */
  44814. _getSharedGizmoLight(): HemisphericLight;
  44815. /**
  44816. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44817. */
  44818. pickUtilitySceneFirst: boolean;
  44819. /**
  44820. * 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)
  44821. */
  44822. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44823. /**
  44824. * 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)
  44825. */
  44826. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44827. /**
  44828. * The scene that is rendered on top of the original scene
  44829. */
  44830. utilityLayerScene: Scene;
  44831. /**
  44832. * If the utility layer should automatically be rendered on top of existing scene
  44833. */
  44834. shouldRender: boolean;
  44835. /**
  44836. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44837. */
  44838. onlyCheckPointerDownEvents: boolean;
  44839. /**
  44840. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44841. */
  44842. processAllEvents: boolean;
  44843. /**
  44844. * Observable raised when the pointer move from the utility layer scene to the main scene
  44845. */
  44846. onPointerOutObservable: Observable<number>;
  44847. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44848. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44849. private _afterRenderObserver;
  44850. private _sceneDisposeObserver;
  44851. private _originalPointerObserver;
  44852. /**
  44853. * Instantiates a UtilityLayerRenderer
  44854. * @param originalScene the original scene that will be rendered on top of
  44855. * @param handleEvents boolean indicating if the utility layer should handle events
  44856. */
  44857. constructor(
  44858. /** the original scene that will be rendered on top of */
  44859. originalScene: Scene, handleEvents?: boolean);
  44860. private _notifyObservers;
  44861. /**
  44862. * Renders the utility layers scene on top of the original scene
  44863. */
  44864. render(): void;
  44865. /**
  44866. * Disposes of the renderer
  44867. */
  44868. dispose(): void;
  44869. private _updateCamera;
  44870. }
  44871. }
  44872. declare module "babylonjs/Gizmos/gizmo" {
  44873. import { Nullable } from "babylonjs/types";
  44874. import { IDisposable } from "babylonjs/scene";
  44875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44876. import { Mesh } from "babylonjs/Meshes/mesh";
  44877. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44878. /**
  44879. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44880. */
  44881. export class Gizmo implements IDisposable {
  44882. /** The utility layer the gizmo will be added to */
  44883. gizmoLayer: UtilityLayerRenderer;
  44884. /**
  44885. * The root mesh of the gizmo
  44886. */
  44887. _rootMesh: Mesh;
  44888. private _attachedMesh;
  44889. /**
  44890. * Ratio for the scale of the gizmo (Default: 1)
  44891. */
  44892. scaleRatio: number;
  44893. /**
  44894. * If a custom mesh has been set (Default: false)
  44895. */
  44896. protected _customMeshSet: boolean;
  44897. /**
  44898. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44899. * * When set, interactions will be enabled
  44900. */
  44901. attachedMesh: Nullable<AbstractMesh>;
  44902. /**
  44903. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44904. * @param mesh The mesh to replace the default mesh of the gizmo
  44905. */
  44906. setCustomMesh(mesh: Mesh): void;
  44907. /**
  44908. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44909. */
  44910. updateGizmoRotationToMatchAttachedMesh: boolean;
  44911. /**
  44912. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44913. */
  44914. updateGizmoPositionToMatchAttachedMesh: boolean;
  44915. /**
  44916. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44917. */
  44918. updateScale: boolean;
  44919. protected _interactionsEnabled: boolean;
  44920. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44921. private _beforeRenderObserver;
  44922. private _tempVector;
  44923. /**
  44924. * Creates a gizmo
  44925. * @param gizmoLayer The utility layer the gizmo will be added to
  44926. */
  44927. constructor(
  44928. /** The utility layer the gizmo will be added to */
  44929. gizmoLayer?: UtilityLayerRenderer);
  44930. /**
  44931. * Updates the gizmo to match the attached mesh's position/rotation
  44932. */
  44933. protected _update(): void;
  44934. /**
  44935. * Disposes of the gizmo
  44936. */
  44937. dispose(): void;
  44938. }
  44939. }
  44940. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44941. import { Observable } from "babylonjs/Misc/observable";
  44942. import { Nullable } from "babylonjs/types";
  44943. import { Vector3 } from "babylonjs/Maths/math.vector";
  44944. import { Color3 } from "babylonjs/Maths/math.color";
  44945. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44947. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44948. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44949. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44950. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44951. import { Scene } from "babylonjs/scene";
  44952. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44953. /**
  44954. * Single plane drag gizmo
  44955. */
  44956. export class PlaneDragGizmo extends Gizmo {
  44957. /**
  44958. * Drag behavior responsible for the gizmos dragging interactions
  44959. */
  44960. dragBehavior: PointerDragBehavior;
  44961. private _pointerObserver;
  44962. /**
  44963. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44964. */
  44965. snapDistance: number;
  44966. /**
  44967. * Event that fires each time the gizmo snaps to a new location.
  44968. * * snapDistance is the the change in distance
  44969. */
  44970. onSnapObservable: Observable<{
  44971. snapDistance: number;
  44972. }>;
  44973. private _plane;
  44974. private _coloredMaterial;
  44975. private _hoverMaterial;
  44976. private _isEnabled;
  44977. private _parent;
  44978. /** @hidden */
  44979. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44980. /** @hidden */
  44981. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44982. /**
  44983. * Creates a PlaneDragGizmo
  44984. * @param gizmoLayer The utility layer the gizmo will be added to
  44985. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44986. * @param color The color of the gizmo
  44987. */
  44988. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44989. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44990. /**
  44991. * If the gizmo is enabled
  44992. */
  44993. isEnabled: boolean;
  44994. /**
  44995. * Disposes of the gizmo
  44996. */
  44997. dispose(): void;
  44998. }
  44999. }
  45000. declare module "babylonjs/Gizmos/positionGizmo" {
  45001. import { Observable } from "babylonjs/Misc/observable";
  45002. import { Nullable } from "babylonjs/types";
  45003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45004. import { Mesh } from "babylonjs/Meshes/mesh";
  45005. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45006. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45007. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45008. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45009. /**
  45010. * Gizmo that enables dragging a mesh along 3 axis
  45011. */
  45012. export class PositionGizmo extends Gizmo {
  45013. /**
  45014. * Internal gizmo used for interactions on the x axis
  45015. */
  45016. xGizmo: AxisDragGizmo;
  45017. /**
  45018. * Internal gizmo used for interactions on the y axis
  45019. */
  45020. yGizmo: AxisDragGizmo;
  45021. /**
  45022. * Internal gizmo used for interactions on the z axis
  45023. */
  45024. zGizmo: AxisDragGizmo;
  45025. /**
  45026. * Internal gizmo used for interactions on the yz plane
  45027. */
  45028. xPlaneGizmo: PlaneDragGizmo;
  45029. /**
  45030. * Internal gizmo used for interactions on the xz plane
  45031. */
  45032. yPlaneGizmo: PlaneDragGizmo;
  45033. /**
  45034. * Internal gizmo used for interactions on the xy plane
  45035. */
  45036. zPlaneGizmo: PlaneDragGizmo;
  45037. /**
  45038. * private variables
  45039. */
  45040. private _meshAttached;
  45041. private _updateGizmoRotationToMatchAttachedMesh;
  45042. private _snapDistance;
  45043. private _scaleRatio;
  45044. /** Fires an event when any of it's sub gizmos are dragged */
  45045. onDragStartObservable: Observable<unknown>;
  45046. /** Fires an event when any of it's sub gizmos are released from dragging */
  45047. onDragEndObservable: Observable<unknown>;
  45048. /**
  45049. * If set to true, planar drag is enabled
  45050. */
  45051. private _planarGizmoEnabled;
  45052. attachedMesh: Nullable<AbstractMesh>;
  45053. /**
  45054. * Creates a PositionGizmo
  45055. * @param gizmoLayer The utility layer the gizmo will be added to
  45056. */
  45057. constructor(gizmoLayer?: UtilityLayerRenderer);
  45058. /**
  45059. * If the planar drag gizmo is enabled
  45060. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45061. */
  45062. planarGizmoEnabled: boolean;
  45063. updateGizmoRotationToMatchAttachedMesh: boolean;
  45064. /**
  45065. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45066. */
  45067. snapDistance: number;
  45068. /**
  45069. * Ratio for the scale of the gizmo (Default: 1)
  45070. */
  45071. scaleRatio: number;
  45072. /**
  45073. * Disposes of the gizmo
  45074. */
  45075. dispose(): void;
  45076. /**
  45077. * CustomMeshes are not supported by this gizmo
  45078. * @param mesh The mesh to replace the default mesh of the gizmo
  45079. */
  45080. setCustomMesh(mesh: Mesh): void;
  45081. }
  45082. }
  45083. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45084. import { Observable } from "babylonjs/Misc/observable";
  45085. import { Nullable } from "babylonjs/types";
  45086. import { Vector3 } from "babylonjs/Maths/math.vector";
  45087. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45089. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45090. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45091. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45092. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45093. import { Scene } from "babylonjs/scene";
  45094. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45095. import { Color3 } from "babylonjs/Maths/math.color";
  45096. /**
  45097. * Single axis drag gizmo
  45098. */
  45099. export class AxisDragGizmo extends Gizmo {
  45100. /**
  45101. * Drag behavior responsible for the gizmos dragging interactions
  45102. */
  45103. dragBehavior: PointerDragBehavior;
  45104. private _pointerObserver;
  45105. /**
  45106. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45107. */
  45108. snapDistance: number;
  45109. /**
  45110. * Event that fires each time the gizmo snaps to a new location.
  45111. * * snapDistance is the the change in distance
  45112. */
  45113. onSnapObservable: Observable<{
  45114. snapDistance: number;
  45115. }>;
  45116. private _isEnabled;
  45117. private _parent;
  45118. private _arrow;
  45119. private _coloredMaterial;
  45120. private _hoverMaterial;
  45121. /** @hidden */
  45122. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45123. /** @hidden */
  45124. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45125. /**
  45126. * Creates an AxisDragGizmo
  45127. * @param gizmoLayer The utility layer the gizmo will be added to
  45128. * @param dragAxis The axis which the gizmo will be able to drag on
  45129. * @param color The color of the gizmo
  45130. */
  45131. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45132. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45133. /**
  45134. * If the gizmo is enabled
  45135. */
  45136. isEnabled: boolean;
  45137. /**
  45138. * Disposes of the gizmo
  45139. */
  45140. dispose(): void;
  45141. }
  45142. }
  45143. declare module "babylonjs/Debug/axesViewer" {
  45144. import { Vector3 } from "babylonjs/Maths/math.vector";
  45145. import { Nullable } from "babylonjs/types";
  45146. import { Scene } from "babylonjs/scene";
  45147. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45148. /**
  45149. * The Axes viewer will show 3 axes in a specific point in space
  45150. */
  45151. export class AxesViewer {
  45152. private _xAxis;
  45153. private _yAxis;
  45154. private _zAxis;
  45155. private _scaleLinesFactor;
  45156. private _instanced;
  45157. /**
  45158. * Gets the hosting scene
  45159. */
  45160. scene: Scene;
  45161. /**
  45162. * Gets or sets a number used to scale line length
  45163. */
  45164. scaleLines: number;
  45165. /** Gets the node hierarchy used to render x-axis */
  45166. readonly xAxis: TransformNode;
  45167. /** Gets the node hierarchy used to render y-axis */
  45168. readonly yAxis: TransformNode;
  45169. /** Gets the node hierarchy used to render z-axis */
  45170. readonly zAxis: TransformNode;
  45171. /**
  45172. * Creates a new AxesViewer
  45173. * @param scene defines the hosting scene
  45174. * @param scaleLines defines a number used to scale line length (1 by default)
  45175. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45176. * @param xAxis defines the node hierarchy used to render the x-axis
  45177. * @param yAxis defines the node hierarchy used to render the y-axis
  45178. * @param zAxis defines the node hierarchy used to render the z-axis
  45179. */
  45180. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45181. /**
  45182. * Force the viewer to update
  45183. * @param position defines the position of the viewer
  45184. * @param xaxis defines the x axis of the viewer
  45185. * @param yaxis defines the y axis of the viewer
  45186. * @param zaxis defines the z axis of the viewer
  45187. */
  45188. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45189. /**
  45190. * Creates an instance of this axes viewer.
  45191. * @returns a new axes viewer with instanced meshes
  45192. */
  45193. createInstance(): AxesViewer;
  45194. /** Releases resources */
  45195. dispose(): void;
  45196. private static _SetRenderingGroupId;
  45197. }
  45198. }
  45199. declare module "babylonjs/Debug/boneAxesViewer" {
  45200. import { Nullable } from "babylonjs/types";
  45201. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45202. import { Vector3 } from "babylonjs/Maths/math.vector";
  45203. import { Mesh } from "babylonjs/Meshes/mesh";
  45204. import { Bone } from "babylonjs/Bones/bone";
  45205. import { Scene } from "babylonjs/scene";
  45206. /**
  45207. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45208. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45209. */
  45210. export class BoneAxesViewer extends AxesViewer {
  45211. /**
  45212. * Gets or sets the target mesh where to display the axes viewer
  45213. */
  45214. mesh: Nullable<Mesh>;
  45215. /**
  45216. * Gets or sets the target bone where to display the axes viewer
  45217. */
  45218. bone: Nullable<Bone>;
  45219. /** Gets current position */
  45220. pos: Vector3;
  45221. /** Gets direction of X axis */
  45222. xaxis: Vector3;
  45223. /** Gets direction of Y axis */
  45224. yaxis: Vector3;
  45225. /** Gets direction of Z axis */
  45226. zaxis: Vector3;
  45227. /**
  45228. * Creates a new BoneAxesViewer
  45229. * @param scene defines the hosting scene
  45230. * @param bone defines the target bone
  45231. * @param mesh defines the target mesh
  45232. * @param scaleLines defines a scaling factor for line length (1 by default)
  45233. */
  45234. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45235. /**
  45236. * Force the viewer to update
  45237. */
  45238. update(): void;
  45239. /** Releases resources */
  45240. dispose(): void;
  45241. }
  45242. }
  45243. declare module "babylonjs/Debug/debugLayer" {
  45244. import { Scene } from "babylonjs/scene";
  45245. /**
  45246. * Interface used to define scene explorer extensibility option
  45247. */
  45248. export interface IExplorerExtensibilityOption {
  45249. /**
  45250. * Define the option label
  45251. */
  45252. label: string;
  45253. /**
  45254. * Defines the action to execute on click
  45255. */
  45256. action: (entity: any) => void;
  45257. }
  45258. /**
  45259. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45260. */
  45261. export interface IExplorerExtensibilityGroup {
  45262. /**
  45263. * Defines a predicate to test if a given type mut be extended
  45264. */
  45265. predicate: (entity: any) => boolean;
  45266. /**
  45267. * Gets the list of options added to a type
  45268. */
  45269. entries: IExplorerExtensibilityOption[];
  45270. }
  45271. /**
  45272. * Interface used to define the options to use to create the Inspector
  45273. */
  45274. export interface IInspectorOptions {
  45275. /**
  45276. * Display in overlay mode (default: false)
  45277. */
  45278. overlay?: boolean;
  45279. /**
  45280. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45281. */
  45282. globalRoot?: HTMLElement;
  45283. /**
  45284. * Display the Scene explorer
  45285. */
  45286. showExplorer?: boolean;
  45287. /**
  45288. * Display the property inspector
  45289. */
  45290. showInspector?: boolean;
  45291. /**
  45292. * Display in embed mode (both panes on the right)
  45293. */
  45294. embedMode?: boolean;
  45295. /**
  45296. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45297. */
  45298. handleResize?: boolean;
  45299. /**
  45300. * Allow the panes to popup (default: true)
  45301. */
  45302. enablePopup?: boolean;
  45303. /**
  45304. * Allow the panes to be closed by users (default: true)
  45305. */
  45306. enableClose?: boolean;
  45307. /**
  45308. * Optional list of extensibility entries
  45309. */
  45310. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45311. /**
  45312. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45313. */
  45314. inspectorURL?: string;
  45315. }
  45316. module "babylonjs/scene" {
  45317. interface Scene {
  45318. /**
  45319. * @hidden
  45320. * Backing field
  45321. */
  45322. _debugLayer: DebugLayer;
  45323. /**
  45324. * Gets the debug layer (aka Inspector) associated with the scene
  45325. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45326. */
  45327. debugLayer: DebugLayer;
  45328. }
  45329. }
  45330. /**
  45331. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45332. * what is happening in your scene
  45333. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45334. */
  45335. export class DebugLayer {
  45336. /**
  45337. * Define the url to get the inspector script from.
  45338. * By default it uses the babylonjs CDN.
  45339. * @ignoreNaming
  45340. */
  45341. static InspectorURL: string;
  45342. private _scene;
  45343. private BJSINSPECTOR;
  45344. private _onPropertyChangedObservable?;
  45345. /**
  45346. * Observable triggered when a property is changed through the inspector.
  45347. */
  45348. readonly onPropertyChangedObservable: any;
  45349. /**
  45350. * Instantiates a new debug layer.
  45351. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45352. * what is happening in your scene
  45353. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45354. * @param scene Defines the scene to inspect
  45355. */
  45356. constructor(scene: Scene);
  45357. /** Creates the inspector window. */
  45358. private _createInspector;
  45359. /**
  45360. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45361. * @param entity defines the entity to select
  45362. * @param lineContainerTitle defines the specific block to highlight
  45363. */
  45364. select(entity: any, lineContainerTitle?: string): void;
  45365. /** Get the inspector from bundle or global */
  45366. private _getGlobalInspector;
  45367. /**
  45368. * Get if the inspector is visible or not.
  45369. * @returns true if visible otherwise, false
  45370. */
  45371. isVisible(): boolean;
  45372. /**
  45373. * Hide the inspector and close its window.
  45374. */
  45375. hide(): void;
  45376. /**
  45377. * Launch the debugLayer.
  45378. * @param config Define the configuration of the inspector
  45379. * @return a promise fulfilled when the debug layer is visible
  45380. */
  45381. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45382. }
  45383. }
  45384. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45385. import { Nullable } from "babylonjs/types";
  45386. import { Scene } from "babylonjs/scene";
  45387. import { Vector4 } from "babylonjs/Maths/math.vector";
  45388. import { Color4 } from "babylonjs/Maths/math.color";
  45389. import { Mesh } from "babylonjs/Meshes/mesh";
  45390. /**
  45391. * Class containing static functions to help procedurally build meshes
  45392. */
  45393. export class BoxBuilder {
  45394. /**
  45395. * Creates a box mesh
  45396. * * The parameter `size` sets the size (float) of each box side (default 1)
  45397. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45398. * * 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)
  45399. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45403. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45404. * @param name defines the name of the mesh
  45405. * @param options defines the options used to create the mesh
  45406. * @param scene defines the hosting scene
  45407. * @returns the box mesh
  45408. */
  45409. static CreateBox(name: string, options: {
  45410. size?: number;
  45411. width?: number;
  45412. height?: number;
  45413. depth?: number;
  45414. faceUV?: Vector4[];
  45415. faceColors?: Color4[];
  45416. sideOrientation?: number;
  45417. frontUVs?: Vector4;
  45418. backUVs?: Vector4;
  45419. wrap?: boolean;
  45420. topBaseAt?: number;
  45421. bottomBaseAt?: number;
  45422. updatable?: boolean;
  45423. }, scene?: Nullable<Scene>): Mesh;
  45424. }
  45425. }
  45426. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45427. import { Vector4 } from "babylonjs/Maths/math.vector";
  45428. import { Mesh } from "babylonjs/Meshes/mesh";
  45429. import { Scene } from "babylonjs/scene";
  45430. import { Nullable } from "babylonjs/types";
  45431. /**
  45432. * Class containing static functions to help procedurally build meshes
  45433. */
  45434. export class SphereBuilder {
  45435. /**
  45436. * Creates a sphere mesh
  45437. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45438. * * 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`)
  45439. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45440. * * 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
  45441. * * 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)
  45442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45445. * @param name defines the name of the mesh
  45446. * @param options defines the options used to create the mesh
  45447. * @param scene defines the hosting scene
  45448. * @returns the sphere mesh
  45449. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45450. */
  45451. static CreateSphere(name: string, options: {
  45452. segments?: number;
  45453. diameter?: number;
  45454. diameterX?: number;
  45455. diameterY?: number;
  45456. diameterZ?: number;
  45457. arc?: number;
  45458. slice?: number;
  45459. sideOrientation?: number;
  45460. frontUVs?: Vector4;
  45461. backUVs?: Vector4;
  45462. updatable?: boolean;
  45463. }, scene?: Nullable<Scene>): Mesh;
  45464. }
  45465. }
  45466. declare module "babylonjs/Debug/physicsViewer" {
  45467. import { Nullable } from "babylonjs/types";
  45468. import { Scene } from "babylonjs/scene";
  45469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45470. import { Mesh } from "babylonjs/Meshes/mesh";
  45471. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45472. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45473. /**
  45474. * Used to show the physics impostor around the specific mesh
  45475. */
  45476. export class PhysicsViewer {
  45477. /** @hidden */
  45478. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45479. /** @hidden */
  45480. protected _meshes: Array<Nullable<AbstractMesh>>;
  45481. /** @hidden */
  45482. protected _scene: Nullable<Scene>;
  45483. /** @hidden */
  45484. protected _numMeshes: number;
  45485. /** @hidden */
  45486. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45487. private _renderFunction;
  45488. private _utilityLayer;
  45489. private _debugBoxMesh;
  45490. private _debugSphereMesh;
  45491. private _debugCylinderMesh;
  45492. private _debugMaterial;
  45493. private _debugMeshMeshes;
  45494. /**
  45495. * Creates a new PhysicsViewer
  45496. * @param scene defines the hosting scene
  45497. */
  45498. constructor(scene: Scene);
  45499. /** @hidden */
  45500. protected _updateDebugMeshes(): void;
  45501. /**
  45502. * Renders a specified physic impostor
  45503. * @param impostor defines the impostor to render
  45504. * @param targetMesh defines the mesh represented by the impostor
  45505. * @returns the new debug mesh used to render the impostor
  45506. */
  45507. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45508. /**
  45509. * Hides a specified physic impostor
  45510. * @param impostor defines the impostor to hide
  45511. */
  45512. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45513. private _getDebugMaterial;
  45514. private _getDebugBoxMesh;
  45515. private _getDebugSphereMesh;
  45516. private _getDebugCylinderMesh;
  45517. private _getDebugMeshMesh;
  45518. private _getDebugMesh;
  45519. /** Releases all resources */
  45520. dispose(): void;
  45521. }
  45522. }
  45523. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45524. import { Vector3 } from "babylonjs/Maths/math.vector";
  45525. import { Color4 } from "babylonjs/Maths/math.color";
  45526. import { Nullable } from "babylonjs/types";
  45527. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45528. import { Scene } from "babylonjs/scene";
  45529. /**
  45530. * Class containing static functions to help procedurally build meshes
  45531. */
  45532. export class LinesBuilder {
  45533. /**
  45534. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45535. * * 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
  45536. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45537. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45538. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45539. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45540. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45541. * * 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
  45542. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45544. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45545. * @param name defines the name of the new line system
  45546. * @param options defines the options used to create the line system
  45547. * @param scene defines the hosting scene
  45548. * @returns a new line system mesh
  45549. */
  45550. static CreateLineSystem(name: string, options: {
  45551. lines: Vector3[][];
  45552. updatable?: boolean;
  45553. instance?: Nullable<LinesMesh>;
  45554. colors?: Nullable<Color4[][]>;
  45555. useVertexAlpha?: boolean;
  45556. }, scene: Nullable<Scene>): LinesMesh;
  45557. /**
  45558. * Creates a line mesh
  45559. * 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
  45560. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45561. * * The parameter `points` is an array successive Vector3
  45562. * * 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
  45563. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45564. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45565. * * When updating an instance, remember that only point positions can change, not the number of points
  45566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45568. * @param name defines the name of the new line system
  45569. * @param options defines the options used to create the line system
  45570. * @param scene defines the hosting scene
  45571. * @returns a new line mesh
  45572. */
  45573. static CreateLines(name: string, options: {
  45574. points: Vector3[];
  45575. updatable?: boolean;
  45576. instance?: Nullable<LinesMesh>;
  45577. colors?: Color4[];
  45578. useVertexAlpha?: boolean;
  45579. }, scene?: Nullable<Scene>): LinesMesh;
  45580. /**
  45581. * Creates a dashed line mesh
  45582. * * 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
  45583. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45584. * * The parameter `points` is an array successive Vector3
  45585. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45586. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45587. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45588. * * 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
  45589. * * When updating an instance, remember that only point positions can change, not the number of points
  45590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45591. * @param name defines the name of the mesh
  45592. * @param options defines the options used to create the mesh
  45593. * @param scene defines the hosting scene
  45594. * @returns the dashed line mesh
  45595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45596. */
  45597. static CreateDashedLines(name: string, options: {
  45598. points: Vector3[];
  45599. dashSize?: number;
  45600. gapSize?: number;
  45601. dashNb?: number;
  45602. updatable?: boolean;
  45603. instance?: LinesMesh;
  45604. }, scene?: Nullable<Scene>): LinesMesh;
  45605. }
  45606. }
  45607. declare module "babylonjs/Debug/rayHelper" {
  45608. import { Nullable } from "babylonjs/types";
  45609. import { Ray } from "babylonjs/Culling/ray";
  45610. import { Vector3 } from "babylonjs/Maths/math.vector";
  45611. import { Color3 } from "babylonjs/Maths/math.color";
  45612. import { Scene } from "babylonjs/scene";
  45613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45614. import "babylonjs/Meshes/Builders/linesBuilder";
  45615. /**
  45616. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45617. * in order to better appreciate the issue one might have.
  45618. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45619. */
  45620. export class RayHelper {
  45621. /**
  45622. * Defines the ray we are currently tryin to visualize.
  45623. */
  45624. ray: Nullable<Ray>;
  45625. private _renderPoints;
  45626. private _renderLine;
  45627. private _renderFunction;
  45628. private _scene;
  45629. private _updateToMeshFunction;
  45630. private _attachedToMesh;
  45631. private _meshSpaceDirection;
  45632. private _meshSpaceOrigin;
  45633. /**
  45634. * Helper function to create a colored helper in a scene in one line.
  45635. * @param ray Defines the ray we are currently tryin to visualize
  45636. * @param scene Defines the scene the ray is used in
  45637. * @param color Defines the color we want to see the ray in
  45638. * @returns The newly created ray helper.
  45639. */
  45640. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45641. /**
  45642. * Instantiate a new ray helper.
  45643. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45644. * in order to better appreciate the issue one might have.
  45645. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45646. * @param ray Defines the ray we are currently tryin to visualize
  45647. */
  45648. constructor(ray: Ray);
  45649. /**
  45650. * Shows the ray we are willing to debug.
  45651. * @param scene Defines the scene the ray needs to be rendered in
  45652. * @param color Defines the color the ray needs to be rendered in
  45653. */
  45654. show(scene: Scene, color?: Color3): void;
  45655. /**
  45656. * Hides the ray we are debugging.
  45657. */
  45658. hide(): void;
  45659. private _render;
  45660. /**
  45661. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45662. * @param mesh Defines the mesh we want the helper attached to
  45663. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45664. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45665. * @param length Defines the length of the ray
  45666. */
  45667. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45668. /**
  45669. * Detach the ray helper from the mesh it has previously been attached to.
  45670. */
  45671. detachFromMesh(): void;
  45672. private _updateToMesh;
  45673. /**
  45674. * Dispose the helper and release its associated resources.
  45675. */
  45676. dispose(): void;
  45677. }
  45678. }
  45679. declare module "babylonjs/Debug/skeletonViewer" {
  45680. import { Color3 } from "babylonjs/Maths/math.color";
  45681. import { Scene } from "babylonjs/scene";
  45682. import { Nullable } from "babylonjs/types";
  45683. import { Skeleton } from "babylonjs/Bones/skeleton";
  45684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45685. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45686. /**
  45687. * Class used to render a debug view of a given skeleton
  45688. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45689. */
  45690. export class SkeletonViewer {
  45691. /** defines the skeleton to render */
  45692. skeleton: Skeleton;
  45693. /** defines the mesh attached to the skeleton */
  45694. mesh: AbstractMesh;
  45695. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45696. autoUpdateBonesMatrices: boolean;
  45697. /** defines the rendering group id to use with the viewer */
  45698. renderingGroupId: number;
  45699. /** Gets or sets the color used to render the skeleton */
  45700. color: Color3;
  45701. private _scene;
  45702. private _debugLines;
  45703. private _debugMesh;
  45704. private _isEnabled;
  45705. private _renderFunction;
  45706. private _utilityLayer;
  45707. /**
  45708. * Returns the mesh used to render the bones
  45709. */
  45710. readonly debugMesh: Nullable<LinesMesh>;
  45711. /**
  45712. * Creates a new SkeletonViewer
  45713. * @param skeleton defines the skeleton to render
  45714. * @param mesh defines the mesh attached to the skeleton
  45715. * @param scene defines the hosting scene
  45716. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45717. * @param renderingGroupId defines the rendering group id to use with the viewer
  45718. */
  45719. constructor(
  45720. /** defines the skeleton to render */
  45721. skeleton: Skeleton,
  45722. /** defines the mesh attached to the skeleton */
  45723. mesh: AbstractMesh, scene: Scene,
  45724. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45725. autoUpdateBonesMatrices?: boolean,
  45726. /** defines the rendering group id to use with the viewer */
  45727. renderingGroupId?: number);
  45728. /** Gets or sets a boolean indicating if the viewer is enabled */
  45729. isEnabled: boolean;
  45730. private _getBonePosition;
  45731. private _getLinesForBonesWithLength;
  45732. private _getLinesForBonesNoLength;
  45733. /** Update the viewer to sync with current skeleton state */
  45734. update(): void;
  45735. /** Release associated resources */
  45736. dispose(): void;
  45737. }
  45738. }
  45739. declare module "babylonjs/Debug/index" {
  45740. export * from "babylonjs/Debug/axesViewer";
  45741. export * from "babylonjs/Debug/boneAxesViewer";
  45742. export * from "babylonjs/Debug/debugLayer";
  45743. export * from "babylonjs/Debug/physicsViewer";
  45744. export * from "babylonjs/Debug/rayHelper";
  45745. export * from "babylonjs/Debug/skeletonViewer";
  45746. }
  45747. declare module "babylonjs/Engines/nullEngine" {
  45748. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45749. import { Scene } from "babylonjs/scene";
  45750. import { Engine } from "babylonjs/Engines/engine";
  45751. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45752. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45753. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45754. import { Effect } from "babylonjs/Materials/effect";
  45755. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45756. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45757. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45758. /**
  45759. * Options to create the null engine
  45760. */
  45761. export class NullEngineOptions {
  45762. /**
  45763. * Render width (Default: 512)
  45764. */
  45765. renderWidth: number;
  45766. /**
  45767. * Render height (Default: 256)
  45768. */
  45769. renderHeight: number;
  45770. /**
  45771. * Texture size (Default: 512)
  45772. */
  45773. textureSize: number;
  45774. /**
  45775. * If delta time between frames should be constant
  45776. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45777. */
  45778. deterministicLockstep: boolean;
  45779. /**
  45780. * Maximum about of steps between frames (Default: 4)
  45781. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45782. */
  45783. lockstepMaxSteps: number;
  45784. }
  45785. /**
  45786. * The null engine class provides support for headless version of babylon.js.
  45787. * This can be used in server side scenario or for testing purposes
  45788. */
  45789. export class NullEngine extends Engine {
  45790. private _options;
  45791. /**
  45792. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45793. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45794. * @returns true if engine is in deterministic lock step mode
  45795. */
  45796. isDeterministicLockStep(): boolean;
  45797. /**
  45798. * Gets the max steps when engine is running in deterministic lock step
  45799. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45800. * @returns the max steps
  45801. */
  45802. getLockstepMaxSteps(): number;
  45803. /**
  45804. * Gets the current hardware scaling level.
  45805. * By default the hardware scaling level is computed from the window device ratio.
  45806. * 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.
  45807. * @returns a number indicating the current hardware scaling level
  45808. */
  45809. getHardwareScalingLevel(): number;
  45810. constructor(options?: NullEngineOptions);
  45811. /**
  45812. * Creates a vertex buffer
  45813. * @param vertices the data for the vertex buffer
  45814. * @returns the new WebGL static buffer
  45815. */
  45816. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45817. /**
  45818. * Creates a new index buffer
  45819. * @param indices defines the content of the index buffer
  45820. * @param updatable defines if the index buffer must be updatable
  45821. * @returns a new webGL buffer
  45822. */
  45823. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45824. /**
  45825. * Clear the current render buffer or the current render target (if any is set up)
  45826. * @param color defines the color to use
  45827. * @param backBuffer defines if the back buffer must be cleared
  45828. * @param depth defines if the depth buffer must be cleared
  45829. * @param stencil defines if the stencil buffer must be cleared
  45830. */
  45831. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45832. /**
  45833. * Gets the current render width
  45834. * @param useScreen defines if screen size must be used (or the current render target if any)
  45835. * @returns a number defining the current render width
  45836. */
  45837. getRenderWidth(useScreen?: boolean): number;
  45838. /**
  45839. * Gets the current render height
  45840. * @param useScreen defines if screen size must be used (or the current render target if any)
  45841. * @returns a number defining the current render height
  45842. */
  45843. getRenderHeight(useScreen?: boolean): number;
  45844. /**
  45845. * Set the WebGL's viewport
  45846. * @param viewport defines the viewport element to be used
  45847. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45848. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45849. */
  45850. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45851. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45852. /**
  45853. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45854. * @param pipelineContext defines the pipeline context to use
  45855. * @param uniformsNames defines the list of uniform names
  45856. * @returns an array of webGL uniform locations
  45857. */
  45858. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45859. /**
  45860. * Gets the lsit of active attributes for a given webGL program
  45861. * @param pipelineContext defines the pipeline context to use
  45862. * @param attributesNames defines the list of attribute names to get
  45863. * @returns an array of indices indicating the offset of each attribute
  45864. */
  45865. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45866. /**
  45867. * Binds an effect to the webGL context
  45868. * @param effect defines the effect to bind
  45869. */
  45870. bindSamplers(effect: Effect): void;
  45871. /**
  45872. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45873. * @param effect defines the effect to activate
  45874. */
  45875. enableEffect(effect: Effect): void;
  45876. /**
  45877. * Set various states to the webGL context
  45878. * @param culling defines backface culling state
  45879. * @param zOffset defines the value to apply to zOffset (0 by default)
  45880. * @param force defines if states must be applied even if cache is up to date
  45881. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45882. */
  45883. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45884. /**
  45885. * Set the value of an uniform to an array of int32
  45886. * @param uniform defines the webGL uniform location where to store the value
  45887. * @param array defines the array of int32 to store
  45888. */
  45889. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45890. /**
  45891. * Set the value of an uniform to an array of int32 (stored as vec2)
  45892. * @param uniform defines the webGL uniform location where to store the value
  45893. * @param array defines the array of int32 to store
  45894. */
  45895. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45896. /**
  45897. * Set the value of an uniform to an array of int32 (stored as vec3)
  45898. * @param uniform defines the webGL uniform location where to store the value
  45899. * @param array defines the array of int32 to store
  45900. */
  45901. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45902. /**
  45903. * Set the value of an uniform to an array of int32 (stored as vec4)
  45904. * @param uniform defines the webGL uniform location where to store the value
  45905. * @param array defines the array of int32 to store
  45906. */
  45907. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45908. /**
  45909. * Set the value of an uniform to an array of float32
  45910. * @param uniform defines the webGL uniform location where to store the value
  45911. * @param array defines the array of float32 to store
  45912. */
  45913. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45914. /**
  45915. * Set the value of an uniform to an array of float32 (stored as vec2)
  45916. * @param uniform defines the webGL uniform location where to store the value
  45917. * @param array defines the array of float32 to store
  45918. */
  45919. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45920. /**
  45921. * Set the value of an uniform to an array of float32 (stored as vec3)
  45922. * @param uniform defines the webGL uniform location where to store the value
  45923. * @param array defines the array of float32 to store
  45924. */
  45925. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45926. /**
  45927. * Set the value of an uniform to an array of float32 (stored as vec4)
  45928. * @param uniform defines the webGL uniform location where to store the value
  45929. * @param array defines the array of float32 to store
  45930. */
  45931. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45932. /**
  45933. * Set the value of an uniform to an array of number
  45934. * @param uniform defines the webGL uniform location where to store the value
  45935. * @param array defines the array of number to store
  45936. */
  45937. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45938. /**
  45939. * Set the value of an uniform to an array of number (stored as vec2)
  45940. * @param uniform defines the webGL uniform location where to store the value
  45941. * @param array defines the array of number to store
  45942. */
  45943. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45944. /**
  45945. * Set the value of an uniform to an array of number (stored as vec3)
  45946. * @param uniform defines the webGL uniform location where to store the value
  45947. * @param array defines the array of number to store
  45948. */
  45949. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45950. /**
  45951. * Set the value of an uniform to an array of number (stored as vec4)
  45952. * @param uniform defines the webGL uniform location where to store the value
  45953. * @param array defines the array of number to store
  45954. */
  45955. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45956. /**
  45957. * Set the value of an uniform to an array of float32 (stored as matrices)
  45958. * @param uniform defines the webGL uniform location where to store the value
  45959. * @param matrices defines the array of float32 to store
  45960. */
  45961. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45962. /**
  45963. * Set the value of an uniform to a matrix (3x3)
  45964. * @param uniform defines the webGL uniform location where to store the value
  45965. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45966. */
  45967. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45968. /**
  45969. * Set the value of an uniform to a matrix (2x2)
  45970. * @param uniform defines the webGL uniform location where to store the value
  45971. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45972. */
  45973. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45974. /**
  45975. * Set the value of an uniform to a number (float)
  45976. * @param uniform defines the webGL uniform location where to store the value
  45977. * @param value defines the float number to store
  45978. */
  45979. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45980. /**
  45981. * Set the value of an uniform to a vec2
  45982. * @param uniform defines the webGL uniform location where to store the value
  45983. * @param x defines the 1st component of the value
  45984. * @param y defines the 2nd component of the value
  45985. */
  45986. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45987. /**
  45988. * Set the value of an uniform to a vec3
  45989. * @param uniform defines the webGL uniform location where to store the value
  45990. * @param x defines the 1st component of the value
  45991. * @param y defines the 2nd component of the value
  45992. * @param z defines the 3rd component of the value
  45993. */
  45994. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45995. /**
  45996. * Set the value of an uniform to a boolean
  45997. * @param uniform defines the webGL uniform location where to store the value
  45998. * @param bool defines the boolean to store
  45999. */
  46000. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46001. /**
  46002. * Set the value of an uniform to a vec4
  46003. * @param uniform defines the webGL uniform location where to store the value
  46004. * @param x defines the 1st component of the value
  46005. * @param y defines the 2nd component of the value
  46006. * @param z defines the 3rd component of the value
  46007. * @param w defines the 4th component of the value
  46008. */
  46009. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46010. /**
  46011. * Sets the current alpha mode
  46012. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46013. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46014. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46015. */
  46016. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46017. /**
  46018. * Bind webGl buffers directly to the webGL context
  46019. * @param vertexBuffers defines the vertex buffer to bind
  46020. * @param indexBuffer defines the index buffer to bind
  46021. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46022. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46023. * @param effect defines the effect associated with the vertex buffer
  46024. */
  46025. bindBuffers(vertexBuffers: {
  46026. [key: string]: VertexBuffer;
  46027. }, indexBuffer: DataBuffer, effect: Effect): void;
  46028. /**
  46029. * Force the entire cache to be cleared
  46030. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46031. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46032. */
  46033. wipeCaches(bruteForce?: boolean): void;
  46034. /**
  46035. * Send a draw order
  46036. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  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. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46042. /**
  46043. * Draw a list of indexed primitives
  46044. * @param fillMode defines the primitive to use
  46045. * @param indexStart defines the starting index
  46046. * @param indexCount defines the number of index to draw
  46047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46048. */
  46049. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46050. /**
  46051. * Draw a list of unindexed primitives
  46052. * @param fillMode defines the primitive to use
  46053. * @param verticesStart defines the index of first vertex to draw
  46054. * @param verticesCount defines the count of vertices to draw
  46055. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46056. */
  46057. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46058. /** @hidden */
  46059. _createTexture(): WebGLTexture;
  46060. /** @hidden */
  46061. _releaseTexture(texture: InternalTexture): void;
  46062. /**
  46063. * Usually called from Texture.ts.
  46064. * Passed information to create a WebGLTexture
  46065. * @param urlArg defines a value which contains one of the following:
  46066. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46067. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46068. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46069. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46070. * @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)
  46071. * @param scene needed for loading to the correct scene
  46072. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46073. * @param onLoad optional callback to be called upon successful completion
  46074. * @param onError optional callback to be called upon failure
  46075. * @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
  46076. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46077. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46078. * @param forcedExtension defines the extension to use to pick the right loader
  46079. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46080. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46081. */
  46082. 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;
  46083. /**
  46084. * Creates a new render target texture
  46085. * @param size defines the size of the texture
  46086. * @param options defines the options used to create the texture
  46087. * @returns a new render target texture stored in an InternalTexture
  46088. */
  46089. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46090. /**
  46091. * Update the sampling mode of a given texture
  46092. * @param samplingMode defines the required sampling mode
  46093. * @param texture defines the texture to update
  46094. */
  46095. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46096. /**
  46097. * Binds the frame buffer to the specified texture.
  46098. * @param texture The texture to render to or null for the default canvas
  46099. * @param faceIndex The face of the texture to render to in case of cube texture
  46100. * @param requiredWidth The width of the target to render to
  46101. * @param requiredHeight The height of the target to render to
  46102. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46103. * @param depthStencilTexture The depth stencil texture to use to render
  46104. * @param lodLevel defines le lod level to bind to the frame buffer
  46105. */
  46106. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46107. /**
  46108. * Unbind the current render target texture from the webGL context
  46109. * @param texture defines the render target texture to unbind
  46110. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46111. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46112. */
  46113. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46114. /**
  46115. * Creates a dynamic vertex buffer
  46116. * @param vertices the data for the dynamic vertex buffer
  46117. * @returns the new WebGL dynamic buffer
  46118. */
  46119. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46120. /**
  46121. * Update the content of a dynamic texture
  46122. * @param texture defines the texture to update
  46123. * @param canvas defines the canvas containing the source
  46124. * @param invertY defines if data must be stored with Y axis inverted
  46125. * @param premulAlpha defines if alpha is stored as premultiplied
  46126. * @param format defines the format of the data
  46127. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46128. */
  46129. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46130. /**
  46131. * Gets a boolean indicating if all created effects are ready
  46132. * @returns true if all effects are ready
  46133. */
  46134. areAllEffectsReady(): boolean;
  46135. /**
  46136. * @hidden
  46137. * Get the current error code of the webGL context
  46138. * @returns the error code
  46139. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46140. */
  46141. getError(): number;
  46142. /** @hidden */
  46143. _getUnpackAlignement(): number;
  46144. /** @hidden */
  46145. _unpackFlipY(value: boolean): void;
  46146. /**
  46147. * Update a dynamic index buffer
  46148. * @param indexBuffer defines the target index buffer
  46149. * @param indices defines the data to update
  46150. * @param offset defines the offset in the target index buffer where update should start
  46151. */
  46152. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46153. /**
  46154. * Updates a dynamic vertex buffer.
  46155. * @param vertexBuffer the vertex buffer to update
  46156. * @param vertices the data used to update the vertex buffer
  46157. * @param byteOffset the byte offset of the data (optional)
  46158. * @param byteLength the byte length of the data (optional)
  46159. */
  46160. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46161. /** @hidden */
  46162. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46163. /** @hidden */
  46164. _bindTexture(channel: number, texture: InternalTexture): void;
  46165. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46166. /**
  46167. * 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
  46168. */
  46169. releaseEffects(): void;
  46170. displayLoadingUI(): void;
  46171. hideLoadingUI(): void;
  46172. /** @hidden */
  46173. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46174. /** @hidden */
  46175. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46176. /** @hidden */
  46177. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46178. /** @hidden */
  46179. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46180. }
  46181. }
  46182. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46183. import { Nullable, int } from "babylonjs/types";
  46184. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46185. /** @hidden */
  46186. export class _OcclusionDataStorage {
  46187. /** @hidden */
  46188. occlusionInternalRetryCounter: number;
  46189. /** @hidden */
  46190. isOcclusionQueryInProgress: boolean;
  46191. /** @hidden */
  46192. isOccluded: boolean;
  46193. /** @hidden */
  46194. occlusionRetryCount: number;
  46195. /** @hidden */
  46196. occlusionType: number;
  46197. /** @hidden */
  46198. occlusionQueryAlgorithmType: number;
  46199. }
  46200. module "babylonjs/Engines/engine" {
  46201. interface Engine {
  46202. /**
  46203. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46204. * @return the new query
  46205. */
  46206. createQuery(): WebGLQuery;
  46207. /**
  46208. * Delete and release a webGL query
  46209. * @param query defines the query to delete
  46210. * @return the current engine
  46211. */
  46212. deleteQuery(query: WebGLQuery): Engine;
  46213. /**
  46214. * Check if a given query has resolved and got its value
  46215. * @param query defines the query to check
  46216. * @returns true if the query got its value
  46217. */
  46218. isQueryResultAvailable(query: WebGLQuery): boolean;
  46219. /**
  46220. * Gets the value of a given query
  46221. * @param query defines the query to check
  46222. * @returns the value of the query
  46223. */
  46224. getQueryResult(query: WebGLQuery): number;
  46225. /**
  46226. * Initiates an occlusion query
  46227. * @param algorithmType defines the algorithm to use
  46228. * @param query defines the query to use
  46229. * @returns the current engine
  46230. * @see http://doc.babylonjs.com/features/occlusionquery
  46231. */
  46232. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46233. /**
  46234. * Ends an occlusion query
  46235. * @see http://doc.babylonjs.com/features/occlusionquery
  46236. * @param algorithmType defines the algorithm to use
  46237. * @returns the current engine
  46238. */
  46239. endOcclusionQuery(algorithmType: number): Engine;
  46240. /**
  46241. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46242. * Please note that only one query can be issued at a time
  46243. * @returns a time token used to track the time span
  46244. */
  46245. startTimeQuery(): Nullable<_TimeToken>;
  46246. /**
  46247. * Ends a time query
  46248. * @param token defines the token used to measure the time span
  46249. * @returns the time spent (in ns)
  46250. */
  46251. endTimeQuery(token: _TimeToken): int;
  46252. /** @hidden */
  46253. _currentNonTimestampToken: Nullable<_TimeToken>;
  46254. /** @hidden */
  46255. _createTimeQuery(): WebGLQuery;
  46256. /** @hidden */
  46257. _deleteTimeQuery(query: WebGLQuery): void;
  46258. /** @hidden */
  46259. _getGlAlgorithmType(algorithmType: number): number;
  46260. /** @hidden */
  46261. _getTimeQueryResult(query: WebGLQuery): any;
  46262. /** @hidden */
  46263. _getTimeQueryAvailability(query: WebGLQuery): any;
  46264. }
  46265. }
  46266. module "babylonjs/Meshes/abstractMesh" {
  46267. interface AbstractMesh {
  46268. /**
  46269. * Backing filed
  46270. * @hidden
  46271. */
  46272. __occlusionDataStorage: _OcclusionDataStorage;
  46273. /**
  46274. * Access property
  46275. * @hidden
  46276. */
  46277. _occlusionDataStorage: _OcclusionDataStorage;
  46278. /**
  46279. * 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.
  46280. * The default value is -1 which means don't break the query and wait till the result
  46281. * @see http://doc.babylonjs.com/features/occlusionquery
  46282. */
  46283. occlusionRetryCount: number;
  46284. /**
  46285. * 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:
  46286. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46287. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46288. * * 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.
  46289. * @see http://doc.babylonjs.com/features/occlusionquery
  46290. */
  46291. occlusionType: number;
  46292. /**
  46293. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46294. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46295. * * 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.
  46296. * @see http://doc.babylonjs.com/features/occlusionquery
  46297. */
  46298. occlusionQueryAlgorithmType: number;
  46299. /**
  46300. * 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
  46301. * @see http://doc.babylonjs.com/features/occlusionquery
  46302. */
  46303. isOccluded: boolean;
  46304. /**
  46305. * Flag to check the progress status of the query
  46306. * @see http://doc.babylonjs.com/features/occlusionquery
  46307. */
  46308. isOcclusionQueryInProgress: boolean;
  46309. }
  46310. }
  46311. }
  46312. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46313. import { Nullable } from "babylonjs/types";
  46314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46315. /** @hidden */
  46316. export var _forceTransformFeedbackToBundle: boolean;
  46317. module "babylonjs/Engines/engine" {
  46318. interface Engine {
  46319. /**
  46320. * Creates a webGL transform feedback object
  46321. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46322. * @returns the webGL transform feedback object
  46323. */
  46324. createTransformFeedback(): WebGLTransformFeedback;
  46325. /**
  46326. * Delete a webGL transform feedback object
  46327. * @param value defines the webGL transform feedback object to delete
  46328. */
  46329. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46330. /**
  46331. * Bind a webGL transform feedback object to the webgl context
  46332. * @param value defines the webGL transform feedback object to bind
  46333. */
  46334. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46335. /**
  46336. * Begins a transform feedback operation
  46337. * @param usePoints defines if points or triangles must be used
  46338. */
  46339. beginTransformFeedback(usePoints: boolean): void;
  46340. /**
  46341. * Ends a transform feedback operation
  46342. */
  46343. endTransformFeedback(): void;
  46344. /**
  46345. * Specify the varyings to use with transform feedback
  46346. * @param program defines the associated webGL program
  46347. * @param value defines the list of strings representing the varying names
  46348. */
  46349. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46350. /**
  46351. * Bind a webGL buffer for a transform feedback operation
  46352. * @param value defines the webGL buffer to bind
  46353. */
  46354. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46355. }
  46356. }
  46357. }
  46358. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46359. import { Scene } from "babylonjs/scene";
  46360. import { Engine } from "babylonjs/Engines/engine";
  46361. import { Texture } from "babylonjs/Materials/Textures/texture";
  46362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46363. import "babylonjs/Engines/Extensions/engine.multiRender";
  46364. /**
  46365. * Creation options of the multi render target texture.
  46366. */
  46367. export interface IMultiRenderTargetOptions {
  46368. /**
  46369. * Define if the texture needs to create mip maps after render.
  46370. */
  46371. generateMipMaps?: boolean;
  46372. /**
  46373. * Define the types of all the draw buffers we want to create
  46374. */
  46375. types?: number[];
  46376. /**
  46377. * Define the sampling modes of all the draw buffers we want to create
  46378. */
  46379. samplingModes?: number[];
  46380. /**
  46381. * Define if a depth buffer is required
  46382. */
  46383. generateDepthBuffer?: boolean;
  46384. /**
  46385. * Define if a stencil buffer is required
  46386. */
  46387. generateStencilBuffer?: boolean;
  46388. /**
  46389. * Define if a depth texture is required instead of a depth buffer
  46390. */
  46391. generateDepthTexture?: boolean;
  46392. /**
  46393. * Define the number of desired draw buffers
  46394. */
  46395. textureCount?: number;
  46396. /**
  46397. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46398. */
  46399. doNotChangeAspectRatio?: boolean;
  46400. /**
  46401. * Define the default type of the buffers we are creating
  46402. */
  46403. defaultType?: number;
  46404. }
  46405. /**
  46406. * A multi render target, like a render target provides the ability to render to a texture.
  46407. * Unlike the render target, it can render to several draw buffers in one draw.
  46408. * This is specially interesting in deferred rendering or for any effects requiring more than
  46409. * just one color from a single pass.
  46410. */
  46411. export class MultiRenderTarget extends RenderTargetTexture {
  46412. private _internalTextures;
  46413. private _textures;
  46414. private _multiRenderTargetOptions;
  46415. /**
  46416. * Get if draw buffers are currently supported by the used hardware and browser.
  46417. */
  46418. readonly isSupported: boolean;
  46419. /**
  46420. * Get the list of textures generated by the multi render target.
  46421. */
  46422. readonly textures: Texture[];
  46423. /**
  46424. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46425. */
  46426. readonly depthTexture: Texture;
  46427. /**
  46428. * Set the wrapping mode on U of all the textures we are rendering to.
  46429. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46430. */
  46431. wrapU: number;
  46432. /**
  46433. * Set the wrapping mode on V of all the textures we are rendering to.
  46434. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46435. */
  46436. wrapV: number;
  46437. /**
  46438. * Instantiate a new multi render target texture.
  46439. * A multi render target, like a render target provides the ability to render to a texture.
  46440. * Unlike the render target, it can render to several draw buffers in one draw.
  46441. * This is specially interesting in deferred rendering or for any effects requiring more than
  46442. * just one color from a single pass.
  46443. * @param name Define the name of the texture
  46444. * @param size Define the size of the buffers to render to
  46445. * @param count Define the number of target we are rendering into
  46446. * @param scene Define the scene the texture belongs to
  46447. * @param options Define the options used to create the multi render target
  46448. */
  46449. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46450. /** @hidden */
  46451. _rebuild(): void;
  46452. private _createInternalTextures;
  46453. private _createTextures;
  46454. /**
  46455. * Define the number of samples used if MSAA is enabled.
  46456. */
  46457. samples: number;
  46458. /**
  46459. * Resize all the textures in the multi render target.
  46460. * Be carrefull as it will recreate all the data in the new texture.
  46461. * @param size Define the new size
  46462. */
  46463. resize(size: any): void;
  46464. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46465. /**
  46466. * Dispose the render targets and their associated resources
  46467. */
  46468. dispose(): void;
  46469. /**
  46470. * Release all the underlying texture used as draw buffers.
  46471. */
  46472. releaseInternalTextures(): void;
  46473. }
  46474. }
  46475. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46477. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46478. import { Nullable } from "babylonjs/types";
  46479. module "babylonjs/Engines/thinEngine" {
  46480. interface ThinEngine {
  46481. /**
  46482. * Unbind a list of render target textures from the webGL context
  46483. * This is used only when drawBuffer extension or webGL2 are active
  46484. * @param textures defines the render target textures to unbind
  46485. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46486. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46487. */
  46488. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46489. /**
  46490. * Create a multi render target texture
  46491. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46492. * @param size defines the size of the texture
  46493. * @param options defines the creation options
  46494. * @returns the cube texture as an InternalTexture
  46495. */
  46496. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46497. /**
  46498. * Update the sample count for a given multiple render target texture
  46499. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46500. * @param textures defines the textures to update
  46501. * @param samples defines the sample count to set
  46502. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46503. */
  46504. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46505. }
  46506. }
  46507. }
  46508. declare module "babylonjs/Engines/Extensions/engine.views" {
  46509. import { Camera } from "babylonjs/Cameras/camera";
  46510. import { Nullable } from "babylonjs/types";
  46511. /**
  46512. * Class used to define an additional view for the engine
  46513. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46514. */
  46515. export class EngineView {
  46516. /** Defines the canvas where to render the view */
  46517. target: HTMLCanvasElement;
  46518. /** Defines an optional camera used to render the view (will use active camera else) */
  46519. camera?: Camera;
  46520. }
  46521. module "babylonjs/Engines/engine" {
  46522. interface Engine {
  46523. /**
  46524. * Gets or sets the HTML element to use for attaching events
  46525. */
  46526. inputElement: Nullable<HTMLElement>;
  46527. /**
  46528. * Gets the current engine view
  46529. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46530. */
  46531. activeView: Nullable<EngineView>;
  46532. /** Gets or sets the list of views */
  46533. views: EngineView[];
  46534. /**
  46535. * Register a new child canvas
  46536. * @param canvas defines the canvas to register
  46537. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46538. * @returns the associated view
  46539. */
  46540. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46541. /**
  46542. * Remove a registered child canvas
  46543. * @param canvas defines the canvas to remove
  46544. * @returns the current engine
  46545. */
  46546. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46547. }
  46548. }
  46549. }
  46550. declare module "babylonjs/Engines/Extensions/index" {
  46551. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46552. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46553. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46554. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46555. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46556. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46557. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46558. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46559. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46560. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46561. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46562. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46563. export * from "babylonjs/Engines/Extensions/engine.views";
  46564. }
  46565. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46566. import { Nullable } from "babylonjs/types";
  46567. /**
  46568. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46569. */
  46570. export interface CubeMapInfo {
  46571. /**
  46572. * The pixel array for the front face.
  46573. * This is stored in format, left to right, up to down format.
  46574. */
  46575. front: Nullable<ArrayBufferView>;
  46576. /**
  46577. * The pixel array for the back face.
  46578. * This is stored in format, left to right, up to down format.
  46579. */
  46580. back: Nullable<ArrayBufferView>;
  46581. /**
  46582. * The pixel array for the left face.
  46583. * This is stored in format, left to right, up to down format.
  46584. */
  46585. left: Nullable<ArrayBufferView>;
  46586. /**
  46587. * The pixel array for the right face.
  46588. * This is stored in format, left to right, up to down format.
  46589. */
  46590. right: Nullable<ArrayBufferView>;
  46591. /**
  46592. * The pixel array for the up face.
  46593. * This is stored in format, left to right, up to down format.
  46594. */
  46595. up: Nullable<ArrayBufferView>;
  46596. /**
  46597. * The pixel array for the down face.
  46598. * This is stored in format, left to right, up to down format.
  46599. */
  46600. down: Nullable<ArrayBufferView>;
  46601. /**
  46602. * The size of the cubemap stored.
  46603. *
  46604. * Each faces will be size * size pixels.
  46605. */
  46606. size: number;
  46607. /**
  46608. * The format of the texture.
  46609. *
  46610. * RGBA, RGB.
  46611. */
  46612. format: number;
  46613. /**
  46614. * The type of the texture data.
  46615. *
  46616. * UNSIGNED_INT, FLOAT.
  46617. */
  46618. type: number;
  46619. /**
  46620. * Specifies whether the texture is in gamma space.
  46621. */
  46622. gammaSpace: boolean;
  46623. }
  46624. /**
  46625. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46626. */
  46627. export class PanoramaToCubeMapTools {
  46628. private static FACE_FRONT;
  46629. private static FACE_BACK;
  46630. private static FACE_RIGHT;
  46631. private static FACE_LEFT;
  46632. private static FACE_DOWN;
  46633. private static FACE_UP;
  46634. /**
  46635. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46636. *
  46637. * @param float32Array The source data.
  46638. * @param inputWidth The width of the input panorama.
  46639. * @param inputHeight The height of the input panorama.
  46640. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46641. * @return The cubemap data
  46642. */
  46643. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46644. private static CreateCubemapTexture;
  46645. private static CalcProjectionSpherical;
  46646. }
  46647. }
  46648. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46649. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46651. import { Nullable } from "babylonjs/types";
  46652. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46653. /**
  46654. * Helper class dealing with the extraction of spherical polynomial dataArray
  46655. * from a cube map.
  46656. */
  46657. export class CubeMapToSphericalPolynomialTools {
  46658. private static FileFaces;
  46659. /**
  46660. * Converts a texture 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 texture The texture to extract the information from.
  46664. * @return The Spherical Polynomial data.
  46665. */
  46666. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46667. /**
  46668. * Converts a cubemap to the according Spherical Polynomial data.
  46669. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46670. *
  46671. * @param cubeInfo The Cube map to extract the information from.
  46672. * @return The Spherical Polynomial data.
  46673. */
  46674. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46675. }
  46676. }
  46677. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46678. import { Nullable } from "babylonjs/types";
  46679. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46680. module "babylonjs/Materials/Textures/baseTexture" {
  46681. interface BaseTexture {
  46682. /**
  46683. * Get the polynomial representation of the texture data.
  46684. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46685. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46686. */
  46687. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46688. }
  46689. }
  46690. }
  46691. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46692. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46693. /** @hidden */
  46694. export var rgbdEncodePixelShader: {
  46695. name: string;
  46696. shader: string;
  46697. };
  46698. }
  46699. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46700. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46701. /** @hidden */
  46702. export var rgbdDecodePixelShader: {
  46703. name: string;
  46704. shader: string;
  46705. };
  46706. }
  46707. declare module "babylonjs/Misc/environmentTextureTools" {
  46708. import { Nullable } from "babylonjs/types";
  46709. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46711. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46712. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46713. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46714. import "babylonjs/Shaders/rgbdEncode.fragment";
  46715. import "babylonjs/Shaders/rgbdDecode.fragment";
  46716. /**
  46717. * Raw texture data and descriptor sufficient for WebGL texture upload
  46718. */
  46719. export interface EnvironmentTextureInfo {
  46720. /**
  46721. * Version of the environment map
  46722. */
  46723. version: number;
  46724. /**
  46725. * Width of image
  46726. */
  46727. width: number;
  46728. /**
  46729. * Irradiance information stored in the file.
  46730. */
  46731. irradiance: any;
  46732. /**
  46733. * Specular information stored in the file.
  46734. */
  46735. specular: any;
  46736. }
  46737. /**
  46738. * Defines One Image in the file. It requires only the position in the file
  46739. * as well as the length.
  46740. */
  46741. interface BufferImageData {
  46742. /**
  46743. * Length of the image data.
  46744. */
  46745. length: number;
  46746. /**
  46747. * Position of the data from the null terminator delimiting the end of the JSON.
  46748. */
  46749. position: number;
  46750. }
  46751. /**
  46752. * Defines the specular data enclosed in the file.
  46753. * This corresponds to the version 1 of the data.
  46754. */
  46755. export interface EnvironmentTextureSpecularInfoV1 {
  46756. /**
  46757. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46758. */
  46759. specularDataPosition?: number;
  46760. /**
  46761. * This contains all the images data needed to reconstruct the cubemap.
  46762. */
  46763. mipmaps: Array<BufferImageData>;
  46764. /**
  46765. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46766. */
  46767. lodGenerationScale: number;
  46768. }
  46769. /**
  46770. * Sets of helpers addressing the serialization and deserialization of environment texture
  46771. * stored in a BabylonJS env file.
  46772. * Those files are usually stored as .env files.
  46773. */
  46774. export class EnvironmentTextureTools {
  46775. /**
  46776. * Magic number identifying the env file.
  46777. */
  46778. private static _MagicBytes;
  46779. /**
  46780. * Gets the environment info from an env file.
  46781. * @param data The array buffer containing the .env bytes.
  46782. * @returns the environment file info (the json header) if successfully parsed.
  46783. */
  46784. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46785. /**
  46786. * Creates an environment texture from a loaded cube texture.
  46787. * @param texture defines the cube texture to convert in env file
  46788. * @return a promise containing the environment data if succesfull.
  46789. */
  46790. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46791. /**
  46792. * Creates a JSON representation of the spherical data.
  46793. * @param texture defines the texture containing the polynomials
  46794. * @return the JSON representation of the spherical info
  46795. */
  46796. private static _CreateEnvTextureIrradiance;
  46797. /**
  46798. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46799. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46800. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46801. * @return the views described by info providing access to the underlying buffer
  46802. */
  46803. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46804. /**
  46805. * Uploads the texture info contained in the env file to the GPU.
  46806. * @param texture defines the internal texture to upload to
  46807. * @param arrayBuffer defines the buffer cotaining the data to load
  46808. * @param info defines the texture info retrieved through the GetEnvInfo method
  46809. * @returns a promise
  46810. */
  46811. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46812. private static _OnImageReadyAsync;
  46813. /**
  46814. * Uploads the levels of image data to the GPU.
  46815. * @param texture defines the internal texture to upload to
  46816. * @param imageData defines the array buffer views of image data [mipmap][face]
  46817. * @returns a promise
  46818. */
  46819. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46820. /**
  46821. * Uploads spherical polynomials information to the texture.
  46822. * @param texture defines the texture we are trying to upload the information to
  46823. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46824. */
  46825. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46826. /** @hidden */
  46827. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46828. }
  46829. }
  46830. declare module "babylonjs/Maths/math.vertexFormat" {
  46831. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46832. /**
  46833. * Contains position and normal vectors for a vertex
  46834. */
  46835. export class PositionNormalVertex {
  46836. /** the position of the vertex (defaut: 0,0,0) */
  46837. position: Vector3;
  46838. /** the normal of the vertex (defaut: 0,1,0) */
  46839. normal: Vector3;
  46840. /**
  46841. * Creates a PositionNormalVertex
  46842. * @param position the position of the vertex (defaut: 0,0,0)
  46843. * @param normal the normal of the vertex (defaut: 0,1,0)
  46844. */
  46845. constructor(
  46846. /** the position of the vertex (defaut: 0,0,0) */
  46847. position?: Vector3,
  46848. /** the normal of the vertex (defaut: 0,1,0) */
  46849. normal?: Vector3);
  46850. /**
  46851. * Clones the PositionNormalVertex
  46852. * @returns the cloned PositionNormalVertex
  46853. */
  46854. clone(): PositionNormalVertex;
  46855. }
  46856. /**
  46857. * Contains position, normal and uv vectors for a vertex
  46858. */
  46859. export class PositionNormalTextureVertex {
  46860. /** the position of the vertex (defaut: 0,0,0) */
  46861. position: Vector3;
  46862. /** the normal of the vertex (defaut: 0,1,0) */
  46863. normal: Vector3;
  46864. /** the uv of the vertex (default: 0,0) */
  46865. uv: Vector2;
  46866. /**
  46867. * Creates a PositionNormalTextureVertex
  46868. * @param position the position of the vertex (defaut: 0,0,0)
  46869. * @param normal the normal of the vertex (defaut: 0,1,0)
  46870. * @param uv the uv of the vertex (default: 0,0)
  46871. */
  46872. constructor(
  46873. /** the position of the vertex (defaut: 0,0,0) */
  46874. position?: Vector3,
  46875. /** the normal of the vertex (defaut: 0,1,0) */
  46876. normal?: Vector3,
  46877. /** the uv of the vertex (default: 0,0) */
  46878. uv?: Vector2);
  46879. /**
  46880. * Clones the PositionNormalTextureVertex
  46881. * @returns the cloned PositionNormalTextureVertex
  46882. */
  46883. clone(): PositionNormalTextureVertex;
  46884. }
  46885. }
  46886. declare module "babylonjs/Maths/math" {
  46887. export * from "babylonjs/Maths/math.axis";
  46888. export * from "babylonjs/Maths/math.color";
  46889. export * from "babylonjs/Maths/math.constants";
  46890. export * from "babylonjs/Maths/math.frustum";
  46891. export * from "babylonjs/Maths/math.path";
  46892. export * from "babylonjs/Maths/math.plane";
  46893. export * from "babylonjs/Maths/math.size";
  46894. export * from "babylonjs/Maths/math.vector";
  46895. export * from "babylonjs/Maths/math.vertexFormat";
  46896. export * from "babylonjs/Maths/math.viewport";
  46897. }
  46898. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46899. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46900. /** @hidden */
  46901. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46902. private _genericAttributeLocation;
  46903. private _varyingLocationCount;
  46904. private _varyingLocationMap;
  46905. private _replacements;
  46906. private _textureCount;
  46907. private _uniforms;
  46908. lineProcessor(line: string): string;
  46909. attributeProcessor(attribute: string): string;
  46910. varyingProcessor(varying: string, isFragment: boolean): string;
  46911. uniformProcessor(uniform: string): string;
  46912. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46913. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46914. }
  46915. }
  46916. declare module "babylonjs/Engines/nativeEngine" {
  46917. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46918. import { Engine } from "babylonjs/Engines/engine";
  46919. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46920. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46922. import { Effect } from "babylonjs/Materials/effect";
  46923. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46924. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46925. import { Scene } from "babylonjs/scene";
  46926. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46927. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46928. /**
  46929. * Container for accessors for natively-stored mesh data buffers.
  46930. */
  46931. class NativeDataBuffer extends DataBuffer {
  46932. /**
  46933. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46934. */
  46935. nativeIndexBuffer?: any;
  46936. /**
  46937. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46938. */
  46939. nativeVertexBuffer?: any;
  46940. }
  46941. /** @hidden */
  46942. class NativeTexture extends InternalTexture {
  46943. getInternalTexture(): InternalTexture;
  46944. getViewCount(): number;
  46945. }
  46946. /** @hidden */
  46947. export class NativeEngine extends Engine {
  46948. private readonly _native;
  46949. getHardwareScalingLevel(): number;
  46950. constructor();
  46951. /**
  46952. * Can be used to override the current requestAnimationFrame requester.
  46953. * @hidden
  46954. */
  46955. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46956. /**
  46957. * Override default engine behavior.
  46958. * @param color
  46959. * @param backBuffer
  46960. * @param depth
  46961. * @param stencil
  46962. */
  46963. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46964. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46965. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46966. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46967. recordVertexArrayObject(vertexBuffers: {
  46968. [key: string]: VertexBuffer;
  46969. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46970. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46971. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46972. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46973. /**
  46974. * Draw a list of indexed primitives
  46975. * @param fillMode defines the primitive to use
  46976. * @param indexStart defines the starting index
  46977. * @param indexCount defines the number of index to draw
  46978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46979. */
  46980. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46981. /**
  46982. * Draw a list of unindexed primitives
  46983. * @param fillMode defines the primitive to use
  46984. * @param verticesStart defines the index of first vertex to draw
  46985. * @param verticesCount defines the count of vertices to draw
  46986. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46987. */
  46988. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46989. createPipelineContext(): IPipelineContext;
  46990. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46991. /** @hidden */
  46992. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46993. /** @hidden */
  46994. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46995. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46996. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46997. protected _setProgram(program: WebGLProgram): void;
  46998. _releaseEffect(effect: Effect): void;
  46999. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47000. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47001. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47002. bindSamplers(effect: Effect): void;
  47003. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47004. getRenderWidth(useScreen?: boolean): number;
  47005. getRenderHeight(useScreen?: boolean): number;
  47006. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47007. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47008. /**
  47009. * Set the z offset to apply to current rendering
  47010. * @param value defines the offset to apply
  47011. */
  47012. setZOffset(value: number): void;
  47013. /**
  47014. * Gets the current value of the zOffset
  47015. * @returns the current zOffset state
  47016. */
  47017. getZOffset(): number;
  47018. /**
  47019. * Enable or disable depth buffering
  47020. * @param enable defines the state to set
  47021. */
  47022. setDepthBuffer(enable: boolean): void;
  47023. /**
  47024. * Gets a boolean indicating if depth writing is enabled
  47025. * @returns the current depth writing state
  47026. */
  47027. getDepthWrite(): boolean;
  47028. /**
  47029. * Enable or disable depth writing
  47030. * @param enable defines the state to set
  47031. */
  47032. setDepthWrite(enable: boolean): void;
  47033. /**
  47034. * Enable or disable color writing
  47035. * @param enable defines the state to set
  47036. */
  47037. setColorWrite(enable: boolean): void;
  47038. /**
  47039. * Gets a boolean indicating if color writing is enabled
  47040. * @returns the current color writing state
  47041. */
  47042. getColorWrite(): boolean;
  47043. /**
  47044. * Sets alpha constants used by some alpha blending modes
  47045. * @param r defines the red component
  47046. * @param g defines the green component
  47047. * @param b defines the blue component
  47048. * @param a defines the alpha component
  47049. */
  47050. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47051. /**
  47052. * Sets the current alpha mode
  47053. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47054. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47055. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47056. */
  47057. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47058. /**
  47059. * Gets the current alpha mode
  47060. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47061. * @returns the current alpha mode
  47062. */
  47063. getAlphaMode(): number;
  47064. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47065. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47066. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47067. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47068. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47069. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47070. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47071. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47072. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47073. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47074. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47075. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47076. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47077. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47078. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47079. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47080. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47081. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47082. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47083. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47084. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47085. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47086. wipeCaches(bruteForce?: boolean): void;
  47087. _createTexture(): WebGLTexture;
  47088. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47089. /**
  47090. * Usually called from BABYLON.Texture.ts.
  47091. * Passed information to create a WebGLTexture
  47092. * @param urlArg defines a value which contains one of the following:
  47093. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47094. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47095. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47096. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47097. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47098. * @param scene needed for loading to the correct scene
  47099. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47100. * @param onLoad optional callback to be called upon successful completion
  47101. * @param onError optional callback to be called upon failure
  47102. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47103. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47104. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47105. * @param forcedExtension defines the extension to use to pick the right loader
  47106. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47107. */
  47108. 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;
  47109. /**
  47110. * Creates a cube texture
  47111. * @param rootUrl defines the url where the files to load is located
  47112. * @param scene defines the current scene
  47113. * @param files defines the list of files to load (1 per face)
  47114. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47115. * @param onLoad defines an optional callback raised when the texture is loaded
  47116. * @param onError defines an optional callback raised if there is an issue to load the texture
  47117. * @param format defines the format of the data
  47118. * @param forcedExtension defines the extension to use to pick the right loader
  47119. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47120. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47121. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47122. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47123. * @returns the cube texture as an InternalTexture
  47124. */
  47125. 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;
  47126. private _getSamplingFilter;
  47127. private static _GetNativeTextureFormat;
  47128. createRenderTargetTexture(size: number | {
  47129. width: number;
  47130. height: number;
  47131. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47132. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47133. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47134. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47135. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47136. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47137. /**
  47138. * Updates a dynamic vertex buffer.
  47139. * @param vertexBuffer the vertex buffer to update
  47140. * @param data the data used to update the vertex buffer
  47141. * @param byteOffset the byte offset of the data (optional)
  47142. * @param byteLength the byte length of the data (optional)
  47143. */
  47144. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47145. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47146. private _updateAnisotropicLevel;
  47147. private _getAddressMode;
  47148. /** @hidden */
  47149. _bindTexture(channel: number, texture: InternalTexture): void;
  47150. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47151. releaseEffects(): void;
  47152. /** @hidden */
  47153. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47154. /** @hidden */
  47155. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47156. /** @hidden */
  47157. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47158. /** @hidden */
  47159. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47160. }
  47161. }
  47162. declare module "babylonjs/Engines/index" {
  47163. export * from "babylonjs/Engines/constants";
  47164. export * from "babylonjs/Engines/engineCapabilities";
  47165. export * from "babylonjs/Engines/instancingAttributeInfo";
  47166. export * from "babylonjs/Engines/thinEngine";
  47167. export * from "babylonjs/Engines/engine";
  47168. export * from "babylonjs/Engines/engineStore";
  47169. export * from "babylonjs/Engines/nullEngine";
  47170. export * from "babylonjs/Engines/Extensions/index";
  47171. export * from "babylonjs/Engines/IPipelineContext";
  47172. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47173. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47174. export * from "babylonjs/Engines/nativeEngine";
  47175. }
  47176. declare module "babylonjs/Events/clipboardEvents" {
  47177. /**
  47178. * Gather the list of clipboard event types as constants.
  47179. */
  47180. export class ClipboardEventTypes {
  47181. /**
  47182. * The clipboard event is fired when a copy command is active (pressed).
  47183. */
  47184. static readonly COPY: number;
  47185. /**
  47186. * The clipboard event is fired when a cut command is active (pressed).
  47187. */
  47188. static readonly CUT: number;
  47189. /**
  47190. * The clipboard event is fired when a paste command is active (pressed).
  47191. */
  47192. static readonly PASTE: number;
  47193. }
  47194. /**
  47195. * This class is used to store clipboard related info for the onClipboardObservable event.
  47196. */
  47197. export class ClipboardInfo {
  47198. /**
  47199. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47200. */
  47201. type: number;
  47202. /**
  47203. * Defines the related dom event
  47204. */
  47205. event: ClipboardEvent;
  47206. /**
  47207. *Creates an instance of ClipboardInfo.
  47208. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47209. * @param event Defines the related dom event
  47210. */
  47211. constructor(
  47212. /**
  47213. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47214. */
  47215. type: number,
  47216. /**
  47217. * Defines the related dom event
  47218. */
  47219. event: ClipboardEvent);
  47220. /**
  47221. * Get the clipboard event's type from the keycode.
  47222. * @param keyCode Defines the keyCode for the current keyboard event.
  47223. * @return {number}
  47224. */
  47225. static GetTypeFromCharacter(keyCode: number): number;
  47226. }
  47227. }
  47228. declare module "babylonjs/Events/index" {
  47229. export * from "babylonjs/Events/keyboardEvents";
  47230. export * from "babylonjs/Events/pointerEvents";
  47231. export * from "babylonjs/Events/clipboardEvents";
  47232. }
  47233. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47234. import { Scene } from "babylonjs/scene";
  47235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47236. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47237. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47238. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47239. /**
  47240. * Google Daydream controller
  47241. */
  47242. export class DaydreamController extends WebVRController {
  47243. /**
  47244. * Base Url for the controller model.
  47245. */
  47246. static MODEL_BASE_URL: string;
  47247. /**
  47248. * File name for the controller model.
  47249. */
  47250. static MODEL_FILENAME: string;
  47251. /**
  47252. * Gamepad Id prefix used to identify Daydream Controller.
  47253. */
  47254. static readonly GAMEPAD_ID_PREFIX: string;
  47255. /**
  47256. * Creates a new DaydreamController from a gamepad
  47257. * @param vrGamepad the gamepad that the controller should be created from
  47258. */
  47259. constructor(vrGamepad: any);
  47260. /**
  47261. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47262. * @param scene scene in which to add meshes
  47263. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47264. */
  47265. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47266. /**
  47267. * Called once for each button that changed state since the last frame
  47268. * @param buttonIdx Which button index changed
  47269. * @param state New state of the button
  47270. * @param changes Which properties on the state changed since last frame
  47271. */
  47272. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47273. }
  47274. }
  47275. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47276. import { Scene } from "babylonjs/scene";
  47277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47278. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47279. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47280. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47281. /**
  47282. * Gear VR Controller
  47283. */
  47284. export class GearVRController extends WebVRController {
  47285. /**
  47286. * Base Url for the controller model.
  47287. */
  47288. static MODEL_BASE_URL: string;
  47289. /**
  47290. * File name for the controller model.
  47291. */
  47292. static MODEL_FILENAME: string;
  47293. /**
  47294. * Gamepad Id prefix used to identify this controller.
  47295. */
  47296. static readonly GAMEPAD_ID_PREFIX: string;
  47297. private readonly _buttonIndexToObservableNameMap;
  47298. /**
  47299. * Creates a new GearVRController from a gamepad
  47300. * @param vrGamepad the gamepad that the controller should be created from
  47301. */
  47302. constructor(vrGamepad: any);
  47303. /**
  47304. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47305. * @param scene scene in which to add meshes
  47306. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47307. */
  47308. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47309. /**
  47310. * Called once for each button that changed state since the last frame
  47311. * @param buttonIdx Which button index changed
  47312. * @param state New state of the button
  47313. * @param changes Which properties on the state changed since last frame
  47314. */
  47315. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47316. }
  47317. }
  47318. declare module "babylonjs/Gamepads/Controllers/index" {
  47319. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47320. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47321. export * from "babylonjs/Gamepads/Controllers/genericController";
  47322. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47323. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47324. export * from "babylonjs/Gamepads/Controllers/viveController";
  47325. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47326. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47327. }
  47328. declare module "babylonjs/Gamepads/index" {
  47329. export * from "babylonjs/Gamepads/Controllers/index";
  47330. export * from "babylonjs/Gamepads/gamepad";
  47331. export * from "babylonjs/Gamepads/gamepadManager";
  47332. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47333. export * from "babylonjs/Gamepads/xboxGamepad";
  47334. export * from "babylonjs/Gamepads/dualShockGamepad";
  47335. }
  47336. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47337. import { Scene } from "babylonjs/scene";
  47338. import { Vector4 } from "babylonjs/Maths/math.vector";
  47339. import { Color4 } from "babylonjs/Maths/math.color";
  47340. import { Mesh } from "babylonjs/Meshes/mesh";
  47341. import { Nullable } from "babylonjs/types";
  47342. /**
  47343. * Class containing static functions to help procedurally build meshes
  47344. */
  47345. export class PolyhedronBuilder {
  47346. /**
  47347. * Creates a polyhedron mesh
  47348. * * 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
  47349. * * The parameter `size` (positive float, default 1) sets the polygon size
  47350. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47351. * * 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`
  47352. * * 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
  47353. * * 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)`)
  47354. * * 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
  47355. * * 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
  47356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47359. * @param name defines the name of the mesh
  47360. * @param options defines the options used to create the mesh
  47361. * @param scene defines the hosting scene
  47362. * @returns the polyhedron mesh
  47363. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47364. */
  47365. static CreatePolyhedron(name: string, options: {
  47366. type?: number;
  47367. size?: number;
  47368. sizeX?: number;
  47369. sizeY?: number;
  47370. sizeZ?: number;
  47371. custom?: any;
  47372. faceUV?: Vector4[];
  47373. faceColors?: Color4[];
  47374. flat?: boolean;
  47375. updatable?: boolean;
  47376. sideOrientation?: number;
  47377. frontUVs?: Vector4;
  47378. backUVs?: Vector4;
  47379. }, scene?: Nullable<Scene>): Mesh;
  47380. }
  47381. }
  47382. declare module "babylonjs/Gizmos/scaleGizmo" {
  47383. import { Observable } from "babylonjs/Misc/observable";
  47384. import { Nullable } from "babylonjs/types";
  47385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47386. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47387. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47388. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47389. /**
  47390. * Gizmo that enables scaling a mesh along 3 axis
  47391. */
  47392. export class ScaleGizmo extends Gizmo {
  47393. /**
  47394. * Internal gizmo used for interactions on the x axis
  47395. */
  47396. xGizmo: AxisScaleGizmo;
  47397. /**
  47398. * Internal gizmo used for interactions on the y axis
  47399. */
  47400. yGizmo: AxisScaleGizmo;
  47401. /**
  47402. * Internal gizmo used for interactions on the z axis
  47403. */
  47404. zGizmo: AxisScaleGizmo;
  47405. /**
  47406. * Internal gizmo used to scale all axis equally
  47407. */
  47408. uniformScaleGizmo: AxisScaleGizmo;
  47409. private _meshAttached;
  47410. private _updateGizmoRotationToMatchAttachedMesh;
  47411. private _snapDistance;
  47412. private _scaleRatio;
  47413. private _uniformScalingMesh;
  47414. private _octahedron;
  47415. /** Fires an event when any of it's sub gizmos are dragged */
  47416. onDragStartObservable: Observable<unknown>;
  47417. /** Fires an event when any of it's sub gizmos are released from dragging */
  47418. onDragEndObservable: Observable<unknown>;
  47419. attachedMesh: Nullable<AbstractMesh>;
  47420. /**
  47421. * Creates a ScaleGizmo
  47422. * @param gizmoLayer The utility layer the gizmo will be added to
  47423. */
  47424. constructor(gizmoLayer?: UtilityLayerRenderer);
  47425. updateGizmoRotationToMatchAttachedMesh: boolean;
  47426. /**
  47427. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47428. */
  47429. snapDistance: number;
  47430. /**
  47431. * Ratio for the scale of the gizmo (Default: 1)
  47432. */
  47433. scaleRatio: number;
  47434. /**
  47435. * Disposes of the gizmo
  47436. */
  47437. dispose(): void;
  47438. }
  47439. }
  47440. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47441. import { Observable } from "babylonjs/Misc/observable";
  47442. import { Nullable } from "babylonjs/types";
  47443. import { Vector3 } from "babylonjs/Maths/math.vector";
  47444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47445. import { Mesh } from "babylonjs/Meshes/mesh";
  47446. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47447. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47448. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47449. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47450. import { Color3 } from "babylonjs/Maths/math.color";
  47451. /**
  47452. * Single axis scale gizmo
  47453. */
  47454. export class AxisScaleGizmo extends Gizmo {
  47455. /**
  47456. * Drag behavior responsible for the gizmos dragging interactions
  47457. */
  47458. dragBehavior: PointerDragBehavior;
  47459. private _pointerObserver;
  47460. /**
  47461. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47462. */
  47463. snapDistance: number;
  47464. /**
  47465. * Event that fires each time the gizmo snaps to a new location.
  47466. * * snapDistance is the the change in distance
  47467. */
  47468. onSnapObservable: Observable<{
  47469. snapDistance: number;
  47470. }>;
  47471. /**
  47472. * If the scaling operation should be done on all axis (default: false)
  47473. */
  47474. uniformScaling: boolean;
  47475. private _isEnabled;
  47476. private _parent;
  47477. private _arrow;
  47478. private _coloredMaterial;
  47479. private _hoverMaterial;
  47480. /**
  47481. * Creates an AxisScaleGizmo
  47482. * @param gizmoLayer The utility layer the gizmo will be added to
  47483. * @param dragAxis The axis which the gizmo will be able to scale on
  47484. * @param color The color of the gizmo
  47485. */
  47486. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47487. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47488. /**
  47489. * If the gizmo is enabled
  47490. */
  47491. isEnabled: boolean;
  47492. /**
  47493. * Disposes of the gizmo
  47494. */
  47495. dispose(): void;
  47496. /**
  47497. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47498. * @param mesh The mesh to replace the default mesh of the gizmo
  47499. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47500. */
  47501. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47502. }
  47503. }
  47504. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47505. import { Observable } from "babylonjs/Misc/observable";
  47506. import { Nullable } from "babylonjs/types";
  47507. import { Vector3 } from "babylonjs/Maths/math.vector";
  47508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47509. import { Mesh } from "babylonjs/Meshes/mesh";
  47510. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47511. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47512. import { Color3 } from "babylonjs/Maths/math.color";
  47513. import "babylonjs/Meshes/Builders/boxBuilder";
  47514. /**
  47515. * Bounding box gizmo
  47516. */
  47517. export class BoundingBoxGizmo extends Gizmo {
  47518. private _lineBoundingBox;
  47519. private _rotateSpheresParent;
  47520. private _scaleBoxesParent;
  47521. private _boundingDimensions;
  47522. private _renderObserver;
  47523. private _pointerObserver;
  47524. private _scaleDragSpeed;
  47525. private _tmpQuaternion;
  47526. private _tmpVector;
  47527. private _tmpRotationMatrix;
  47528. /**
  47529. * 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)
  47530. */
  47531. ignoreChildren: boolean;
  47532. /**
  47533. * 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)
  47534. */
  47535. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47536. /**
  47537. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47538. */
  47539. rotationSphereSize: number;
  47540. /**
  47541. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47542. */
  47543. scaleBoxSize: number;
  47544. /**
  47545. * 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)
  47546. */
  47547. fixedDragMeshScreenSize: boolean;
  47548. /**
  47549. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47550. */
  47551. fixedDragMeshScreenSizeDistanceFactor: number;
  47552. /**
  47553. * Fired when a rotation sphere or scale box is dragged
  47554. */
  47555. onDragStartObservable: Observable<{}>;
  47556. /**
  47557. * Fired when a scale box is dragged
  47558. */
  47559. onScaleBoxDragObservable: Observable<{}>;
  47560. /**
  47561. * Fired when a scale box drag is ended
  47562. */
  47563. onScaleBoxDragEndObservable: Observable<{}>;
  47564. /**
  47565. * Fired when a rotation sphere is dragged
  47566. */
  47567. onRotationSphereDragObservable: Observable<{}>;
  47568. /**
  47569. * Fired when a rotation sphere drag is ended
  47570. */
  47571. onRotationSphereDragEndObservable: Observable<{}>;
  47572. /**
  47573. * 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)
  47574. */
  47575. scalePivot: Nullable<Vector3>;
  47576. /**
  47577. * Mesh used as a pivot to rotate the attached mesh
  47578. */
  47579. private _anchorMesh;
  47580. private _existingMeshScale;
  47581. private _dragMesh;
  47582. private pointerDragBehavior;
  47583. private coloredMaterial;
  47584. private hoverColoredMaterial;
  47585. /**
  47586. * Sets the color of the bounding box gizmo
  47587. * @param color the color to set
  47588. */
  47589. setColor(color: Color3): void;
  47590. /**
  47591. * Creates an BoundingBoxGizmo
  47592. * @param gizmoLayer The utility layer the gizmo will be added to
  47593. * @param color The color of the gizmo
  47594. */
  47595. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47596. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47597. private _selectNode;
  47598. /**
  47599. * Updates the bounding box information for the Gizmo
  47600. */
  47601. updateBoundingBox(): void;
  47602. private _updateRotationSpheres;
  47603. private _updateScaleBoxes;
  47604. /**
  47605. * Enables rotation on the specified axis and disables rotation on the others
  47606. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47607. */
  47608. setEnabledRotationAxis(axis: string): void;
  47609. /**
  47610. * Enables/disables scaling
  47611. * @param enable if scaling should be enabled
  47612. */
  47613. setEnabledScaling(enable: boolean): void;
  47614. private _updateDummy;
  47615. /**
  47616. * Enables a pointer drag behavior on the bounding box of the gizmo
  47617. */
  47618. enableDragBehavior(): void;
  47619. /**
  47620. * Disposes of the gizmo
  47621. */
  47622. dispose(): void;
  47623. /**
  47624. * 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)
  47625. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47626. * @returns the bounding box mesh with the passed in mesh as a child
  47627. */
  47628. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47629. /**
  47630. * CustomMeshes are not supported by this gizmo
  47631. * @param mesh The mesh to replace the default mesh of the gizmo
  47632. */
  47633. setCustomMesh(mesh: Mesh): void;
  47634. }
  47635. }
  47636. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47637. import { Observable } from "babylonjs/Misc/observable";
  47638. import { Nullable } from "babylonjs/types";
  47639. import { Vector3 } from "babylonjs/Maths/math.vector";
  47640. import { Color3 } from "babylonjs/Maths/math.color";
  47641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47642. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47643. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47644. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47645. import "babylonjs/Meshes/Builders/linesBuilder";
  47646. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47647. /**
  47648. * Single plane rotation gizmo
  47649. */
  47650. export class PlaneRotationGizmo extends Gizmo {
  47651. /**
  47652. * Drag behavior responsible for the gizmos dragging interactions
  47653. */
  47654. dragBehavior: PointerDragBehavior;
  47655. private _pointerObserver;
  47656. /**
  47657. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47658. */
  47659. snapDistance: number;
  47660. /**
  47661. * Event that fires each time the gizmo snaps to a new location.
  47662. * * snapDistance is the the change in distance
  47663. */
  47664. onSnapObservable: Observable<{
  47665. snapDistance: number;
  47666. }>;
  47667. private _isEnabled;
  47668. private _parent;
  47669. /**
  47670. * Creates a PlaneRotationGizmo
  47671. * @param gizmoLayer The utility layer the gizmo will be added to
  47672. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47673. * @param color The color of the gizmo
  47674. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47675. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47676. */
  47677. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47678. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47679. /**
  47680. * If the gizmo is enabled
  47681. */
  47682. isEnabled: boolean;
  47683. /**
  47684. * Disposes of the gizmo
  47685. */
  47686. dispose(): void;
  47687. }
  47688. }
  47689. declare module "babylonjs/Gizmos/rotationGizmo" {
  47690. import { Observable } from "babylonjs/Misc/observable";
  47691. import { Nullable } from "babylonjs/types";
  47692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47693. import { Mesh } from "babylonjs/Meshes/mesh";
  47694. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47695. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47696. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47697. /**
  47698. * Gizmo that enables rotating a mesh along 3 axis
  47699. */
  47700. export class RotationGizmo extends Gizmo {
  47701. /**
  47702. * Internal gizmo used for interactions on the x axis
  47703. */
  47704. xGizmo: PlaneRotationGizmo;
  47705. /**
  47706. * Internal gizmo used for interactions on the y axis
  47707. */
  47708. yGizmo: PlaneRotationGizmo;
  47709. /**
  47710. * Internal gizmo used for interactions on the z axis
  47711. */
  47712. zGizmo: PlaneRotationGizmo;
  47713. /** Fires an event when any of it's sub gizmos are dragged */
  47714. onDragStartObservable: Observable<unknown>;
  47715. /** Fires an event when any of it's sub gizmos are released from dragging */
  47716. onDragEndObservable: Observable<unknown>;
  47717. private _meshAttached;
  47718. attachedMesh: Nullable<AbstractMesh>;
  47719. /**
  47720. * Creates a RotationGizmo
  47721. * @param gizmoLayer The utility layer the gizmo will be added to
  47722. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47723. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47724. */
  47725. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47726. updateGizmoRotationToMatchAttachedMesh: boolean;
  47727. /**
  47728. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47729. */
  47730. snapDistance: number;
  47731. /**
  47732. * Ratio for the scale of the gizmo (Default: 1)
  47733. */
  47734. scaleRatio: number;
  47735. /**
  47736. * Disposes of the gizmo
  47737. */
  47738. dispose(): void;
  47739. /**
  47740. * CustomMeshes are not supported by this gizmo
  47741. * @param mesh The mesh to replace the default mesh of the gizmo
  47742. */
  47743. setCustomMesh(mesh: Mesh): void;
  47744. }
  47745. }
  47746. declare module "babylonjs/Gizmos/gizmoManager" {
  47747. import { Observable } from "babylonjs/Misc/observable";
  47748. import { Nullable } from "babylonjs/types";
  47749. import { Scene, IDisposable } from "babylonjs/scene";
  47750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47751. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47752. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47753. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47754. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47755. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47756. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47757. /**
  47758. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47759. */
  47760. export class GizmoManager implements IDisposable {
  47761. private scene;
  47762. /**
  47763. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47764. */
  47765. gizmos: {
  47766. positionGizmo: Nullable<PositionGizmo>;
  47767. rotationGizmo: Nullable<RotationGizmo>;
  47768. scaleGizmo: Nullable<ScaleGizmo>;
  47769. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47770. };
  47771. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47772. clearGizmoOnEmptyPointerEvent: boolean;
  47773. /** Fires an event when the manager is attached to a mesh */
  47774. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47775. private _gizmosEnabled;
  47776. private _pointerObserver;
  47777. private _attachedMesh;
  47778. private _boundingBoxColor;
  47779. private _defaultUtilityLayer;
  47780. private _defaultKeepDepthUtilityLayer;
  47781. /**
  47782. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47783. */
  47784. boundingBoxDragBehavior: SixDofDragBehavior;
  47785. /**
  47786. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47787. */
  47788. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47789. /**
  47790. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47791. */
  47792. usePointerToAttachGizmos: boolean;
  47793. /**
  47794. * Utility layer that the bounding box gizmo belongs to
  47795. */
  47796. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47797. /**
  47798. * Utility layer that all gizmos besides bounding box belong to
  47799. */
  47800. readonly utilityLayer: UtilityLayerRenderer;
  47801. /**
  47802. * Instatiates a gizmo manager
  47803. * @param scene the scene to overlay the gizmos on top of
  47804. */
  47805. constructor(scene: Scene);
  47806. /**
  47807. * Attaches a set of gizmos to the specified mesh
  47808. * @param mesh The mesh the gizmo's should be attached to
  47809. */
  47810. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47811. /**
  47812. * If the position gizmo is enabled
  47813. */
  47814. positionGizmoEnabled: boolean;
  47815. /**
  47816. * If the rotation gizmo is enabled
  47817. */
  47818. rotationGizmoEnabled: boolean;
  47819. /**
  47820. * If the scale gizmo is enabled
  47821. */
  47822. scaleGizmoEnabled: boolean;
  47823. /**
  47824. * If the boundingBox gizmo is enabled
  47825. */
  47826. boundingBoxGizmoEnabled: boolean;
  47827. /**
  47828. * Disposes of the gizmo manager
  47829. */
  47830. dispose(): void;
  47831. }
  47832. }
  47833. declare module "babylonjs/Lights/directionalLight" {
  47834. import { Camera } from "babylonjs/Cameras/camera";
  47835. import { Scene } from "babylonjs/scene";
  47836. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47838. import { Light } from "babylonjs/Lights/light";
  47839. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47840. import { Effect } from "babylonjs/Materials/effect";
  47841. /**
  47842. * A directional light is defined by a direction (what a surprise!).
  47843. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47844. * 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.
  47845. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47846. */
  47847. export class DirectionalLight extends ShadowLight {
  47848. private _shadowFrustumSize;
  47849. /**
  47850. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47851. */
  47852. /**
  47853. * Specifies a fix frustum size for the shadow generation.
  47854. */
  47855. shadowFrustumSize: number;
  47856. private _shadowOrthoScale;
  47857. /**
  47858. * Gets the shadow projection scale against the optimal computed one.
  47859. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47860. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47861. */
  47862. /**
  47863. * Sets the shadow projection scale against the optimal computed one.
  47864. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47865. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47866. */
  47867. shadowOrthoScale: number;
  47868. /**
  47869. * Automatically compute the projection matrix to best fit (including all the casters)
  47870. * on each frame.
  47871. */
  47872. autoUpdateExtends: boolean;
  47873. private _orthoLeft;
  47874. private _orthoRight;
  47875. private _orthoTop;
  47876. private _orthoBottom;
  47877. /**
  47878. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47879. * The directional light is emitted from everywhere in the given direction.
  47880. * It can cast shadows.
  47881. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47882. * @param name The friendly name of the light
  47883. * @param direction The direction of the light
  47884. * @param scene The scene the light belongs to
  47885. */
  47886. constructor(name: string, direction: Vector3, scene: Scene);
  47887. /**
  47888. * Returns the string "DirectionalLight".
  47889. * @return The class name
  47890. */
  47891. getClassName(): string;
  47892. /**
  47893. * Returns the integer 1.
  47894. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47895. */
  47896. getTypeID(): number;
  47897. /**
  47898. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47899. * Returns the DirectionalLight Shadow projection matrix.
  47900. */
  47901. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47902. /**
  47903. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47904. * Returns the DirectionalLight Shadow projection matrix.
  47905. */
  47906. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47907. /**
  47908. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47909. * Returns the DirectionalLight Shadow projection matrix.
  47910. */
  47911. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47912. protected _buildUniformLayout(): void;
  47913. /**
  47914. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47915. * @param effect The effect to update
  47916. * @param lightIndex The index of the light in the effect to update
  47917. * @returns The directional light
  47918. */
  47919. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47920. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47921. /**
  47922. * Gets the minZ used for shadow according to both the scene and the light.
  47923. *
  47924. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47925. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47926. * @param activeCamera The camera we are returning the min for
  47927. * @returns the depth min z
  47928. */
  47929. getDepthMinZ(activeCamera: Camera): number;
  47930. /**
  47931. * Gets the maxZ used for shadow according to both the scene and the light.
  47932. *
  47933. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47934. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47935. * @param activeCamera The camera we are returning the max for
  47936. * @returns the depth max z
  47937. */
  47938. getDepthMaxZ(activeCamera: Camera): number;
  47939. /**
  47940. * Prepares the list of defines specific to the light type.
  47941. * @param defines the list of defines
  47942. * @param lightIndex defines the index of the light for the effect
  47943. */
  47944. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47945. }
  47946. }
  47947. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47948. import { Mesh } from "babylonjs/Meshes/mesh";
  47949. /**
  47950. * Class containing static functions to help procedurally build meshes
  47951. */
  47952. export class HemisphereBuilder {
  47953. /**
  47954. * Creates a hemisphere mesh
  47955. * @param name defines the name of the mesh
  47956. * @param options defines the options used to create the mesh
  47957. * @param scene defines the hosting scene
  47958. * @returns the hemisphere mesh
  47959. */
  47960. static CreateHemisphere(name: string, options: {
  47961. segments?: number;
  47962. diameter?: number;
  47963. sideOrientation?: number;
  47964. }, scene: any): Mesh;
  47965. }
  47966. }
  47967. declare module "babylonjs/Lights/spotLight" {
  47968. import { Nullable } from "babylonjs/types";
  47969. import { Scene } from "babylonjs/scene";
  47970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47972. import { Effect } from "babylonjs/Materials/effect";
  47973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47974. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47975. /**
  47976. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47977. * These values define a cone of light starting from the position, emitting toward the direction.
  47978. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47979. * and the exponent defines the speed of the decay of the light with distance (reach).
  47980. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47981. */
  47982. export class SpotLight extends ShadowLight {
  47983. private _angle;
  47984. private _innerAngle;
  47985. private _cosHalfAngle;
  47986. private _lightAngleScale;
  47987. private _lightAngleOffset;
  47988. /**
  47989. * Gets the cone angle of the spot light in Radians.
  47990. */
  47991. /**
  47992. * Sets the cone angle of the spot light in Radians.
  47993. */
  47994. angle: number;
  47995. /**
  47996. * Only used in gltf falloff mode, this defines the angle where
  47997. * the directional falloff will start before cutting at angle which could be seen
  47998. * as outer angle.
  47999. */
  48000. /**
  48001. * Only used in gltf falloff mode, this defines the angle where
  48002. * the directional falloff will start before cutting at angle which could be seen
  48003. * as outer angle.
  48004. */
  48005. innerAngle: number;
  48006. private _shadowAngleScale;
  48007. /**
  48008. * Allows scaling the angle of the light for shadow generation only.
  48009. */
  48010. /**
  48011. * Allows scaling the angle of the light for shadow generation only.
  48012. */
  48013. shadowAngleScale: number;
  48014. /**
  48015. * The light decay speed with the distance from the emission spot.
  48016. */
  48017. exponent: number;
  48018. private _projectionTextureMatrix;
  48019. /**
  48020. * Allows reading the projecton texture
  48021. */
  48022. readonly projectionTextureMatrix: Matrix;
  48023. protected _projectionTextureLightNear: number;
  48024. /**
  48025. * Gets the near clip of the Spotlight for texture projection.
  48026. */
  48027. /**
  48028. * Sets the near clip of the Spotlight for texture projection.
  48029. */
  48030. projectionTextureLightNear: number;
  48031. protected _projectionTextureLightFar: number;
  48032. /**
  48033. * Gets the far clip of the Spotlight for texture projection.
  48034. */
  48035. /**
  48036. * Sets the far clip of the Spotlight for texture projection.
  48037. */
  48038. projectionTextureLightFar: number;
  48039. protected _projectionTextureUpDirection: Vector3;
  48040. /**
  48041. * Gets the Up vector of the Spotlight for texture projection.
  48042. */
  48043. /**
  48044. * Sets the Up vector of the Spotlight for texture projection.
  48045. */
  48046. projectionTextureUpDirection: Vector3;
  48047. private _projectionTexture;
  48048. /**
  48049. * Gets the projection texture of the light.
  48050. */
  48051. /**
  48052. * Sets the projection texture of the light.
  48053. */
  48054. projectionTexture: Nullable<BaseTexture>;
  48055. private _projectionTextureViewLightDirty;
  48056. private _projectionTextureProjectionLightDirty;
  48057. private _projectionTextureDirty;
  48058. private _projectionTextureViewTargetVector;
  48059. private _projectionTextureViewLightMatrix;
  48060. private _projectionTextureProjectionLightMatrix;
  48061. private _projectionTextureScalingMatrix;
  48062. /**
  48063. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48064. * It can cast shadows.
  48065. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48066. * @param name The light friendly name
  48067. * @param position The position of the spot light in the scene
  48068. * @param direction The direction of the light in the scene
  48069. * @param angle The cone angle of the light in Radians
  48070. * @param exponent The light decay speed with the distance from the emission spot
  48071. * @param scene The scene the lights belongs to
  48072. */
  48073. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48074. /**
  48075. * Returns the string "SpotLight".
  48076. * @returns the class name
  48077. */
  48078. getClassName(): string;
  48079. /**
  48080. * Returns the integer 2.
  48081. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48082. */
  48083. getTypeID(): number;
  48084. /**
  48085. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48086. */
  48087. protected _setDirection(value: Vector3): void;
  48088. /**
  48089. * Overrides the position setter to recompute the projection texture view light Matrix.
  48090. */
  48091. protected _setPosition(value: Vector3): void;
  48092. /**
  48093. * 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.
  48094. * Returns the SpotLight.
  48095. */
  48096. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48097. protected _computeProjectionTextureViewLightMatrix(): void;
  48098. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48099. /**
  48100. * Main function for light texture projection matrix computing.
  48101. */
  48102. protected _computeProjectionTextureMatrix(): void;
  48103. protected _buildUniformLayout(): void;
  48104. private _computeAngleValues;
  48105. /**
  48106. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48107. * @param effect The effect to update
  48108. * @param lightIndex The index of the light in the effect to update
  48109. * @returns The spot light
  48110. */
  48111. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48112. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48113. /**
  48114. * Disposes the light and the associated resources.
  48115. */
  48116. dispose(): void;
  48117. /**
  48118. * Prepares the list of defines specific to the light type.
  48119. * @param defines the list of defines
  48120. * @param lightIndex defines the index of the light for the effect
  48121. */
  48122. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48123. }
  48124. }
  48125. declare module "babylonjs/Gizmos/lightGizmo" {
  48126. import { Nullable } from "babylonjs/types";
  48127. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48128. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48129. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48130. import { Light } from "babylonjs/Lights/light";
  48131. /**
  48132. * Gizmo that enables viewing a light
  48133. */
  48134. export class LightGizmo extends Gizmo {
  48135. private _lightMesh;
  48136. private _material;
  48137. private cachedPosition;
  48138. private cachedForward;
  48139. /**
  48140. * Creates a LightGizmo
  48141. * @param gizmoLayer The utility layer the gizmo will be added to
  48142. */
  48143. constructor(gizmoLayer?: UtilityLayerRenderer);
  48144. private _light;
  48145. /**
  48146. * The light that the gizmo is attached to
  48147. */
  48148. light: Nullable<Light>;
  48149. /**
  48150. * Gets the material used to render the light gizmo
  48151. */
  48152. readonly material: StandardMaterial;
  48153. /**
  48154. * @hidden
  48155. * Updates the gizmo to match the attached mesh's position/rotation
  48156. */
  48157. protected _update(): void;
  48158. private static _Scale;
  48159. /**
  48160. * Creates the lines for a light mesh
  48161. */
  48162. private static _createLightLines;
  48163. /**
  48164. * Disposes of the light gizmo
  48165. */
  48166. dispose(): void;
  48167. private static _CreateHemisphericLightMesh;
  48168. private static _CreatePointLightMesh;
  48169. private static _CreateSpotLightMesh;
  48170. private static _CreateDirectionalLightMesh;
  48171. }
  48172. }
  48173. declare module "babylonjs/Gizmos/index" {
  48174. export * from "babylonjs/Gizmos/axisDragGizmo";
  48175. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48176. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48177. export * from "babylonjs/Gizmos/gizmo";
  48178. export * from "babylonjs/Gizmos/gizmoManager";
  48179. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48180. export * from "babylonjs/Gizmos/positionGizmo";
  48181. export * from "babylonjs/Gizmos/rotationGizmo";
  48182. export * from "babylonjs/Gizmos/scaleGizmo";
  48183. export * from "babylonjs/Gizmos/lightGizmo";
  48184. export * from "babylonjs/Gizmos/planeDragGizmo";
  48185. }
  48186. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48187. /** @hidden */
  48188. export var backgroundFragmentDeclaration: {
  48189. name: string;
  48190. shader: string;
  48191. };
  48192. }
  48193. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48194. /** @hidden */
  48195. export var backgroundUboDeclaration: {
  48196. name: string;
  48197. shader: string;
  48198. };
  48199. }
  48200. declare module "babylonjs/Shaders/background.fragment" {
  48201. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48202. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48203. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48204. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48205. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48206. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48207. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48208. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48209. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48210. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48211. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48212. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48213. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48214. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48215. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48216. /** @hidden */
  48217. export var backgroundPixelShader: {
  48218. name: string;
  48219. shader: string;
  48220. };
  48221. }
  48222. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48223. /** @hidden */
  48224. export var backgroundVertexDeclaration: {
  48225. name: string;
  48226. shader: string;
  48227. };
  48228. }
  48229. declare module "babylonjs/Shaders/background.vertex" {
  48230. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48231. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48232. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48233. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48234. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48235. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48236. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48237. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48238. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48239. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48240. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48241. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48242. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48243. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48244. /** @hidden */
  48245. export var backgroundVertexShader: {
  48246. name: string;
  48247. shader: string;
  48248. };
  48249. }
  48250. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48251. import { Nullable, int, float } from "babylonjs/types";
  48252. import { Scene } from "babylonjs/scene";
  48253. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48254. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48256. import { Mesh } from "babylonjs/Meshes/mesh";
  48257. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48258. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48259. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48260. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48261. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48262. import { Color3 } from "babylonjs/Maths/math.color";
  48263. import "babylonjs/Shaders/background.fragment";
  48264. import "babylonjs/Shaders/background.vertex";
  48265. /**
  48266. * Background material used to create an efficient environement around your scene.
  48267. */
  48268. export class BackgroundMaterial extends PushMaterial {
  48269. /**
  48270. * Standard reflectance value at parallel view angle.
  48271. */
  48272. static StandardReflectance0: number;
  48273. /**
  48274. * Standard reflectance value at grazing angle.
  48275. */
  48276. static StandardReflectance90: number;
  48277. protected _primaryColor: Color3;
  48278. /**
  48279. * Key light Color (multiply against the environement texture)
  48280. */
  48281. primaryColor: Color3;
  48282. protected __perceptualColor: Nullable<Color3>;
  48283. /**
  48284. * Experimental Internal Use Only.
  48285. *
  48286. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48287. * This acts as a helper to set the primary color to a more "human friendly" value.
  48288. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48289. * output color as close as possible from the chosen value.
  48290. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48291. * part of lighting setup.)
  48292. */
  48293. _perceptualColor: Nullable<Color3>;
  48294. protected _primaryColorShadowLevel: float;
  48295. /**
  48296. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48297. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48298. */
  48299. primaryColorShadowLevel: float;
  48300. protected _primaryColorHighlightLevel: float;
  48301. /**
  48302. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48303. * The primary color is used at the level chosen to define what the white area would look.
  48304. */
  48305. primaryColorHighlightLevel: float;
  48306. protected _reflectionTexture: Nullable<BaseTexture>;
  48307. /**
  48308. * Reflection Texture used in the material.
  48309. * Should be author in a specific way for the best result (refer to the documentation).
  48310. */
  48311. reflectionTexture: Nullable<BaseTexture>;
  48312. protected _reflectionBlur: float;
  48313. /**
  48314. * Reflection Texture level of blur.
  48315. *
  48316. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48317. * texture twice.
  48318. */
  48319. reflectionBlur: float;
  48320. protected _diffuseTexture: Nullable<BaseTexture>;
  48321. /**
  48322. * Diffuse Texture used in the material.
  48323. * Should be author in a specific way for the best result (refer to the documentation).
  48324. */
  48325. diffuseTexture: Nullable<BaseTexture>;
  48326. protected _shadowLights: Nullable<IShadowLight[]>;
  48327. /**
  48328. * Specify the list of lights casting shadow on the material.
  48329. * All scene shadow lights will be included if null.
  48330. */
  48331. shadowLights: Nullable<IShadowLight[]>;
  48332. protected _shadowLevel: float;
  48333. /**
  48334. * Helps adjusting the shadow to a softer level if required.
  48335. * 0 means black shadows and 1 means no shadows.
  48336. */
  48337. shadowLevel: float;
  48338. protected _sceneCenter: Vector3;
  48339. /**
  48340. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48341. * It is usually zero but might be interesting to modify according to your setup.
  48342. */
  48343. sceneCenter: Vector3;
  48344. protected _opacityFresnel: boolean;
  48345. /**
  48346. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48347. * This helps ensuring a nice transition when the camera goes under the ground.
  48348. */
  48349. opacityFresnel: boolean;
  48350. protected _reflectionFresnel: boolean;
  48351. /**
  48352. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48353. * This helps adding a mirror texture on the ground.
  48354. */
  48355. reflectionFresnel: boolean;
  48356. protected _reflectionFalloffDistance: number;
  48357. /**
  48358. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48359. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48360. */
  48361. reflectionFalloffDistance: number;
  48362. protected _reflectionAmount: number;
  48363. /**
  48364. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48365. */
  48366. reflectionAmount: number;
  48367. protected _reflectionReflectance0: number;
  48368. /**
  48369. * This specifies the weight of the reflection at grazing angle.
  48370. */
  48371. reflectionReflectance0: number;
  48372. protected _reflectionReflectance90: number;
  48373. /**
  48374. * This specifies the weight of the reflection at a perpendicular point of view.
  48375. */
  48376. reflectionReflectance90: number;
  48377. /**
  48378. * Sets the reflection reflectance fresnel values according to the default standard
  48379. * empirically know to work well :-)
  48380. */
  48381. reflectionStandardFresnelWeight: number;
  48382. protected _useRGBColor: boolean;
  48383. /**
  48384. * Helps to directly use the maps channels instead of their level.
  48385. */
  48386. useRGBColor: boolean;
  48387. protected _enableNoise: boolean;
  48388. /**
  48389. * This helps reducing the banding effect that could occur on the background.
  48390. */
  48391. enableNoise: boolean;
  48392. /**
  48393. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48394. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48395. * Recommended to be keep at 1.0 except for special cases.
  48396. */
  48397. fovMultiplier: number;
  48398. private _fovMultiplier;
  48399. /**
  48400. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48401. */
  48402. useEquirectangularFOV: boolean;
  48403. private _maxSimultaneousLights;
  48404. /**
  48405. * Number of Simultaneous lights allowed on the material.
  48406. */
  48407. maxSimultaneousLights: int;
  48408. /**
  48409. * Default configuration related to image processing available in the Background Material.
  48410. */
  48411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48412. /**
  48413. * Keep track of the image processing observer to allow dispose and replace.
  48414. */
  48415. private _imageProcessingObserver;
  48416. /**
  48417. * Attaches a new image processing configuration to the PBR Material.
  48418. * @param configuration (if null the scene configuration will be use)
  48419. */
  48420. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48421. /**
  48422. * Gets the image processing configuration used either in this material.
  48423. */
  48424. /**
  48425. * Sets the Default image processing configuration used either in the this material.
  48426. *
  48427. * If sets to null, the scene one is in use.
  48428. */
  48429. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48430. /**
  48431. * Gets wether the color curves effect is enabled.
  48432. */
  48433. /**
  48434. * Sets wether the color curves effect is enabled.
  48435. */
  48436. cameraColorCurvesEnabled: boolean;
  48437. /**
  48438. * Gets wether the color grading effect is enabled.
  48439. */
  48440. /**
  48441. * Gets wether the color grading effect is enabled.
  48442. */
  48443. cameraColorGradingEnabled: boolean;
  48444. /**
  48445. * Gets wether tonemapping is enabled or not.
  48446. */
  48447. /**
  48448. * Sets wether tonemapping is enabled or not
  48449. */
  48450. cameraToneMappingEnabled: boolean;
  48451. /**
  48452. * The camera exposure used on this material.
  48453. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48454. * This corresponds to a photographic exposure.
  48455. */
  48456. /**
  48457. * The camera exposure used on this material.
  48458. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48459. * This corresponds to a photographic exposure.
  48460. */
  48461. cameraExposure: float;
  48462. /**
  48463. * Gets The camera contrast used on this material.
  48464. */
  48465. /**
  48466. * Sets The camera contrast used on this material.
  48467. */
  48468. cameraContrast: float;
  48469. /**
  48470. * Gets the Color Grading 2D Lookup Texture.
  48471. */
  48472. /**
  48473. * Sets the Color Grading 2D Lookup Texture.
  48474. */
  48475. cameraColorGradingTexture: Nullable<BaseTexture>;
  48476. /**
  48477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48479. * 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;
  48480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48481. */
  48482. /**
  48483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48485. * 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;
  48486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48487. */
  48488. cameraColorCurves: Nullable<ColorCurves>;
  48489. /**
  48490. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48491. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48492. */
  48493. switchToBGR: boolean;
  48494. private _renderTargets;
  48495. private _reflectionControls;
  48496. private _white;
  48497. private _primaryShadowColor;
  48498. private _primaryHighlightColor;
  48499. /**
  48500. * Instantiates a Background Material in the given scene
  48501. * @param name The friendly name of the material
  48502. * @param scene The scene to add the material to
  48503. */
  48504. constructor(name: string, scene: Scene);
  48505. /**
  48506. * Gets a boolean indicating that current material needs to register RTT
  48507. */
  48508. readonly hasRenderTargetTextures: boolean;
  48509. /**
  48510. * The entire material has been created in order to prevent overdraw.
  48511. * @returns false
  48512. */
  48513. needAlphaTesting(): boolean;
  48514. /**
  48515. * The entire material has been created in order to prevent overdraw.
  48516. * @returns true if blending is enable
  48517. */
  48518. needAlphaBlending(): boolean;
  48519. /**
  48520. * Checks wether the material is ready to be rendered for a given mesh.
  48521. * @param mesh The mesh to render
  48522. * @param subMesh The submesh to check against
  48523. * @param useInstances Specify wether or not the material is used with instances
  48524. * @returns true if all the dependencies are ready (Textures, Effects...)
  48525. */
  48526. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48527. /**
  48528. * Compute the primary color according to the chosen perceptual color.
  48529. */
  48530. private _computePrimaryColorFromPerceptualColor;
  48531. /**
  48532. * Compute the highlights and shadow colors according to their chosen levels.
  48533. */
  48534. private _computePrimaryColors;
  48535. /**
  48536. * Build the uniform buffer used in the material.
  48537. */
  48538. buildUniformLayout(): void;
  48539. /**
  48540. * Unbind the material.
  48541. */
  48542. unbind(): void;
  48543. /**
  48544. * Bind only the world matrix to the material.
  48545. * @param world The world matrix to bind.
  48546. */
  48547. bindOnlyWorldMatrix(world: Matrix): void;
  48548. /**
  48549. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48550. * @param world The world matrix to bind.
  48551. * @param subMesh The submesh to bind for.
  48552. */
  48553. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48554. /**
  48555. * Checks to see if a texture is used in the material.
  48556. * @param texture - Base texture to use.
  48557. * @returns - Boolean specifying if a texture is used in the material.
  48558. */
  48559. hasTexture(texture: BaseTexture): boolean;
  48560. /**
  48561. * Dispose the material.
  48562. * @param forceDisposeEffect Force disposal of the associated effect.
  48563. * @param forceDisposeTextures Force disposal of the associated textures.
  48564. */
  48565. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48566. /**
  48567. * Clones the material.
  48568. * @param name The cloned name.
  48569. * @returns The cloned material.
  48570. */
  48571. clone(name: string): BackgroundMaterial;
  48572. /**
  48573. * Serializes the current material to its JSON representation.
  48574. * @returns The JSON representation.
  48575. */
  48576. serialize(): any;
  48577. /**
  48578. * Gets the class name of the material
  48579. * @returns "BackgroundMaterial"
  48580. */
  48581. getClassName(): string;
  48582. /**
  48583. * Parse a JSON input to create back a background material.
  48584. * @param source The JSON data to parse
  48585. * @param scene The scene to create the parsed material in
  48586. * @param rootUrl The root url of the assets the material depends upon
  48587. * @returns the instantiated BackgroundMaterial.
  48588. */
  48589. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48590. }
  48591. }
  48592. declare module "babylonjs/Helpers/environmentHelper" {
  48593. import { Observable } from "babylonjs/Misc/observable";
  48594. import { Nullable } from "babylonjs/types";
  48595. import { Scene } from "babylonjs/scene";
  48596. import { Vector3 } from "babylonjs/Maths/math.vector";
  48597. import { Color3 } from "babylonjs/Maths/math.color";
  48598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48599. import { Mesh } from "babylonjs/Meshes/mesh";
  48600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48601. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48602. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48603. import "babylonjs/Meshes/Builders/planeBuilder";
  48604. import "babylonjs/Meshes/Builders/boxBuilder";
  48605. /**
  48606. * Represents the different options available during the creation of
  48607. * a Environment helper.
  48608. *
  48609. * This can control the default ground, skybox and image processing setup of your scene.
  48610. */
  48611. export interface IEnvironmentHelperOptions {
  48612. /**
  48613. * Specifies wether or not to create a ground.
  48614. * True by default.
  48615. */
  48616. createGround: boolean;
  48617. /**
  48618. * Specifies the ground size.
  48619. * 15 by default.
  48620. */
  48621. groundSize: number;
  48622. /**
  48623. * The texture used on the ground for the main color.
  48624. * Comes from the BabylonJS CDN by default.
  48625. *
  48626. * Remarks: Can be either a texture or a url.
  48627. */
  48628. groundTexture: string | BaseTexture;
  48629. /**
  48630. * The color mixed in the ground texture by default.
  48631. * BabylonJS clearColor by default.
  48632. */
  48633. groundColor: Color3;
  48634. /**
  48635. * Specifies the ground opacity.
  48636. * 1 by default.
  48637. */
  48638. groundOpacity: number;
  48639. /**
  48640. * Enables the ground to receive shadows.
  48641. * True by default.
  48642. */
  48643. enableGroundShadow: boolean;
  48644. /**
  48645. * Helps preventing the shadow to be fully black on the ground.
  48646. * 0.5 by default.
  48647. */
  48648. groundShadowLevel: number;
  48649. /**
  48650. * Creates a mirror texture attach to the ground.
  48651. * false by default.
  48652. */
  48653. enableGroundMirror: boolean;
  48654. /**
  48655. * Specifies the ground mirror size ratio.
  48656. * 0.3 by default as the default kernel is 64.
  48657. */
  48658. groundMirrorSizeRatio: number;
  48659. /**
  48660. * Specifies the ground mirror blur kernel size.
  48661. * 64 by default.
  48662. */
  48663. groundMirrorBlurKernel: number;
  48664. /**
  48665. * Specifies the ground mirror visibility amount.
  48666. * 1 by default
  48667. */
  48668. groundMirrorAmount: number;
  48669. /**
  48670. * Specifies the ground mirror reflectance weight.
  48671. * This uses the standard weight of the background material to setup the fresnel effect
  48672. * of the mirror.
  48673. * 1 by default.
  48674. */
  48675. groundMirrorFresnelWeight: number;
  48676. /**
  48677. * Specifies the ground mirror Falloff distance.
  48678. * This can helps reducing the size of the reflection.
  48679. * 0 by Default.
  48680. */
  48681. groundMirrorFallOffDistance: number;
  48682. /**
  48683. * Specifies the ground mirror texture type.
  48684. * Unsigned Int by Default.
  48685. */
  48686. groundMirrorTextureType: number;
  48687. /**
  48688. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48689. * the shown objects.
  48690. */
  48691. groundYBias: number;
  48692. /**
  48693. * Specifies wether or not to create a skybox.
  48694. * True by default.
  48695. */
  48696. createSkybox: boolean;
  48697. /**
  48698. * Specifies the skybox size.
  48699. * 20 by default.
  48700. */
  48701. skyboxSize: number;
  48702. /**
  48703. * The texture used on the skybox for the main color.
  48704. * Comes from the BabylonJS CDN by default.
  48705. *
  48706. * Remarks: Can be either a texture or a url.
  48707. */
  48708. skyboxTexture: string | BaseTexture;
  48709. /**
  48710. * The color mixed in the skybox texture by default.
  48711. * BabylonJS clearColor by default.
  48712. */
  48713. skyboxColor: Color3;
  48714. /**
  48715. * The background rotation around the Y axis of the scene.
  48716. * This helps aligning the key lights of your scene with the background.
  48717. * 0 by default.
  48718. */
  48719. backgroundYRotation: number;
  48720. /**
  48721. * Compute automatically the size of the elements to best fit with the scene.
  48722. */
  48723. sizeAuto: boolean;
  48724. /**
  48725. * Default position of the rootMesh if autoSize is not true.
  48726. */
  48727. rootPosition: Vector3;
  48728. /**
  48729. * Sets up the image processing in the scene.
  48730. * true by default.
  48731. */
  48732. setupImageProcessing: boolean;
  48733. /**
  48734. * The texture used as your environment texture in the scene.
  48735. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48736. *
  48737. * Remarks: Can be either a texture or a url.
  48738. */
  48739. environmentTexture: string | BaseTexture;
  48740. /**
  48741. * The value of the exposure to apply to the scene.
  48742. * 0.6 by default if setupImageProcessing is true.
  48743. */
  48744. cameraExposure: number;
  48745. /**
  48746. * The value of the contrast to apply to the scene.
  48747. * 1.6 by default if setupImageProcessing is true.
  48748. */
  48749. cameraContrast: number;
  48750. /**
  48751. * Specifies wether or not tonemapping should be enabled in the scene.
  48752. * true by default if setupImageProcessing is true.
  48753. */
  48754. toneMappingEnabled: boolean;
  48755. }
  48756. /**
  48757. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48758. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48759. * It also helps with the default setup of your imageProcessing configuration.
  48760. */
  48761. export class EnvironmentHelper {
  48762. /**
  48763. * Default ground texture URL.
  48764. */
  48765. private static _groundTextureCDNUrl;
  48766. /**
  48767. * Default skybox texture URL.
  48768. */
  48769. private static _skyboxTextureCDNUrl;
  48770. /**
  48771. * Default environment texture URL.
  48772. */
  48773. private static _environmentTextureCDNUrl;
  48774. /**
  48775. * Creates the default options for the helper.
  48776. */
  48777. private static _getDefaultOptions;
  48778. private _rootMesh;
  48779. /**
  48780. * Gets the root mesh created by the helper.
  48781. */
  48782. readonly rootMesh: Mesh;
  48783. private _skybox;
  48784. /**
  48785. * Gets the skybox created by the helper.
  48786. */
  48787. readonly skybox: Nullable<Mesh>;
  48788. private _skyboxTexture;
  48789. /**
  48790. * Gets the skybox texture created by the helper.
  48791. */
  48792. readonly skyboxTexture: Nullable<BaseTexture>;
  48793. private _skyboxMaterial;
  48794. /**
  48795. * Gets the skybox material created by the helper.
  48796. */
  48797. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48798. private _ground;
  48799. /**
  48800. * Gets the ground mesh created by the helper.
  48801. */
  48802. readonly ground: Nullable<Mesh>;
  48803. private _groundTexture;
  48804. /**
  48805. * Gets the ground texture created by the helper.
  48806. */
  48807. readonly groundTexture: Nullable<BaseTexture>;
  48808. private _groundMirror;
  48809. /**
  48810. * Gets the ground mirror created by the helper.
  48811. */
  48812. readonly groundMirror: Nullable<MirrorTexture>;
  48813. /**
  48814. * Gets the ground mirror render list to helps pushing the meshes
  48815. * you wish in the ground reflection.
  48816. */
  48817. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48818. private _groundMaterial;
  48819. /**
  48820. * Gets the ground material created by the helper.
  48821. */
  48822. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48823. /**
  48824. * Stores the creation options.
  48825. */
  48826. private readonly _scene;
  48827. private _options;
  48828. /**
  48829. * This observable will be notified with any error during the creation of the environment,
  48830. * mainly texture creation errors.
  48831. */
  48832. onErrorObservable: Observable<{
  48833. message?: string;
  48834. exception?: any;
  48835. }>;
  48836. /**
  48837. * constructor
  48838. * @param options Defines the options we want to customize the helper
  48839. * @param scene The scene to add the material to
  48840. */
  48841. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48842. /**
  48843. * Updates the background according to the new options
  48844. * @param options
  48845. */
  48846. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48847. /**
  48848. * Sets the primary color of all the available elements.
  48849. * @param color the main color to affect to the ground and the background
  48850. */
  48851. setMainColor(color: Color3): void;
  48852. /**
  48853. * Setup the image processing according to the specified options.
  48854. */
  48855. private _setupImageProcessing;
  48856. /**
  48857. * Setup the environment texture according to the specified options.
  48858. */
  48859. private _setupEnvironmentTexture;
  48860. /**
  48861. * Setup the background according to the specified options.
  48862. */
  48863. private _setupBackground;
  48864. /**
  48865. * Get the scene sizes according to the setup.
  48866. */
  48867. private _getSceneSize;
  48868. /**
  48869. * Setup the ground according to the specified options.
  48870. */
  48871. private _setupGround;
  48872. /**
  48873. * Setup the ground material according to the specified options.
  48874. */
  48875. private _setupGroundMaterial;
  48876. /**
  48877. * Setup the ground diffuse texture according to the specified options.
  48878. */
  48879. private _setupGroundDiffuseTexture;
  48880. /**
  48881. * Setup the ground mirror texture according to the specified options.
  48882. */
  48883. private _setupGroundMirrorTexture;
  48884. /**
  48885. * Setup the ground to receive the mirror texture.
  48886. */
  48887. private _setupMirrorInGroundMaterial;
  48888. /**
  48889. * Setup the skybox according to the specified options.
  48890. */
  48891. private _setupSkybox;
  48892. /**
  48893. * Setup the skybox material according to the specified options.
  48894. */
  48895. private _setupSkyboxMaterial;
  48896. /**
  48897. * Setup the skybox reflection texture according to the specified options.
  48898. */
  48899. private _setupSkyboxReflectionTexture;
  48900. private _errorHandler;
  48901. /**
  48902. * Dispose all the elements created by the Helper.
  48903. */
  48904. dispose(): void;
  48905. }
  48906. }
  48907. declare module "babylonjs/Helpers/photoDome" {
  48908. import { Observable } from "babylonjs/Misc/observable";
  48909. import { Nullable } from "babylonjs/types";
  48910. import { Scene } from "babylonjs/scene";
  48911. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48912. import { Mesh } from "babylonjs/Meshes/mesh";
  48913. import { Texture } from "babylonjs/Materials/Textures/texture";
  48914. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48915. import "babylonjs/Meshes/Builders/sphereBuilder";
  48916. /**
  48917. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48918. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48919. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48920. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48921. */
  48922. export class PhotoDome extends TransformNode {
  48923. /**
  48924. * Define the image as a Monoscopic panoramic 360 image.
  48925. */
  48926. static readonly MODE_MONOSCOPIC: number;
  48927. /**
  48928. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48929. */
  48930. static readonly MODE_TOPBOTTOM: number;
  48931. /**
  48932. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48933. */
  48934. static readonly MODE_SIDEBYSIDE: number;
  48935. private _useDirectMapping;
  48936. /**
  48937. * The texture being displayed on the sphere
  48938. */
  48939. protected _photoTexture: Texture;
  48940. /**
  48941. * Gets or sets the texture being displayed on the sphere
  48942. */
  48943. photoTexture: Texture;
  48944. /**
  48945. * Observable raised when an error occured while loading the 360 image
  48946. */
  48947. onLoadErrorObservable: Observable<string>;
  48948. /**
  48949. * The skybox material
  48950. */
  48951. protected _material: BackgroundMaterial;
  48952. /**
  48953. * The surface used for the skybox
  48954. */
  48955. protected _mesh: Mesh;
  48956. /**
  48957. * Gets the mesh used for the skybox.
  48958. */
  48959. readonly mesh: Mesh;
  48960. /**
  48961. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48962. * Also see the options.resolution property.
  48963. */
  48964. fovMultiplier: number;
  48965. private _imageMode;
  48966. /**
  48967. * Gets or set the current video mode for the video. It can be:
  48968. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48969. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48970. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48971. */
  48972. imageMode: number;
  48973. /**
  48974. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48975. * @param name Element's name, child elements will append suffixes for their own names.
  48976. * @param urlsOfPhoto defines the url of the photo to display
  48977. * @param options defines an object containing optional or exposed sub element properties
  48978. * @param onError defines a callback called when an error occured while loading the texture
  48979. */
  48980. constructor(name: string, urlOfPhoto: string, options: {
  48981. resolution?: number;
  48982. size?: number;
  48983. useDirectMapping?: boolean;
  48984. faceForward?: boolean;
  48985. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48986. private _onBeforeCameraRenderObserver;
  48987. private _changeImageMode;
  48988. /**
  48989. * Releases resources associated with this node.
  48990. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48991. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48992. */
  48993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48994. }
  48995. }
  48996. declare module "babylonjs/Misc/rgbdTextureTools" {
  48997. import "babylonjs/Shaders/rgbdDecode.fragment";
  48998. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48999. import { Texture } from "babylonjs/Materials/Textures/texture";
  49000. /**
  49001. * Class used to host RGBD texture specific utilities
  49002. */
  49003. export class RGBDTextureTools {
  49004. /**
  49005. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49006. * @param texture the texture to expand.
  49007. */
  49008. static ExpandRGBDTexture(texture: Texture): void;
  49009. }
  49010. }
  49011. declare module "babylonjs/Misc/brdfTextureTools" {
  49012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49013. import { Scene } from "babylonjs/scene";
  49014. /**
  49015. * Class used to host texture specific utilities
  49016. */
  49017. export class BRDFTextureTools {
  49018. /**
  49019. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49020. * @param scene defines the hosting scene
  49021. * @returns the environment BRDF texture
  49022. */
  49023. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49024. private static _environmentBRDFBase64Texture;
  49025. }
  49026. }
  49027. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49028. import { Nullable } from "babylonjs/types";
  49029. import { Color3 } from "babylonjs/Maths/math.color";
  49030. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49031. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49032. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49033. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49034. import { Engine } from "babylonjs/Engines/engine";
  49035. import { Scene } from "babylonjs/scene";
  49036. /**
  49037. * @hidden
  49038. */
  49039. export interface IMaterialClearCoatDefines {
  49040. CLEARCOAT: boolean;
  49041. CLEARCOAT_DEFAULTIOR: boolean;
  49042. CLEARCOAT_TEXTURE: boolean;
  49043. CLEARCOAT_TEXTUREDIRECTUV: number;
  49044. CLEARCOAT_BUMP: boolean;
  49045. CLEARCOAT_BUMPDIRECTUV: number;
  49046. CLEARCOAT_TINT: boolean;
  49047. CLEARCOAT_TINT_TEXTURE: boolean;
  49048. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49049. /** @hidden */
  49050. _areTexturesDirty: boolean;
  49051. }
  49052. /**
  49053. * Define the code related to the clear coat parameters of the pbr material.
  49054. */
  49055. export class PBRClearCoatConfiguration {
  49056. /**
  49057. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49058. * The default fits with a polyurethane material.
  49059. */
  49060. private static readonly _DefaultIndexOfRefraction;
  49061. private _isEnabled;
  49062. /**
  49063. * Defines if the clear coat is enabled in the material.
  49064. */
  49065. isEnabled: boolean;
  49066. /**
  49067. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49068. */
  49069. intensity: number;
  49070. /**
  49071. * Defines the clear coat layer roughness.
  49072. */
  49073. roughness: number;
  49074. private _indexOfRefraction;
  49075. /**
  49076. * Defines the index of refraction of the clear coat.
  49077. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49078. * The default fits with a polyurethane material.
  49079. * Changing the default value is more performance intensive.
  49080. */
  49081. indexOfRefraction: number;
  49082. private _texture;
  49083. /**
  49084. * Stores the clear coat values in a texture.
  49085. */
  49086. texture: Nullable<BaseTexture>;
  49087. private _bumpTexture;
  49088. /**
  49089. * Define the clear coat specific bump texture.
  49090. */
  49091. bumpTexture: Nullable<BaseTexture>;
  49092. private _isTintEnabled;
  49093. /**
  49094. * Defines if the clear coat tint is enabled in the material.
  49095. */
  49096. isTintEnabled: boolean;
  49097. /**
  49098. * Defines the clear coat tint of the material.
  49099. * This is only use if tint is enabled
  49100. */
  49101. tintColor: Color3;
  49102. /**
  49103. * Defines the distance at which the tint color should be found in the
  49104. * clear coat media.
  49105. * This is only use if tint is enabled
  49106. */
  49107. tintColorAtDistance: number;
  49108. /**
  49109. * Defines the clear coat layer thickness.
  49110. * This is only use if tint is enabled
  49111. */
  49112. tintThickness: number;
  49113. private _tintTexture;
  49114. /**
  49115. * Stores the clear tint values in a texture.
  49116. * rgb is tint
  49117. * a is a thickness factor
  49118. */
  49119. tintTexture: Nullable<BaseTexture>;
  49120. /** @hidden */
  49121. private _internalMarkAllSubMeshesAsTexturesDirty;
  49122. /** @hidden */
  49123. _markAllSubMeshesAsTexturesDirty(): void;
  49124. /**
  49125. * Instantiate a new istance of clear coat configuration.
  49126. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49127. */
  49128. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49129. /**
  49130. * Gets wehter the submesh is ready to be used or not.
  49131. * @param defines the list of "defines" to update.
  49132. * @param scene defines the scene the material belongs to.
  49133. * @param engine defines the engine the material belongs to.
  49134. * @param disableBumpMap defines wether the material disables bump or not.
  49135. * @returns - boolean indicating that the submesh is ready or not.
  49136. */
  49137. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49138. /**
  49139. * Checks to see if a texture is used in the material.
  49140. * @param defines the list of "defines" to update.
  49141. * @param scene defines the scene to the material belongs to.
  49142. */
  49143. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49144. /**
  49145. * Binds the material data.
  49146. * @param uniformBuffer defines the Uniform buffer to fill in.
  49147. * @param scene defines the scene the material belongs to.
  49148. * @param engine defines the engine the material belongs to.
  49149. * @param disableBumpMap defines wether the material disables bump or not.
  49150. * @param isFrozen defines wether the material is frozen or not.
  49151. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49152. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49153. */
  49154. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49155. /**
  49156. * Checks to see if a texture is used in the material.
  49157. * @param texture - Base texture to use.
  49158. * @returns - Boolean specifying if a texture is used in the material.
  49159. */
  49160. hasTexture(texture: BaseTexture): boolean;
  49161. /**
  49162. * Returns an array of the actively used textures.
  49163. * @param activeTextures Array of BaseTextures
  49164. */
  49165. getActiveTextures(activeTextures: BaseTexture[]): void;
  49166. /**
  49167. * Returns the animatable textures.
  49168. * @param animatables Array of animatable textures.
  49169. */
  49170. getAnimatables(animatables: IAnimatable[]): void;
  49171. /**
  49172. * Disposes the resources of the material.
  49173. * @param forceDisposeTextures - Forces the disposal of all textures.
  49174. */
  49175. dispose(forceDisposeTextures?: boolean): void;
  49176. /**
  49177. * Get the current class name of the texture useful for serialization or dynamic coding.
  49178. * @returns "PBRClearCoatConfiguration"
  49179. */
  49180. getClassName(): string;
  49181. /**
  49182. * Add fallbacks to the effect fallbacks list.
  49183. * @param defines defines the Base texture to use.
  49184. * @param fallbacks defines the current fallback list.
  49185. * @param currentRank defines the current fallback rank.
  49186. * @returns the new fallback rank.
  49187. */
  49188. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49189. /**
  49190. * Add the required uniforms to the current list.
  49191. * @param uniforms defines the current uniform list.
  49192. */
  49193. static AddUniforms(uniforms: string[]): void;
  49194. /**
  49195. * Add the required samplers to the current list.
  49196. * @param samplers defines the current sampler list.
  49197. */
  49198. static AddSamplers(samplers: string[]): void;
  49199. /**
  49200. * Add the required uniforms to the current buffer.
  49201. * @param uniformBuffer defines the current uniform buffer.
  49202. */
  49203. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49204. /**
  49205. * Makes a duplicate of the current configuration into another one.
  49206. * @param clearCoatConfiguration define the config where to copy the info
  49207. */
  49208. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49209. /**
  49210. * Serializes this clear coat configuration.
  49211. * @returns - An object with the serialized config.
  49212. */
  49213. serialize(): any;
  49214. /**
  49215. * Parses a anisotropy Configuration from a serialized object.
  49216. * @param source - Serialized object.
  49217. * @param scene Defines the scene we are parsing for
  49218. * @param rootUrl Defines the rootUrl to load from
  49219. */
  49220. parse(source: any, scene: Scene, rootUrl: string): void;
  49221. }
  49222. }
  49223. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49224. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49226. import { Vector2 } from "babylonjs/Maths/math.vector";
  49227. import { Scene } from "babylonjs/scene";
  49228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49229. import { Nullable } from "babylonjs/types";
  49230. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49231. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49232. /**
  49233. * @hidden
  49234. */
  49235. export interface IMaterialAnisotropicDefines {
  49236. ANISOTROPIC: boolean;
  49237. ANISOTROPIC_TEXTURE: boolean;
  49238. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49239. MAINUV1: boolean;
  49240. _areTexturesDirty: boolean;
  49241. _needUVs: boolean;
  49242. }
  49243. /**
  49244. * Define the code related to the anisotropic parameters of the pbr material.
  49245. */
  49246. export class PBRAnisotropicConfiguration {
  49247. private _isEnabled;
  49248. /**
  49249. * Defines if the anisotropy is enabled in the material.
  49250. */
  49251. isEnabled: boolean;
  49252. /**
  49253. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49254. */
  49255. intensity: number;
  49256. /**
  49257. * Defines if the effect is along the tangents, bitangents or in between.
  49258. * By default, the effect is "strectching" the highlights along the tangents.
  49259. */
  49260. direction: Vector2;
  49261. private _texture;
  49262. /**
  49263. * Stores the anisotropy values in a texture.
  49264. * rg is direction (like normal from -1 to 1)
  49265. * b is a intensity
  49266. */
  49267. texture: Nullable<BaseTexture>;
  49268. /** @hidden */
  49269. private _internalMarkAllSubMeshesAsTexturesDirty;
  49270. /** @hidden */
  49271. _markAllSubMeshesAsTexturesDirty(): void;
  49272. /**
  49273. * Instantiate a new istance of anisotropy configuration.
  49274. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49275. */
  49276. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49277. /**
  49278. * Specifies that the submesh is ready to be used.
  49279. * @param defines the list of "defines" to update.
  49280. * @param scene defines the scene the material belongs to.
  49281. * @returns - boolean indicating that the submesh is ready or not.
  49282. */
  49283. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49284. /**
  49285. * Checks to see if a texture is used in the material.
  49286. * @param defines the list of "defines" to update.
  49287. * @param mesh the mesh we are preparing the defines for.
  49288. * @param scene defines the scene the material belongs to.
  49289. */
  49290. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49291. /**
  49292. * Binds the material data.
  49293. * @param uniformBuffer defines the Uniform buffer to fill in.
  49294. * @param scene defines the scene the material belongs to.
  49295. * @param isFrozen defines wether the material is frozen or not.
  49296. */
  49297. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49298. /**
  49299. * Checks to see if a texture is used in the material.
  49300. * @param texture - Base texture to use.
  49301. * @returns - Boolean specifying if a texture is used in the material.
  49302. */
  49303. hasTexture(texture: BaseTexture): boolean;
  49304. /**
  49305. * Returns an array of the actively used textures.
  49306. * @param activeTextures Array of BaseTextures
  49307. */
  49308. getActiveTextures(activeTextures: BaseTexture[]): void;
  49309. /**
  49310. * Returns the animatable textures.
  49311. * @param animatables Array of animatable textures.
  49312. */
  49313. getAnimatables(animatables: IAnimatable[]): void;
  49314. /**
  49315. * Disposes the resources of the material.
  49316. * @param forceDisposeTextures - Forces the disposal of all textures.
  49317. */
  49318. dispose(forceDisposeTextures?: boolean): void;
  49319. /**
  49320. * Get the current class name of the texture useful for serialization or dynamic coding.
  49321. * @returns "PBRAnisotropicConfiguration"
  49322. */
  49323. getClassName(): string;
  49324. /**
  49325. * Add fallbacks to the effect fallbacks list.
  49326. * @param defines defines the Base texture to use.
  49327. * @param fallbacks defines the current fallback list.
  49328. * @param currentRank defines the current fallback rank.
  49329. * @returns the new fallback rank.
  49330. */
  49331. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49332. /**
  49333. * Add the required uniforms to the current list.
  49334. * @param uniforms defines the current uniform list.
  49335. */
  49336. static AddUniforms(uniforms: string[]): void;
  49337. /**
  49338. * Add the required uniforms to the current buffer.
  49339. * @param uniformBuffer defines the current uniform buffer.
  49340. */
  49341. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49342. /**
  49343. * Add the required samplers to the current list.
  49344. * @param samplers defines the current sampler list.
  49345. */
  49346. static AddSamplers(samplers: string[]): void;
  49347. /**
  49348. * Makes a duplicate of the current configuration into another one.
  49349. * @param anisotropicConfiguration define the config where to copy the info
  49350. */
  49351. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49352. /**
  49353. * Serializes this anisotropy configuration.
  49354. * @returns - An object with the serialized config.
  49355. */
  49356. serialize(): any;
  49357. /**
  49358. * Parses a anisotropy Configuration from a serialized object.
  49359. * @param source - Serialized object.
  49360. * @param scene Defines the scene we are parsing for
  49361. * @param rootUrl Defines the rootUrl to load from
  49362. */
  49363. parse(source: any, scene: Scene, rootUrl: string): void;
  49364. }
  49365. }
  49366. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49367. import { Scene } from "babylonjs/scene";
  49368. /**
  49369. * @hidden
  49370. */
  49371. export interface IMaterialBRDFDefines {
  49372. BRDF_V_HEIGHT_CORRELATED: boolean;
  49373. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49374. SPHERICAL_HARMONICS: boolean;
  49375. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49376. /** @hidden */
  49377. _areMiscDirty: boolean;
  49378. }
  49379. /**
  49380. * Define the code related to the BRDF parameters of the pbr material.
  49381. */
  49382. export class PBRBRDFConfiguration {
  49383. /**
  49384. * Default value used for the energy conservation.
  49385. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49386. */
  49387. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49388. /**
  49389. * Default value used for the Smith Visibility Height Correlated mode.
  49390. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49391. */
  49392. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49393. /**
  49394. * Default value used for the IBL diffuse part.
  49395. * This can help switching back to the polynomials mode globally which is a tiny bit
  49396. * less GPU intensive at the drawback of a lower quality.
  49397. */
  49398. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49399. /**
  49400. * Default value used for activating energy conservation for the specular workflow.
  49401. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49402. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49403. */
  49404. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49405. private _useEnergyConservation;
  49406. /**
  49407. * Defines if the material uses energy conservation.
  49408. */
  49409. useEnergyConservation: boolean;
  49410. private _useSmithVisibilityHeightCorrelated;
  49411. /**
  49412. * LEGACY Mode set to false
  49413. * Defines if the material uses height smith correlated visibility term.
  49414. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49415. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49416. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49417. * Not relying on height correlated will also disable energy conservation.
  49418. */
  49419. useSmithVisibilityHeightCorrelated: boolean;
  49420. private _useSphericalHarmonics;
  49421. /**
  49422. * LEGACY Mode set to false
  49423. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49424. * diffuse part of the IBL.
  49425. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49426. * to the ground truth.
  49427. */
  49428. useSphericalHarmonics: boolean;
  49429. private _useSpecularGlossinessInputEnergyConservation;
  49430. /**
  49431. * Defines if the material uses energy conservation, when the specular workflow is active.
  49432. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49433. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49434. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49435. */
  49436. useSpecularGlossinessInputEnergyConservation: boolean;
  49437. /** @hidden */
  49438. private _internalMarkAllSubMeshesAsMiscDirty;
  49439. /** @hidden */
  49440. _markAllSubMeshesAsMiscDirty(): void;
  49441. /**
  49442. * Instantiate a new istance of clear coat configuration.
  49443. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49444. */
  49445. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49446. /**
  49447. * Checks to see if a texture is used in the material.
  49448. * @param defines the list of "defines" to update.
  49449. */
  49450. prepareDefines(defines: IMaterialBRDFDefines): void;
  49451. /**
  49452. * Get the current class name of the texture useful for serialization or dynamic coding.
  49453. * @returns "PBRClearCoatConfiguration"
  49454. */
  49455. getClassName(): string;
  49456. /**
  49457. * Makes a duplicate of the current configuration into another one.
  49458. * @param brdfConfiguration define the config where to copy the info
  49459. */
  49460. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49461. /**
  49462. * Serializes this BRDF configuration.
  49463. * @returns - An object with the serialized config.
  49464. */
  49465. serialize(): any;
  49466. /**
  49467. * Parses a anisotropy Configuration from a serialized object.
  49468. * @param source - Serialized object.
  49469. * @param scene Defines the scene we are parsing for
  49470. * @param rootUrl Defines the rootUrl to load from
  49471. */
  49472. parse(source: any, scene: Scene, rootUrl: string): void;
  49473. }
  49474. }
  49475. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49476. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49477. import { Color3 } from "babylonjs/Maths/math.color";
  49478. import { Scene } from "babylonjs/scene";
  49479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49480. import { Nullable } from "babylonjs/types";
  49481. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49482. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49483. /**
  49484. * @hidden
  49485. */
  49486. export interface IMaterialSheenDefines {
  49487. SHEEN: boolean;
  49488. SHEEN_TEXTURE: boolean;
  49489. SHEEN_TEXTUREDIRECTUV: number;
  49490. SHEEN_LINKWITHALBEDO: boolean;
  49491. /** @hidden */
  49492. _areTexturesDirty: boolean;
  49493. }
  49494. /**
  49495. * Define the code related to the Sheen parameters of the pbr material.
  49496. */
  49497. export class PBRSheenConfiguration {
  49498. private _isEnabled;
  49499. /**
  49500. * Defines if the material uses sheen.
  49501. */
  49502. isEnabled: boolean;
  49503. private _linkSheenWithAlbedo;
  49504. /**
  49505. * Defines if the sheen is linked to the sheen color.
  49506. */
  49507. linkSheenWithAlbedo: boolean;
  49508. /**
  49509. * Defines the sheen intensity.
  49510. */
  49511. intensity: number;
  49512. /**
  49513. * Defines the sheen color.
  49514. */
  49515. color: Color3;
  49516. private _texture;
  49517. /**
  49518. * Stores the sheen tint values in a texture.
  49519. * rgb is tint
  49520. * a is a intensity
  49521. */
  49522. texture: Nullable<BaseTexture>;
  49523. /** @hidden */
  49524. private _internalMarkAllSubMeshesAsTexturesDirty;
  49525. /** @hidden */
  49526. _markAllSubMeshesAsTexturesDirty(): void;
  49527. /**
  49528. * Instantiate a new istance of clear coat configuration.
  49529. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49530. */
  49531. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49532. /**
  49533. * Specifies that the submesh is ready to be used.
  49534. * @param defines the list of "defines" to update.
  49535. * @param scene defines the scene the material belongs to.
  49536. * @returns - boolean indicating that the submesh is ready or not.
  49537. */
  49538. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49539. /**
  49540. * Checks to see if a texture is used in the material.
  49541. * @param defines the list of "defines" to update.
  49542. * @param scene defines the scene the material belongs to.
  49543. */
  49544. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49545. /**
  49546. * Binds the material data.
  49547. * @param uniformBuffer defines the Uniform buffer to fill in.
  49548. * @param scene defines the scene the material belongs to.
  49549. * @param isFrozen defines wether the material is frozen or not.
  49550. */
  49551. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49552. /**
  49553. * Checks to see if a texture is used in the material.
  49554. * @param texture - Base texture to use.
  49555. * @returns - Boolean specifying if a texture is used in the material.
  49556. */
  49557. hasTexture(texture: BaseTexture): boolean;
  49558. /**
  49559. * Returns an array of the actively used textures.
  49560. * @param activeTextures Array of BaseTextures
  49561. */
  49562. getActiveTextures(activeTextures: BaseTexture[]): void;
  49563. /**
  49564. * Returns the animatable textures.
  49565. * @param animatables Array of animatable textures.
  49566. */
  49567. getAnimatables(animatables: IAnimatable[]): void;
  49568. /**
  49569. * Disposes the resources of the material.
  49570. * @param forceDisposeTextures - Forces the disposal of all textures.
  49571. */
  49572. dispose(forceDisposeTextures?: boolean): void;
  49573. /**
  49574. * Get the current class name of the texture useful for serialization or dynamic coding.
  49575. * @returns "PBRSheenConfiguration"
  49576. */
  49577. getClassName(): string;
  49578. /**
  49579. * Add fallbacks to the effect fallbacks list.
  49580. * @param defines defines the Base texture to use.
  49581. * @param fallbacks defines the current fallback list.
  49582. * @param currentRank defines the current fallback rank.
  49583. * @returns the new fallback rank.
  49584. */
  49585. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49586. /**
  49587. * Add the required uniforms to the current list.
  49588. * @param uniforms defines the current uniform list.
  49589. */
  49590. static AddUniforms(uniforms: string[]): void;
  49591. /**
  49592. * Add the required uniforms to the current buffer.
  49593. * @param uniformBuffer defines the current uniform buffer.
  49594. */
  49595. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49596. /**
  49597. * Add the required samplers to the current list.
  49598. * @param samplers defines the current sampler list.
  49599. */
  49600. static AddSamplers(samplers: string[]): void;
  49601. /**
  49602. * Makes a duplicate of the current configuration into another one.
  49603. * @param sheenConfiguration define the config where to copy the info
  49604. */
  49605. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49606. /**
  49607. * Serializes this BRDF configuration.
  49608. * @returns - An object with the serialized config.
  49609. */
  49610. serialize(): any;
  49611. /**
  49612. * Parses a anisotropy Configuration from a serialized object.
  49613. * @param source - Serialized object.
  49614. * @param scene Defines the scene we are parsing for
  49615. * @param rootUrl Defines the rootUrl to load from
  49616. */
  49617. parse(source: any, scene: Scene, rootUrl: string): void;
  49618. }
  49619. }
  49620. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49621. import { Nullable } from "babylonjs/types";
  49622. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49623. import { Color3 } from "babylonjs/Maths/math.color";
  49624. import { SmartArray } from "babylonjs/Misc/smartArray";
  49625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49627. import { Effect } from "babylonjs/Materials/effect";
  49628. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49629. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49630. import { Engine } from "babylonjs/Engines/engine";
  49631. import { Scene } from "babylonjs/scene";
  49632. /**
  49633. * @hidden
  49634. */
  49635. export interface IMaterialSubSurfaceDefines {
  49636. SUBSURFACE: boolean;
  49637. SS_REFRACTION: boolean;
  49638. SS_TRANSLUCENCY: boolean;
  49639. SS_SCATERRING: boolean;
  49640. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49641. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49642. SS_REFRACTIONMAP_3D: boolean;
  49643. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49644. SS_LODINREFRACTIONALPHA: boolean;
  49645. SS_GAMMAREFRACTION: boolean;
  49646. SS_RGBDREFRACTION: boolean;
  49647. SS_LINEARSPECULARREFRACTION: boolean;
  49648. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49649. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49650. /** @hidden */
  49651. _areTexturesDirty: boolean;
  49652. }
  49653. /**
  49654. * Define the code related to the sub surface parameters of the pbr material.
  49655. */
  49656. export class PBRSubSurfaceConfiguration {
  49657. private _isRefractionEnabled;
  49658. /**
  49659. * Defines if the refraction is enabled in the material.
  49660. */
  49661. isRefractionEnabled: boolean;
  49662. private _isTranslucencyEnabled;
  49663. /**
  49664. * Defines if the translucency is enabled in the material.
  49665. */
  49666. isTranslucencyEnabled: boolean;
  49667. private _isScatteringEnabled;
  49668. /**
  49669. * Defines the refraction intensity of the material.
  49670. * The refraction when enabled replaces the Diffuse part of the material.
  49671. * The intensity helps transitionning between diffuse and refraction.
  49672. */
  49673. refractionIntensity: number;
  49674. /**
  49675. * Defines the translucency intensity of the material.
  49676. * When translucency has been enabled, this defines how much of the "translucency"
  49677. * is addded to the diffuse part of the material.
  49678. */
  49679. translucencyIntensity: number;
  49680. /**
  49681. * Defines the scattering intensity of the material.
  49682. * When scattering has been enabled, this defines how much of the "scattered light"
  49683. * is addded to the diffuse part of the material.
  49684. */
  49685. scatteringIntensity: number;
  49686. private _thicknessTexture;
  49687. /**
  49688. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49689. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49690. * 0 would mean minimumThickness
  49691. * 1 would mean maximumThickness
  49692. * The other channels might be use as a mask to vary the different effects intensity.
  49693. */
  49694. thicknessTexture: Nullable<BaseTexture>;
  49695. private _refractionTexture;
  49696. /**
  49697. * Defines the texture to use for refraction.
  49698. */
  49699. refractionTexture: Nullable<BaseTexture>;
  49700. private _indexOfRefraction;
  49701. /**
  49702. * Defines the index of refraction used in the material.
  49703. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49704. */
  49705. indexOfRefraction: number;
  49706. private _invertRefractionY;
  49707. /**
  49708. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49709. */
  49710. invertRefractionY: boolean;
  49711. private _linkRefractionWithTransparency;
  49712. /**
  49713. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49714. * Materials half opaque for instance using refraction could benefit from this control.
  49715. */
  49716. linkRefractionWithTransparency: boolean;
  49717. /**
  49718. * Defines the minimum thickness stored in the thickness map.
  49719. * If no thickness map is defined, this value will be used to simulate thickness.
  49720. */
  49721. minimumThickness: number;
  49722. /**
  49723. * Defines the maximum thickness stored in the thickness map.
  49724. */
  49725. maximumThickness: number;
  49726. /**
  49727. * Defines the volume tint of the material.
  49728. * This is used for both translucency and scattering.
  49729. */
  49730. tintColor: Color3;
  49731. /**
  49732. * Defines the distance at which the tint color should be found in the media.
  49733. * This is used for refraction only.
  49734. */
  49735. tintColorAtDistance: number;
  49736. /**
  49737. * Defines how far each channel transmit through the media.
  49738. * It is defined as a color to simplify it selection.
  49739. */
  49740. diffusionDistance: Color3;
  49741. private _useMaskFromThicknessTexture;
  49742. /**
  49743. * Stores the intensity of the different subsurface effects in the thickness texture.
  49744. * * the green channel is the translucency intensity.
  49745. * * the blue channel is the scattering intensity.
  49746. * * the alpha channel is the refraction intensity.
  49747. */
  49748. useMaskFromThicknessTexture: boolean;
  49749. /** @hidden */
  49750. private _internalMarkAllSubMeshesAsTexturesDirty;
  49751. /** @hidden */
  49752. _markAllSubMeshesAsTexturesDirty(): void;
  49753. /**
  49754. * Instantiate a new istance of sub surface configuration.
  49755. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49756. */
  49757. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49758. /**
  49759. * Gets wehter the submesh is ready to be used or not.
  49760. * @param defines the list of "defines" to update.
  49761. * @param scene defines the scene the material belongs to.
  49762. * @returns - boolean indicating that the submesh is ready or not.
  49763. */
  49764. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49765. /**
  49766. * Checks to see if a texture is used in the material.
  49767. * @param defines the list of "defines" to update.
  49768. * @param scene defines the scene to the material belongs to.
  49769. */
  49770. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49771. /**
  49772. * Binds the material data.
  49773. * @param uniformBuffer defines the Uniform buffer to fill in.
  49774. * @param scene defines the scene the material belongs to.
  49775. * @param engine defines the engine the material belongs to.
  49776. * @param isFrozen defines wether the material is frozen or not.
  49777. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49778. */
  49779. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49780. /**
  49781. * Unbinds the material from the mesh.
  49782. * @param activeEffect defines the effect that should be unbound from.
  49783. * @returns true if unbound, otherwise false
  49784. */
  49785. unbind(activeEffect: Effect): boolean;
  49786. /**
  49787. * Returns the texture used for refraction or null if none is used.
  49788. * @param scene defines the scene the material belongs to.
  49789. * @returns - Refraction texture if present. If no refraction texture and refraction
  49790. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49791. */
  49792. private _getRefractionTexture;
  49793. /**
  49794. * Returns true if alpha blending should be disabled.
  49795. */
  49796. readonly disableAlphaBlending: boolean;
  49797. /**
  49798. * Fills the list of render target textures.
  49799. * @param renderTargets the list of render targets to update
  49800. */
  49801. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49802. /**
  49803. * Checks to see if a texture is used in the material.
  49804. * @param texture - Base texture to use.
  49805. * @returns - Boolean specifying if a texture is used in the material.
  49806. */
  49807. hasTexture(texture: BaseTexture): boolean;
  49808. /**
  49809. * Gets a boolean indicating that current material needs to register RTT
  49810. * @returns true if this uses a render target otherwise false.
  49811. */
  49812. hasRenderTargetTextures(): boolean;
  49813. /**
  49814. * Returns an array of the actively used textures.
  49815. * @param activeTextures Array of BaseTextures
  49816. */
  49817. getActiveTextures(activeTextures: BaseTexture[]): void;
  49818. /**
  49819. * Returns the animatable textures.
  49820. * @param animatables Array of animatable textures.
  49821. */
  49822. getAnimatables(animatables: IAnimatable[]): void;
  49823. /**
  49824. * Disposes the resources of the material.
  49825. * @param forceDisposeTextures - Forces the disposal of all textures.
  49826. */
  49827. dispose(forceDisposeTextures?: boolean): void;
  49828. /**
  49829. * Get the current class name of the texture useful for serialization or dynamic coding.
  49830. * @returns "PBRSubSurfaceConfiguration"
  49831. */
  49832. getClassName(): string;
  49833. /**
  49834. * Add fallbacks to the effect fallbacks list.
  49835. * @param defines defines the Base texture to use.
  49836. * @param fallbacks defines the current fallback list.
  49837. * @param currentRank defines the current fallback rank.
  49838. * @returns the new fallback rank.
  49839. */
  49840. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49841. /**
  49842. * Add the required uniforms to the current list.
  49843. * @param uniforms defines the current uniform list.
  49844. */
  49845. static AddUniforms(uniforms: string[]): void;
  49846. /**
  49847. * Add the required samplers to the current list.
  49848. * @param samplers defines the current sampler list.
  49849. */
  49850. static AddSamplers(samplers: string[]): void;
  49851. /**
  49852. * Add the required uniforms to the current buffer.
  49853. * @param uniformBuffer defines the current uniform buffer.
  49854. */
  49855. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49856. /**
  49857. * Makes a duplicate of the current configuration into another one.
  49858. * @param configuration define the config where to copy the info
  49859. */
  49860. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49861. /**
  49862. * Serializes this Sub Surface configuration.
  49863. * @returns - An object with the serialized config.
  49864. */
  49865. serialize(): any;
  49866. /**
  49867. * Parses a anisotropy Configuration from a serialized object.
  49868. * @param source - Serialized object.
  49869. * @param scene Defines the scene we are parsing for
  49870. * @param rootUrl Defines the rootUrl to load from
  49871. */
  49872. parse(source: any, scene: Scene, rootUrl: string): void;
  49873. }
  49874. }
  49875. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49876. /** @hidden */
  49877. export var pbrFragmentDeclaration: {
  49878. name: string;
  49879. shader: string;
  49880. };
  49881. }
  49882. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49883. /** @hidden */
  49884. export var pbrUboDeclaration: {
  49885. name: string;
  49886. shader: string;
  49887. };
  49888. }
  49889. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49890. /** @hidden */
  49891. export var pbrFragmentExtraDeclaration: {
  49892. name: string;
  49893. shader: string;
  49894. };
  49895. }
  49896. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49897. /** @hidden */
  49898. export var pbrFragmentSamplersDeclaration: {
  49899. name: string;
  49900. shader: string;
  49901. };
  49902. }
  49903. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49904. /** @hidden */
  49905. export var pbrHelperFunctions: {
  49906. name: string;
  49907. shader: string;
  49908. };
  49909. }
  49910. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49911. /** @hidden */
  49912. export var harmonicsFunctions: {
  49913. name: string;
  49914. shader: string;
  49915. };
  49916. }
  49917. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49918. /** @hidden */
  49919. export var pbrDirectLightingSetupFunctions: {
  49920. name: string;
  49921. shader: string;
  49922. };
  49923. }
  49924. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49925. /** @hidden */
  49926. export var pbrDirectLightingFalloffFunctions: {
  49927. name: string;
  49928. shader: string;
  49929. };
  49930. }
  49931. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49932. /** @hidden */
  49933. export var pbrBRDFFunctions: {
  49934. name: string;
  49935. shader: string;
  49936. };
  49937. }
  49938. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49939. /** @hidden */
  49940. export var pbrDirectLightingFunctions: {
  49941. name: string;
  49942. shader: string;
  49943. };
  49944. }
  49945. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49946. /** @hidden */
  49947. export var pbrIBLFunctions: {
  49948. name: string;
  49949. shader: string;
  49950. };
  49951. }
  49952. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49953. /** @hidden */
  49954. export var pbrDebug: {
  49955. name: string;
  49956. shader: string;
  49957. };
  49958. }
  49959. declare module "babylonjs/Shaders/pbr.fragment" {
  49960. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49961. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49962. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49963. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49964. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49965. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49966. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49967. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49968. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49969. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49970. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49971. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49972. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49973. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49974. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49975. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49976. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49977. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49978. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49979. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49980. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49981. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49982. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49983. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49984. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49985. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49986. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49987. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49988. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49989. /** @hidden */
  49990. export var pbrPixelShader: {
  49991. name: string;
  49992. shader: string;
  49993. };
  49994. }
  49995. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49996. /** @hidden */
  49997. export var pbrVertexDeclaration: {
  49998. name: string;
  49999. shader: string;
  50000. };
  50001. }
  50002. declare module "babylonjs/Shaders/pbr.vertex" {
  50003. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50004. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50005. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50006. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50007. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50008. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50009. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50010. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50011. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50012. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50013. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50014. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50015. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50016. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50017. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50018. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50019. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50020. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50021. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50022. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50023. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50024. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50025. /** @hidden */
  50026. export var pbrVertexShader: {
  50027. name: string;
  50028. shader: string;
  50029. };
  50030. }
  50031. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50032. import { Nullable } from "babylonjs/types";
  50033. import { Scene } from "babylonjs/scene";
  50034. import { Matrix } from "babylonjs/Maths/math.vector";
  50035. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50037. import { Mesh } from "babylonjs/Meshes/mesh";
  50038. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50039. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50040. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50041. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50042. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50043. import { Color3 } from "babylonjs/Maths/math.color";
  50044. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50045. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50046. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50047. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50049. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50050. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50051. import "babylonjs/Shaders/pbr.fragment";
  50052. import "babylonjs/Shaders/pbr.vertex";
  50053. /**
  50054. * Manages the defines for the PBR Material.
  50055. * @hidden
  50056. */
  50057. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50058. PBR: boolean;
  50059. MAINUV1: boolean;
  50060. MAINUV2: boolean;
  50061. UV1: boolean;
  50062. UV2: boolean;
  50063. ALBEDO: boolean;
  50064. ALBEDODIRECTUV: number;
  50065. VERTEXCOLOR: boolean;
  50066. AMBIENT: boolean;
  50067. AMBIENTDIRECTUV: number;
  50068. AMBIENTINGRAYSCALE: boolean;
  50069. OPACITY: boolean;
  50070. VERTEXALPHA: boolean;
  50071. OPACITYDIRECTUV: number;
  50072. OPACITYRGB: boolean;
  50073. ALPHATEST: boolean;
  50074. DEPTHPREPASS: boolean;
  50075. ALPHABLEND: boolean;
  50076. ALPHAFROMALBEDO: boolean;
  50077. ALPHATESTVALUE: string;
  50078. SPECULAROVERALPHA: boolean;
  50079. RADIANCEOVERALPHA: boolean;
  50080. ALPHAFRESNEL: boolean;
  50081. LINEARALPHAFRESNEL: boolean;
  50082. PREMULTIPLYALPHA: boolean;
  50083. EMISSIVE: boolean;
  50084. EMISSIVEDIRECTUV: number;
  50085. REFLECTIVITY: boolean;
  50086. REFLECTIVITYDIRECTUV: number;
  50087. SPECULARTERM: boolean;
  50088. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50089. MICROSURFACEAUTOMATIC: boolean;
  50090. LODBASEDMICROSFURACE: boolean;
  50091. MICROSURFACEMAP: boolean;
  50092. MICROSURFACEMAPDIRECTUV: number;
  50093. METALLICWORKFLOW: boolean;
  50094. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50095. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50096. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50097. AOSTOREINMETALMAPRED: boolean;
  50098. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50099. ENVIRONMENTBRDF: boolean;
  50100. ENVIRONMENTBRDF_RGBD: boolean;
  50101. NORMAL: boolean;
  50102. TANGENT: boolean;
  50103. BUMP: boolean;
  50104. BUMPDIRECTUV: number;
  50105. OBJECTSPACE_NORMALMAP: boolean;
  50106. PARALLAX: boolean;
  50107. PARALLAXOCCLUSION: boolean;
  50108. NORMALXYSCALE: boolean;
  50109. LIGHTMAP: boolean;
  50110. LIGHTMAPDIRECTUV: number;
  50111. USELIGHTMAPASSHADOWMAP: boolean;
  50112. GAMMALIGHTMAP: boolean;
  50113. RGBDLIGHTMAP: boolean;
  50114. REFLECTION: boolean;
  50115. REFLECTIONMAP_3D: boolean;
  50116. REFLECTIONMAP_SPHERICAL: boolean;
  50117. REFLECTIONMAP_PLANAR: boolean;
  50118. REFLECTIONMAP_CUBIC: boolean;
  50119. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50120. REFLECTIONMAP_PROJECTION: boolean;
  50121. REFLECTIONMAP_SKYBOX: boolean;
  50122. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50123. REFLECTIONMAP_EXPLICIT: boolean;
  50124. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50125. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50126. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50127. INVERTCUBICMAP: boolean;
  50128. USESPHERICALFROMREFLECTIONMAP: boolean;
  50129. USEIRRADIANCEMAP: boolean;
  50130. SPHERICAL_HARMONICS: boolean;
  50131. USESPHERICALINVERTEX: boolean;
  50132. REFLECTIONMAP_OPPOSITEZ: boolean;
  50133. LODINREFLECTIONALPHA: boolean;
  50134. GAMMAREFLECTION: boolean;
  50135. RGBDREFLECTION: boolean;
  50136. LINEARSPECULARREFLECTION: boolean;
  50137. RADIANCEOCCLUSION: boolean;
  50138. HORIZONOCCLUSION: boolean;
  50139. INSTANCES: boolean;
  50140. NUM_BONE_INFLUENCERS: number;
  50141. BonesPerMesh: number;
  50142. BONETEXTURE: boolean;
  50143. NONUNIFORMSCALING: boolean;
  50144. MORPHTARGETS: boolean;
  50145. MORPHTARGETS_NORMAL: boolean;
  50146. MORPHTARGETS_TANGENT: boolean;
  50147. MORPHTARGETS_UV: boolean;
  50148. NUM_MORPH_INFLUENCERS: number;
  50149. IMAGEPROCESSING: boolean;
  50150. VIGNETTE: boolean;
  50151. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50152. VIGNETTEBLENDMODEOPAQUE: boolean;
  50153. TONEMAPPING: boolean;
  50154. TONEMAPPING_ACES: boolean;
  50155. CONTRAST: boolean;
  50156. COLORCURVES: boolean;
  50157. COLORGRADING: boolean;
  50158. COLORGRADING3D: boolean;
  50159. SAMPLER3DGREENDEPTH: boolean;
  50160. SAMPLER3DBGRMAP: boolean;
  50161. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50162. EXPOSURE: boolean;
  50163. MULTIVIEW: boolean;
  50164. USEPHYSICALLIGHTFALLOFF: boolean;
  50165. USEGLTFLIGHTFALLOFF: boolean;
  50166. TWOSIDEDLIGHTING: boolean;
  50167. SHADOWFLOAT: boolean;
  50168. CLIPPLANE: boolean;
  50169. CLIPPLANE2: boolean;
  50170. CLIPPLANE3: boolean;
  50171. CLIPPLANE4: boolean;
  50172. POINTSIZE: boolean;
  50173. FOG: boolean;
  50174. LOGARITHMICDEPTH: boolean;
  50175. FORCENORMALFORWARD: boolean;
  50176. SPECULARAA: boolean;
  50177. CLEARCOAT: boolean;
  50178. CLEARCOAT_DEFAULTIOR: boolean;
  50179. CLEARCOAT_TEXTURE: boolean;
  50180. CLEARCOAT_TEXTUREDIRECTUV: number;
  50181. CLEARCOAT_BUMP: boolean;
  50182. CLEARCOAT_BUMPDIRECTUV: number;
  50183. CLEARCOAT_TINT: boolean;
  50184. CLEARCOAT_TINT_TEXTURE: boolean;
  50185. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50186. ANISOTROPIC: boolean;
  50187. ANISOTROPIC_TEXTURE: boolean;
  50188. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50189. BRDF_V_HEIGHT_CORRELATED: boolean;
  50190. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50191. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50192. SHEEN: boolean;
  50193. SHEEN_TEXTURE: boolean;
  50194. SHEEN_TEXTUREDIRECTUV: number;
  50195. SHEEN_LINKWITHALBEDO: boolean;
  50196. SUBSURFACE: boolean;
  50197. SS_REFRACTION: boolean;
  50198. SS_TRANSLUCENCY: boolean;
  50199. SS_SCATERRING: boolean;
  50200. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50201. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50202. SS_REFRACTIONMAP_3D: boolean;
  50203. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50204. SS_LODINREFRACTIONALPHA: boolean;
  50205. SS_GAMMAREFRACTION: boolean;
  50206. SS_RGBDREFRACTION: boolean;
  50207. SS_LINEARSPECULARREFRACTION: boolean;
  50208. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50209. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50210. UNLIT: boolean;
  50211. DEBUGMODE: number;
  50212. /**
  50213. * Initializes the PBR Material defines.
  50214. */
  50215. constructor();
  50216. /**
  50217. * Resets the PBR Material defines.
  50218. */
  50219. reset(): void;
  50220. }
  50221. /**
  50222. * The Physically based material base class of BJS.
  50223. *
  50224. * This offers the main features of a standard PBR material.
  50225. * For more information, please refer to the documentation :
  50226. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50227. */
  50228. export abstract class PBRBaseMaterial extends PushMaterial {
  50229. /**
  50230. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50231. */
  50232. static readonly PBRMATERIAL_OPAQUE: number;
  50233. /**
  50234. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50235. */
  50236. static readonly PBRMATERIAL_ALPHATEST: number;
  50237. /**
  50238. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50239. */
  50240. static readonly PBRMATERIAL_ALPHABLEND: number;
  50241. /**
  50242. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50243. * They are also discarded below the alpha cutoff threshold to improve performances.
  50244. */
  50245. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50246. /**
  50247. * Defines the default value of how much AO map is occluding the analytical lights
  50248. * (point spot...).
  50249. */
  50250. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50251. /**
  50252. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50253. */
  50254. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50255. /**
  50256. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50257. * to enhance interoperability with other engines.
  50258. */
  50259. static readonly LIGHTFALLOFF_GLTF: number;
  50260. /**
  50261. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50262. * to enhance interoperability with other materials.
  50263. */
  50264. static readonly LIGHTFALLOFF_STANDARD: number;
  50265. /**
  50266. * Intensity of the direct lights e.g. the four lights available in your scene.
  50267. * This impacts both the direct diffuse and specular highlights.
  50268. */
  50269. protected _directIntensity: number;
  50270. /**
  50271. * Intensity of the emissive part of the material.
  50272. * This helps controlling the emissive effect without modifying the emissive color.
  50273. */
  50274. protected _emissiveIntensity: number;
  50275. /**
  50276. * Intensity of the environment e.g. how much the environment will light the object
  50277. * either through harmonics for rough material or through the refelction for shiny ones.
  50278. */
  50279. protected _environmentIntensity: number;
  50280. /**
  50281. * This is a special control allowing the reduction of the specular highlights coming from the
  50282. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50283. */
  50284. protected _specularIntensity: number;
  50285. /**
  50286. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50287. */
  50288. private _lightingInfos;
  50289. /**
  50290. * Debug Control allowing disabling the bump map on this material.
  50291. */
  50292. protected _disableBumpMap: boolean;
  50293. /**
  50294. * AKA Diffuse Texture in standard nomenclature.
  50295. */
  50296. protected _albedoTexture: Nullable<BaseTexture>;
  50297. /**
  50298. * AKA Occlusion Texture in other nomenclature.
  50299. */
  50300. protected _ambientTexture: Nullable<BaseTexture>;
  50301. /**
  50302. * AKA Occlusion Texture Intensity in other nomenclature.
  50303. */
  50304. protected _ambientTextureStrength: number;
  50305. /**
  50306. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50307. * 1 means it completely occludes it
  50308. * 0 mean it has no impact
  50309. */
  50310. protected _ambientTextureImpactOnAnalyticalLights: number;
  50311. /**
  50312. * Stores the alpha values in a texture.
  50313. */
  50314. protected _opacityTexture: Nullable<BaseTexture>;
  50315. /**
  50316. * Stores the reflection values in a texture.
  50317. */
  50318. protected _reflectionTexture: Nullable<BaseTexture>;
  50319. /**
  50320. * Stores the emissive values in a texture.
  50321. */
  50322. protected _emissiveTexture: Nullable<BaseTexture>;
  50323. /**
  50324. * AKA Specular texture in other nomenclature.
  50325. */
  50326. protected _reflectivityTexture: Nullable<BaseTexture>;
  50327. /**
  50328. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50329. */
  50330. protected _metallicTexture: Nullable<BaseTexture>;
  50331. /**
  50332. * Specifies the metallic scalar of the metallic/roughness workflow.
  50333. * Can also be used to scale the metalness values of the metallic texture.
  50334. */
  50335. protected _metallic: Nullable<number>;
  50336. /**
  50337. * Specifies the roughness scalar of the metallic/roughness workflow.
  50338. * Can also be used to scale the roughness values of the metallic texture.
  50339. */
  50340. protected _roughness: Nullable<number>;
  50341. /**
  50342. * Specifies the an F0 factor to help configuring the material F0.
  50343. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50344. * to 0.5 the previously hard coded value stays the same.
  50345. * Can also be used to scale the F0 values of the metallic texture.
  50346. */
  50347. protected _metallicF0Factor: number;
  50348. /**
  50349. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50350. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50351. * your expectation as it multiplies with the texture data.
  50352. */
  50353. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50354. /**
  50355. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50356. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50357. */
  50358. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50359. /**
  50360. * Stores surface normal data used to displace a mesh in a texture.
  50361. */
  50362. protected _bumpTexture: Nullable<BaseTexture>;
  50363. /**
  50364. * Stores the pre-calculated light information of a mesh in a texture.
  50365. */
  50366. protected _lightmapTexture: Nullable<BaseTexture>;
  50367. /**
  50368. * The color of a material in ambient lighting.
  50369. */
  50370. protected _ambientColor: Color3;
  50371. /**
  50372. * AKA Diffuse Color in other nomenclature.
  50373. */
  50374. protected _albedoColor: Color3;
  50375. /**
  50376. * AKA Specular Color in other nomenclature.
  50377. */
  50378. protected _reflectivityColor: Color3;
  50379. /**
  50380. * The color applied when light is reflected from a material.
  50381. */
  50382. protected _reflectionColor: Color3;
  50383. /**
  50384. * The color applied when light is emitted from a material.
  50385. */
  50386. protected _emissiveColor: Color3;
  50387. /**
  50388. * AKA Glossiness in other nomenclature.
  50389. */
  50390. protected _microSurface: number;
  50391. /**
  50392. * Specifies that the material will use the light map as a show map.
  50393. */
  50394. protected _useLightmapAsShadowmap: boolean;
  50395. /**
  50396. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50397. * makes the reflect vector face the model (under horizon).
  50398. */
  50399. protected _useHorizonOcclusion: boolean;
  50400. /**
  50401. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50402. * too much the area relying on ambient texture to define their ambient occlusion.
  50403. */
  50404. protected _useRadianceOcclusion: boolean;
  50405. /**
  50406. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50407. */
  50408. protected _useAlphaFromAlbedoTexture: boolean;
  50409. /**
  50410. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50411. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50412. */
  50413. protected _useSpecularOverAlpha: boolean;
  50414. /**
  50415. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50416. */
  50417. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50418. /**
  50419. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50420. */
  50421. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50422. /**
  50423. * Specifies if the metallic texture contains the roughness information in its green channel.
  50424. */
  50425. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50426. /**
  50427. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50428. */
  50429. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50430. /**
  50431. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50432. */
  50433. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50434. /**
  50435. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50436. */
  50437. protected _useAmbientInGrayScale: boolean;
  50438. /**
  50439. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50440. * The material will try to infer what glossiness each pixel should be.
  50441. */
  50442. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50443. /**
  50444. * Defines the falloff type used in this material.
  50445. * It by default is Physical.
  50446. */
  50447. protected _lightFalloff: number;
  50448. /**
  50449. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50450. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50451. */
  50452. protected _useRadianceOverAlpha: boolean;
  50453. /**
  50454. * Allows using an object space normal map (instead of tangent space).
  50455. */
  50456. protected _useObjectSpaceNormalMap: boolean;
  50457. /**
  50458. * Allows using the bump map in parallax mode.
  50459. */
  50460. protected _useParallax: boolean;
  50461. /**
  50462. * Allows using the bump map in parallax occlusion mode.
  50463. */
  50464. protected _useParallaxOcclusion: boolean;
  50465. /**
  50466. * Controls the scale bias of the parallax mode.
  50467. */
  50468. protected _parallaxScaleBias: number;
  50469. /**
  50470. * If sets to true, disables all the lights affecting the material.
  50471. */
  50472. protected _disableLighting: boolean;
  50473. /**
  50474. * Number of Simultaneous lights allowed on the material.
  50475. */
  50476. protected _maxSimultaneousLights: number;
  50477. /**
  50478. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50479. */
  50480. protected _invertNormalMapX: boolean;
  50481. /**
  50482. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50483. */
  50484. protected _invertNormalMapY: boolean;
  50485. /**
  50486. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50487. */
  50488. protected _twoSidedLighting: boolean;
  50489. /**
  50490. * Defines the alpha limits in alpha test mode.
  50491. */
  50492. protected _alphaCutOff: number;
  50493. /**
  50494. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50495. */
  50496. protected _forceAlphaTest: boolean;
  50497. /**
  50498. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50499. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50500. */
  50501. protected _useAlphaFresnel: boolean;
  50502. /**
  50503. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50504. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50505. */
  50506. protected _useLinearAlphaFresnel: boolean;
  50507. /**
  50508. * The transparency mode of the material.
  50509. */
  50510. protected _transparencyMode: Nullable<number>;
  50511. /**
  50512. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50513. * from cos thetav and roughness:
  50514. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50515. */
  50516. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50517. /**
  50518. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50519. */
  50520. protected _forceIrradianceInFragment: boolean;
  50521. /**
  50522. * Force normal to face away from face.
  50523. */
  50524. protected _forceNormalForward: boolean;
  50525. /**
  50526. * Enables specular anti aliasing in the PBR shader.
  50527. * It will both interacts on the Geometry for analytical and IBL lighting.
  50528. * It also prefilter the roughness map based on the bump values.
  50529. */
  50530. protected _enableSpecularAntiAliasing: boolean;
  50531. /**
  50532. * Default configuration related to image processing available in the PBR Material.
  50533. */
  50534. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50535. /**
  50536. * Keep track of the image processing observer to allow dispose and replace.
  50537. */
  50538. private _imageProcessingObserver;
  50539. /**
  50540. * Attaches a new image processing configuration to the PBR Material.
  50541. * @param configuration
  50542. */
  50543. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50544. /**
  50545. * Stores the available render targets.
  50546. */
  50547. private _renderTargets;
  50548. /**
  50549. * Sets the global ambient color for the material used in lighting calculations.
  50550. */
  50551. private _globalAmbientColor;
  50552. /**
  50553. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50554. */
  50555. private _useLogarithmicDepth;
  50556. /**
  50557. * If set to true, no lighting calculations will be applied.
  50558. */
  50559. private _unlit;
  50560. private _debugMode;
  50561. /**
  50562. * @hidden
  50563. * This is reserved for the inspector.
  50564. * Defines the material debug mode.
  50565. * It helps seeing only some components of the material while troubleshooting.
  50566. */
  50567. debugMode: number;
  50568. /**
  50569. * @hidden
  50570. * This is reserved for the inspector.
  50571. * Specify from where on screen the debug mode should start.
  50572. * The value goes from -1 (full screen) to 1 (not visible)
  50573. * It helps with side by side comparison against the final render
  50574. * This defaults to -1
  50575. */
  50576. private debugLimit;
  50577. /**
  50578. * @hidden
  50579. * This is reserved for the inspector.
  50580. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50581. * You can use the factor to better multiply the final value.
  50582. */
  50583. private debugFactor;
  50584. /**
  50585. * Defines the clear coat layer parameters for the material.
  50586. */
  50587. readonly clearCoat: PBRClearCoatConfiguration;
  50588. /**
  50589. * Defines the anisotropic parameters for the material.
  50590. */
  50591. readonly anisotropy: PBRAnisotropicConfiguration;
  50592. /**
  50593. * Defines the BRDF parameters for the material.
  50594. */
  50595. readonly brdf: PBRBRDFConfiguration;
  50596. /**
  50597. * Defines the Sheen parameters for the material.
  50598. */
  50599. readonly sheen: PBRSheenConfiguration;
  50600. /**
  50601. * Defines the SubSurface parameters for the material.
  50602. */
  50603. readonly subSurface: PBRSubSurfaceConfiguration;
  50604. /**
  50605. * Custom callback helping to override the default shader used in the material.
  50606. */
  50607. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50608. protected _rebuildInParallel: boolean;
  50609. /**
  50610. * Instantiates a new PBRMaterial instance.
  50611. *
  50612. * @param name The material name
  50613. * @param scene The scene the material will be use in.
  50614. */
  50615. constructor(name: string, scene: Scene);
  50616. /**
  50617. * Gets a boolean indicating that current material needs to register RTT
  50618. */
  50619. readonly hasRenderTargetTextures: boolean;
  50620. /**
  50621. * Gets the name of the material class.
  50622. */
  50623. getClassName(): string;
  50624. /**
  50625. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50626. */
  50627. /**
  50628. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50629. */
  50630. useLogarithmicDepth: boolean;
  50631. /**
  50632. * Gets the current transparency mode.
  50633. */
  50634. /**
  50635. * Sets the transparency mode of the material.
  50636. *
  50637. * | Value | Type | Description |
  50638. * | ----- | ----------------------------------- | ----------- |
  50639. * | 0 | OPAQUE | |
  50640. * | 1 | ALPHATEST | |
  50641. * | 2 | ALPHABLEND | |
  50642. * | 3 | ALPHATESTANDBLEND | |
  50643. *
  50644. */
  50645. transparencyMode: Nullable<number>;
  50646. /**
  50647. * Returns true if alpha blending should be disabled.
  50648. */
  50649. private readonly _disableAlphaBlending;
  50650. /**
  50651. * Specifies whether or not this material should be rendered in alpha blend mode.
  50652. */
  50653. needAlphaBlending(): boolean;
  50654. /**
  50655. * Specifies if the mesh will require alpha blending.
  50656. * @param mesh - BJS mesh.
  50657. */
  50658. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50659. /**
  50660. * Specifies whether or not this material should be rendered in alpha test mode.
  50661. */
  50662. needAlphaTesting(): boolean;
  50663. /**
  50664. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50665. */
  50666. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50667. /**
  50668. * Gets the texture used for the alpha test.
  50669. */
  50670. getAlphaTestTexture(): Nullable<BaseTexture>;
  50671. /**
  50672. * Specifies that the submesh is ready to be used.
  50673. * @param mesh - BJS mesh.
  50674. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50675. * @param useInstances - Specifies that instances should be used.
  50676. * @returns - boolean indicating that the submesh is ready or not.
  50677. */
  50678. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50679. /**
  50680. * Specifies if the material uses metallic roughness workflow.
  50681. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50682. */
  50683. isMetallicWorkflow(): boolean;
  50684. private _prepareEffect;
  50685. private _prepareDefines;
  50686. /**
  50687. * Force shader compilation
  50688. */
  50689. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50690. /**
  50691. * Initializes the uniform buffer layout for the shader.
  50692. */
  50693. buildUniformLayout(): void;
  50694. /**
  50695. * Unbinds the material from the mesh
  50696. */
  50697. unbind(): void;
  50698. /**
  50699. * Binds the submesh data.
  50700. * @param world - The world matrix.
  50701. * @param mesh - The BJS mesh.
  50702. * @param subMesh - A submesh of the BJS mesh.
  50703. */
  50704. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50705. /**
  50706. * Returns the animatable textures.
  50707. * @returns - Array of animatable textures.
  50708. */
  50709. getAnimatables(): IAnimatable[];
  50710. /**
  50711. * Returns the texture used for reflections.
  50712. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50713. */
  50714. private _getReflectionTexture;
  50715. /**
  50716. * Returns an array of the actively used textures.
  50717. * @returns - Array of BaseTextures
  50718. */
  50719. getActiveTextures(): BaseTexture[];
  50720. /**
  50721. * Checks to see if a texture is used in the material.
  50722. * @param texture - Base texture to use.
  50723. * @returns - Boolean specifying if a texture is used in the material.
  50724. */
  50725. hasTexture(texture: BaseTexture): boolean;
  50726. /**
  50727. * Disposes the resources of the material.
  50728. * @param forceDisposeEffect - Forces the disposal of effects.
  50729. * @param forceDisposeTextures - Forces the disposal of all textures.
  50730. */
  50731. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50732. }
  50733. }
  50734. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50735. import { Nullable } from "babylonjs/types";
  50736. import { Scene } from "babylonjs/scene";
  50737. import { Color3 } from "babylonjs/Maths/math.color";
  50738. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50739. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50741. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50742. /**
  50743. * The Physically based material of BJS.
  50744. *
  50745. * This offers the main features of a standard PBR material.
  50746. * For more information, please refer to the documentation :
  50747. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50748. */
  50749. export class PBRMaterial extends PBRBaseMaterial {
  50750. /**
  50751. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50752. */
  50753. static readonly PBRMATERIAL_OPAQUE: number;
  50754. /**
  50755. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50756. */
  50757. static readonly PBRMATERIAL_ALPHATEST: number;
  50758. /**
  50759. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50760. */
  50761. static readonly PBRMATERIAL_ALPHABLEND: number;
  50762. /**
  50763. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50764. * They are also discarded below the alpha cutoff threshold to improve performances.
  50765. */
  50766. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50767. /**
  50768. * Defines the default value of how much AO map is occluding the analytical lights
  50769. * (point spot...).
  50770. */
  50771. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50772. /**
  50773. * Intensity of the direct lights e.g. the four lights available in your scene.
  50774. * This impacts both the direct diffuse and specular highlights.
  50775. */
  50776. directIntensity: number;
  50777. /**
  50778. * Intensity of the emissive part of the material.
  50779. * This helps controlling the emissive effect without modifying the emissive color.
  50780. */
  50781. emissiveIntensity: number;
  50782. /**
  50783. * Intensity of the environment e.g. how much the environment will light the object
  50784. * either through harmonics for rough material or through the refelction for shiny ones.
  50785. */
  50786. environmentIntensity: number;
  50787. /**
  50788. * This is a special control allowing the reduction of the specular highlights coming from the
  50789. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50790. */
  50791. specularIntensity: number;
  50792. /**
  50793. * Debug Control allowing disabling the bump map on this material.
  50794. */
  50795. disableBumpMap: boolean;
  50796. /**
  50797. * AKA Diffuse Texture in standard nomenclature.
  50798. */
  50799. albedoTexture: BaseTexture;
  50800. /**
  50801. * AKA Occlusion Texture in other nomenclature.
  50802. */
  50803. ambientTexture: BaseTexture;
  50804. /**
  50805. * AKA Occlusion Texture Intensity in other nomenclature.
  50806. */
  50807. ambientTextureStrength: number;
  50808. /**
  50809. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50810. * 1 means it completely occludes it
  50811. * 0 mean it has no impact
  50812. */
  50813. ambientTextureImpactOnAnalyticalLights: number;
  50814. /**
  50815. * Stores the alpha values in a texture.
  50816. */
  50817. opacityTexture: BaseTexture;
  50818. /**
  50819. * Stores the reflection values in a texture.
  50820. */
  50821. reflectionTexture: Nullable<BaseTexture>;
  50822. /**
  50823. * Stores the emissive values in a texture.
  50824. */
  50825. emissiveTexture: BaseTexture;
  50826. /**
  50827. * AKA Specular texture in other nomenclature.
  50828. */
  50829. reflectivityTexture: BaseTexture;
  50830. /**
  50831. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50832. */
  50833. metallicTexture: BaseTexture;
  50834. /**
  50835. * Specifies the metallic scalar of the metallic/roughness workflow.
  50836. * Can also be used to scale the metalness values of the metallic texture.
  50837. */
  50838. metallic: Nullable<number>;
  50839. /**
  50840. * Specifies the roughness scalar of the metallic/roughness workflow.
  50841. * Can also be used to scale the roughness values of the metallic texture.
  50842. */
  50843. roughness: Nullable<number>;
  50844. /**
  50845. * Specifies the an F0 factor to help configuring the material F0.
  50846. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50847. * to 0.5 the previously hard coded value stays the same.
  50848. * Can also be used to scale the F0 values of the metallic texture.
  50849. */
  50850. metallicF0Factor: number;
  50851. /**
  50852. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50853. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50854. * your expectation as it multiplies with the texture data.
  50855. */
  50856. useMetallicF0FactorFromMetallicTexture: boolean;
  50857. /**
  50858. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50859. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50860. */
  50861. microSurfaceTexture: BaseTexture;
  50862. /**
  50863. * Stores surface normal data used to displace a mesh in a texture.
  50864. */
  50865. bumpTexture: BaseTexture;
  50866. /**
  50867. * Stores the pre-calculated light information of a mesh in a texture.
  50868. */
  50869. lightmapTexture: BaseTexture;
  50870. /**
  50871. * Stores the refracted light information in a texture.
  50872. */
  50873. refractionTexture: Nullable<BaseTexture>;
  50874. /**
  50875. * The color of a material in ambient lighting.
  50876. */
  50877. ambientColor: Color3;
  50878. /**
  50879. * AKA Diffuse Color in other nomenclature.
  50880. */
  50881. albedoColor: Color3;
  50882. /**
  50883. * AKA Specular Color in other nomenclature.
  50884. */
  50885. reflectivityColor: Color3;
  50886. /**
  50887. * The color reflected from the material.
  50888. */
  50889. reflectionColor: Color3;
  50890. /**
  50891. * The color emitted from the material.
  50892. */
  50893. emissiveColor: Color3;
  50894. /**
  50895. * AKA Glossiness in other nomenclature.
  50896. */
  50897. microSurface: number;
  50898. /**
  50899. * source material index of refraction (IOR)' / 'destination material IOR.
  50900. */
  50901. indexOfRefraction: number;
  50902. /**
  50903. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50904. */
  50905. invertRefractionY: boolean;
  50906. /**
  50907. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50908. * Materials half opaque for instance using refraction could benefit from this control.
  50909. */
  50910. linkRefractionWithTransparency: boolean;
  50911. /**
  50912. * If true, the light map contains occlusion information instead of lighting info.
  50913. */
  50914. useLightmapAsShadowmap: boolean;
  50915. /**
  50916. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50917. */
  50918. useAlphaFromAlbedoTexture: boolean;
  50919. /**
  50920. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50921. */
  50922. forceAlphaTest: boolean;
  50923. /**
  50924. * Defines the alpha limits in alpha test mode.
  50925. */
  50926. alphaCutOff: number;
  50927. /**
  50928. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50929. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50930. */
  50931. useSpecularOverAlpha: boolean;
  50932. /**
  50933. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50934. */
  50935. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50936. /**
  50937. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50938. */
  50939. useRoughnessFromMetallicTextureAlpha: boolean;
  50940. /**
  50941. * Specifies if the metallic texture contains the roughness information in its green channel.
  50942. */
  50943. useRoughnessFromMetallicTextureGreen: boolean;
  50944. /**
  50945. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50946. */
  50947. useMetallnessFromMetallicTextureBlue: boolean;
  50948. /**
  50949. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50950. */
  50951. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50952. /**
  50953. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50954. */
  50955. useAmbientInGrayScale: boolean;
  50956. /**
  50957. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50958. * The material will try to infer what glossiness each pixel should be.
  50959. */
  50960. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50961. /**
  50962. * BJS is using an harcoded light falloff based on a manually sets up range.
  50963. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50964. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50965. */
  50966. /**
  50967. * BJS is using an harcoded light falloff based on a manually sets up range.
  50968. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50969. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50970. */
  50971. usePhysicalLightFalloff: boolean;
  50972. /**
  50973. * In order to support the falloff compatibility with gltf, a special mode has been added
  50974. * to reproduce the gltf light falloff.
  50975. */
  50976. /**
  50977. * In order to support the falloff compatibility with gltf, a special mode has been added
  50978. * to reproduce the gltf light falloff.
  50979. */
  50980. useGLTFLightFalloff: boolean;
  50981. /**
  50982. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50983. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50984. */
  50985. useRadianceOverAlpha: boolean;
  50986. /**
  50987. * Allows using an object space normal map (instead of tangent space).
  50988. */
  50989. useObjectSpaceNormalMap: boolean;
  50990. /**
  50991. * Allows using the bump map in parallax mode.
  50992. */
  50993. useParallax: boolean;
  50994. /**
  50995. * Allows using the bump map in parallax occlusion mode.
  50996. */
  50997. useParallaxOcclusion: boolean;
  50998. /**
  50999. * Controls the scale bias of the parallax mode.
  51000. */
  51001. parallaxScaleBias: number;
  51002. /**
  51003. * If sets to true, disables all the lights affecting the material.
  51004. */
  51005. disableLighting: boolean;
  51006. /**
  51007. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51008. */
  51009. forceIrradianceInFragment: boolean;
  51010. /**
  51011. * Number of Simultaneous lights allowed on the material.
  51012. */
  51013. maxSimultaneousLights: number;
  51014. /**
  51015. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51016. */
  51017. invertNormalMapX: boolean;
  51018. /**
  51019. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51020. */
  51021. invertNormalMapY: boolean;
  51022. /**
  51023. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51024. */
  51025. twoSidedLighting: boolean;
  51026. /**
  51027. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51028. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51029. */
  51030. useAlphaFresnel: boolean;
  51031. /**
  51032. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51033. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51034. */
  51035. useLinearAlphaFresnel: boolean;
  51036. /**
  51037. * Let user defines the brdf lookup texture used for IBL.
  51038. * A default 8bit version is embedded but you could point at :
  51039. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51040. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51041. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51042. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51043. */
  51044. environmentBRDFTexture: Nullable<BaseTexture>;
  51045. /**
  51046. * Force normal to face away from face.
  51047. */
  51048. forceNormalForward: boolean;
  51049. /**
  51050. * Enables specular anti aliasing in the PBR shader.
  51051. * It will both interacts on the Geometry for analytical and IBL lighting.
  51052. * It also prefilter the roughness map based on the bump values.
  51053. */
  51054. enableSpecularAntiAliasing: boolean;
  51055. /**
  51056. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51057. * makes the reflect vector face the model (under horizon).
  51058. */
  51059. useHorizonOcclusion: boolean;
  51060. /**
  51061. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51062. * too much the area relying on ambient texture to define their ambient occlusion.
  51063. */
  51064. useRadianceOcclusion: boolean;
  51065. /**
  51066. * If set to true, no lighting calculations will be applied.
  51067. */
  51068. unlit: boolean;
  51069. /**
  51070. * Gets the image processing configuration used either in this material.
  51071. */
  51072. /**
  51073. * Sets the Default image processing configuration used either in the this material.
  51074. *
  51075. * If sets to null, the scene one is in use.
  51076. */
  51077. imageProcessingConfiguration: ImageProcessingConfiguration;
  51078. /**
  51079. * Gets wether the color curves effect is enabled.
  51080. */
  51081. /**
  51082. * Sets wether the color curves effect is enabled.
  51083. */
  51084. cameraColorCurvesEnabled: boolean;
  51085. /**
  51086. * Gets wether the color grading effect is enabled.
  51087. */
  51088. /**
  51089. * Gets wether the color grading effect is enabled.
  51090. */
  51091. cameraColorGradingEnabled: boolean;
  51092. /**
  51093. * Gets wether tonemapping is enabled or not.
  51094. */
  51095. /**
  51096. * Sets wether tonemapping is enabled or not
  51097. */
  51098. cameraToneMappingEnabled: boolean;
  51099. /**
  51100. * The camera exposure used on this material.
  51101. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51102. * This corresponds to a photographic exposure.
  51103. */
  51104. /**
  51105. * The camera exposure used on this material.
  51106. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51107. * This corresponds to a photographic exposure.
  51108. */
  51109. cameraExposure: number;
  51110. /**
  51111. * Gets The camera contrast used on this material.
  51112. */
  51113. /**
  51114. * Sets The camera contrast used on this material.
  51115. */
  51116. cameraContrast: number;
  51117. /**
  51118. * Gets the Color Grading 2D Lookup Texture.
  51119. */
  51120. /**
  51121. * Sets the Color Grading 2D Lookup Texture.
  51122. */
  51123. cameraColorGradingTexture: Nullable<BaseTexture>;
  51124. /**
  51125. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51126. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51127. * 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;
  51128. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51129. */
  51130. /**
  51131. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51132. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51133. * 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;
  51134. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51135. */
  51136. cameraColorCurves: Nullable<ColorCurves>;
  51137. /**
  51138. * Instantiates a new PBRMaterial instance.
  51139. *
  51140. * @param name The material name
  51141. * @param scene The scene the material will be use in.
  51142. */
  51143. constructor(name: string, scene: Scene);
  51144. /**
  51145. * Returns the name of this material class.
  51146. */
  51147. getClassName(): string;
  51148. /**
  51149. * Makes a duplicate of the current material.
  51150. * @param name - name to use for the new material.
  51151. */
  51152. clone(name: string): PBRMaterial;
  51153. /**
  51154. * Serializes this PBR Material.
  51155. * @returns - An object with the serialized material.
  51156. */
  51157. serialize(): any;
  51158. /**
  51159. * Parses a PBR Material from a serialized object.
  51160. * @param source - Serialized object.
  51161. * @param scene - BJS scene instance.
  51162. * @param rootUrl - url for the scene object
  51163. * @returns - PBRMaterial
  51164. */
  51165. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51166. }
  51167. }
  51168. declare module "babylonjs/Misc/dds" {
  51169. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51171. import { Nullable } from "babylonjs/types";
  51172. import { Scene } from "babylonjs/scene";
  51173. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51174. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51175. /**
  51176. * Direct draw surface info
  51177. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51178. */
  51179. export interface DDSInfo {
  51180. /**
  51181. * Width of the texture
  51182. */
  51183. width: number;
  51184. /**
  51185. * Width of the texture
  51186. */
  51187. height: number;
  51188. /**
  51189. * Number of Mipmaps for the texture
  51190. * @see https://en.wikipedia.org/wiki/Mipmap
  51191. */
  51192. mipmapCount: number;
  51193. /**
  51194. * If the textures format is a known fourCC format
  51195. * @see https://www.fourcc.org/
  51196. */
  51197. isFourCC: boolean;
  51198. /**
  51199. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51200. */
  51201. isRGB: boolean;
  51202. /**
  51203. * If the texture is a lumincance format
  51204. */
  51205. isLuminance: boolean;
  51206. /**
  51207. * If this is a cube texture
  51208. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51209. */
  51210. isCube: boolean;
  51211. /**
  51212. * If the texture is a compressed format eg. FOURCC_DXT1
  51213. */
  51214. isCompressed: boolean;
  51215. /**
  51216. * The dxgiFormat of the texture
  51217. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51218. */
  51219. dxgiFormat: number;
  51220. /**
  51221. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51222. */
  51223. textureType: number;
  51224. /**
  51225. * Sphericle polynomial created for the dds texture
  51226. */
  51227. sphericalPolynomial?: SphericalPolynomial;
  51228. }
  51229. /**
  51230. * Class used to provide DDS decompression tools
  51231. */
  51232. export class DDSTools {
  51233. /**
  51234. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51235. */
  51236. static StoreLODInAlphaChannel: boolean;
  51237. /**
  51238. * Gets DDS information from an array buffer
  51239. * @param arrayBuffer defines the array buffer to read data from
  51240. * @returns the DDS information
  51241. */
  51242. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51243. private static _FloatView;
  51244. private static _Int32View;
  51245. private static _ToHalfFloat;
  51246. private static _FromHalfFloat;
  51247. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51248. private static _GetHalfFloatRGBAArrayBuffer;
  51249. private static _GetFloatRGBAArrayBuffer;
  51250. private static _GetFloatAsUIntRGBAArrayBuffer;
  51251. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51252. private static _GetRGBAArrayBuffer;
  51253. private static _ExtractLongWordOrder;
  51254. private static _GetRGBArrayBuffer;
  51255. private static _GetLuminanceArrayBuffer;
  51256. /**
  51257. * Uploads DDS Levels to a Babylon Texture
  51258. * @hidden
  51259. */
  51260. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51261. }
  51262. module "babylonjs/Engines/thinEngine" {
  51263. interface ThinEngine {
  51264. /**
  51265. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51266. * @param rootUrl defines the url where the file to load is located
  51267. * @param scene defines the current scene
  51268. * @param lodScale defines scale to apply to the mip map selection
  51269. * @param lodOffset defines offset to apply to the mip map selection
  51270. * @param onLoad defines an optional callback raised when the texture is loaded
  51271. * @param onError defines an optional callback raised if there is an issue to load the texture
  51272. * @param format defines the format of the data
  51273. * @param forcedExtension defines the extension to use to pick the right loader
  51274. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51275. * @returns the cube texture as an InternalTexture
  51276. */
  51277. 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;
  51278. }
  51279. }
  51280. }
  51281. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51282. import { Nullable } from "babylonjs/types";
  51283. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51284. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51285. /**
  51286. * Implementation of the DDS Texture Loader.
  51287. * @hidden
  51288. */
  51289. export class _DDSTextureLoader implements IInternalTextureLoader {
  51290. /**
  51291. * Defines wether the loader supports cascade loading the different faces.
  51292. */
  51293. readonly supportCascades: boolean;
  51294. /**
  51295. * This returns if the loader support the current file information.
  51296. * @param extension defines the file extension of the file being loaded
  51297. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51298. * @param fallback defines the fallback internal texture if any
  51299. * @param isBase64 defines whether the texture is encoded as a base64
  51300. * @param isBuffer defines whether the texture data are stored as a buffer
  51301. * @returns true if the loader can load the specified file
  51302. */
  51303. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51304. /**
  51305. * Transform the url before loading if required.
  51306. * @param rootUrl the url of the texture
  51307. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51308. * @returns the transformed texture
  51309. */
  51310. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51311. /**
  51312. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51313. * @param rootUrl the url of the texture
  51314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51315. * @returns the fallback texture
  51316. */
  51317. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51318. /**
  51319. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51320. * @param data contains the texture data
  51321. * @param texture defines the BabylonJS internal texture
  51322. * @param createPolynomials will be true if polynomials have been requested
  51323. * @param onLoad defines the callback to trigger once the texture is ready
  51324. * @param onError defines the callback to trigger in case of error
  51325. */
  51326. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51327. /**
  51328. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51329. * @param data contains the texture data
  51330. * @param texture defines the BabylonJS internal texture
  51331. * @param callback defines the method to call once ready to upload
  51332. */
  51333. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51334. }
  51335. }
  51336. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51337. import { Nullable } from "babylonjs/types";
  51338. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51339. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51340. /**
  51341. * Implementation of the ENV Texture Loader.
  51342. * @hidden
  51343. */
  51344. export class _ENVTextureLoader implements IInternalTextureLoader {
  51345. /**
  51346. * Defines wether the loader supports cascade loading the different faces.
  51347. */
  51348. readonly supportCascades: boolean;
  51349. /**
  51350. * This returns if the loader support the current file information.
  51351. * @param extension defines the file extension of the file being loaded
  51352. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51353. * @param fallback defines the fallback internal texture if any
  51354. * @param isBase64 defines whether the texture is encoded as a base64
  51355. * @param isBuffer defines whether the texture data are stored as a buffer
  51356. * @returns true if the loader can load the specified file
  51357. */
  51358. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51359. /**
  51360. * Transform the url before loading if required.
  51361. * @param rootUrl the url of the texture
  51362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51363. * @returns the transformed texture
  51364. */
  51365. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51366. /**
  51367. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51368. * @param rootUrl the url of the texture
  51369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51370. * @returns the fallback texture
  51371. */
  51372. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51373. /**
  51374. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51375. * @param data contains the texture data
  51376. * @param texture defines the BabylonJS internal texture
  51377. * @param createPolynomials will be true if polynomials have been requested
  51378. * @param onLoad defines the callback to trigger once the texture is ready
  51379. * @param onError defines the callback to trigger in case of error
  51380. */
  51381. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51382. /**
  51383. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51384. * @param data contains the texture data
  51385. * @param texture defines the BabylonJS internal texture
  51386. * @param callback defines the method to call once ready to upload
  51387. */
  51388. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51389. }
  51390. }
  51391. declare module "babylonjs/Misc/khronosTextureContainer" {
  51392. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51393. /**
  51394. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51395. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51396. */
  51397. export class KhronosTextureContainer {
  51398. /** contents of the KTX container file */
  51399. arrayBuffer: any;
  51400. private static HEADER_LEN;
  51401. private static COMPRESSED_2D;
  51402. private static COMPRESSED_3D;
  51403. private static TEX_2D;
  51404. private static TEX_3D;
  51405. /**
  51406. * Gets the openGL type
  51407. */
  51408. glType: number;
  51409. /**
  51410. * Gets the openGL type size
  51411. */
  51412. glTypeSize: number;
  51413. /**
  51414. * Gets the openGL format
  51415. */
  51416. glFormat: number;
  51417. /**
  51418. * Gets the openGL internal format
  51419. */
  51420. glInternalFormat: number;
  51421. /**
  51422. * Gets the base internal format
  51423. */
  51424. glBaseInternalFormat: number;
  51425. /**
  51426. * Gets image width in pixel
  51427. */
  51428. pixelWidth: number;
  51429. /**
  51430. * Gets image height in pixel
  51431. */
  51432. pixelHeight: number;
  51433. /**
  51434. * Gets image depth in pixels
  51435. */
  51436. pixelDepth: number;
  51437. /**
  51438. * Gets the number of array elements
  51439. */
  51440. numberOfArrayElements: number;
  51441. /**
  51442. * Gets the number of faces
  51443. */
  51444. numberOfFaces: number;
  51445. /**
  51446. * Gets the number of mipmap levels
  51447. */
  51448. numberOfMipmapLevels: number;
  51449. /**
  51450. * Gets the bytes of key value data
  51451. */
  51452. bytesOfKeyValueData: number;
  51453. /**
  51454. * Gets the load type
  51455. */
  51456. loadType: number;
  51457. /**
  51458. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51459. */
  51460. isInvalid: boolean;
  51461. /**
  51462. * Creates a new KhronosTextureContainer
  51463. * @param arrayBuffer contents of the KTX container file
  51464. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51465. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51466. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51467. */
  51468. constructor(
  51469. /** contents of the KTX container file */
  51470. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51471. /**
  51472. * Uploads KTX content to a Babylon Texture.
  51473. * It is assumed that the texture has already been created & is currently bound
  51474. * @hidden
  51475. */
  51476. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51477. private _upload2DCompressedLevels;
  51478. }
  51479. }
  51480. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51481. import { Nullable } from "babylonjs/types";
  51482. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51483. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51484. /**
  51485. * Implementation of the KTX Texture Loader.
  51486. * @hidden
  51487. */
  51488. export class _KTXTextureLoader implements IInternalTextureLoader {
  51489. /**
  51490. * Defines wether the loader supports cascade loading the different faces.
  51491. */
  51492. readonly supportCascades: boolean;
  51493. /**
  51494. * This returns if the loader support the current file information.
  51495. * @param extension defines the file extension of the file being loaded
  51496. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51497. * @param fallback defines the fallback internal texture if any
  51498. * @param isBase64 defines whether the texture is encoded as a base64
  51499. * @param isBuffer defines whether the texture data are stored as a buffer
  51500. * @returns true if the loader can load the specified file
  51501. */
  51502. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51503. /**
  51504. * Transform the url before loading if required.
  51505. * @param rootUrl the url of the texture
  51506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51507. * @returns the transformed texture
  51508. */
  51509. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51510. /**
  51511. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51512. * @param rootUrl the url of the texture
  51513. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51514. * @returns the fallback texture
  51515. */
  51516. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51517. /**
  51518. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51519. * @param data contains the texture data
  51520. * @param texture defines the BabylonJS internal texture
  51521. * @param createPolynomials will be true if polynomials have been requested
  51522. * @param onLoad defines the callback to trigger once the texture is ready
  51523. * @param onError defines the callback to trigger in case of error
  51524. */
  51525. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51526. /**
  51527. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51528. * @param data contains the texture data
  51529. * @param texture defines the BabylonJS internal texture
  51530. * @param callback defines the method to call once ready to upload
  51531. */
  51532. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51533. }
  51534. }
  51535. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51536. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51537. import { Scene } from "babylonjs/scene";
  51538. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51539. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51540. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51541. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51542. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  51543. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51545. /**
  51546. * Options for the default xr helper
  51547. */
  51548. export class WebXRDefaultExperienceOptions {
  51549. /**
  51550. * Floor meshes that should be used for teleporting
  51551. */
  51552. floorMeshes: Array<AbstractMesh>;
  51553. /**
  51554. * Enable or disable default UI to enter XR
  51555. */
  51556. disableDefaultUI: boolean;
  51557. }
  51558. /**
  51559. * Default experience which provides a similar setup to the previous webVRExperience
  51560. */
  51561. export class WebXRDefaultExperience {
  51562. /**
  51563. * Base experience
  51564. */
  51565. baseExperience: WebXRExperienceHelper;
  51566. /**
  51567. * Input experience extension
  51568. */
  51569. input: WebXRInput;
  51570. /**
  51571. * Loads the controller models
  51572. */
  51573. controllerModelLoader: WebXRControllerModelLoader;
  51574. /**
  51575. * Enables laser pointer and selection
  51576. */
  51577. pointerSelection: WebXRControllerPointerSelection;
  51578. /**
  51579. * Enables teleportation
  51580. */
  51581. teleportation: WebXRControllerTeleportation;
  51582. /**
  51583. * Enables ui for enetering/exiting xr
  51584. */
  51585. enterExitUI: WebXREnterExitUI;
  51586. /**
  51587. * Default target xr should render to
  51588. */
  51589. renderTarget: WebXRRenderTarget;
  51590. /**
  51591. * Creates the default xr experience
  51592. * @param scene scene
  51593. * @param options options for basic configuration
  51594. * @returns resulting WebXRDefaultExperience
  51595. */
  51596. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51597. private constructor();
  51598. /**
  51599. * DIsposes of the experience helper
  51600. */
  51601. dispose(): void;
  51602. }
  51603. }
  51604. declare module "babylonjs/Helpers/sceneHelpers" {
  51605. import { Nullable } from "babylonjs/types";
  51606. import { Mesh } from "babylonjs/Meshes/mesh";
  51607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51608. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51609. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51610. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51611. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51612. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51613. import "babylonjs/Meshes/Builders/boxBuilder";
  51614. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51615. /** @hidden */
  51616. export var _forceSceneHelpersToBundle: boolean;
  51617. module "babylonjs/scene" {
  51618. interface Scene {
  51619. /**
  51620. * Creates a default light for the scene.
  51621. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51622. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51623. */
  51624. createDefaultLight(replace?: boolean): void;
  51625. /**
  51626. * Creates a default camera for the scene.
  51627. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51628. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51629. * @param replace has default false, when true replaces the active camera in the scene
  51630. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51631. */
  51632. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51633. /**
  51634. * Creates a default camera and a default light.
  51635. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51636. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51637. * @param replace has the default false, when true replaces the active camera/light in the scene
  51638. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51639. */
  51640. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51641. /**
  51642. * Creates a new sky box
  51643. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51644. * @param environmentTexture defines the texture to use as environment texture
  51645. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51646. * @param scale defines the overall scale of the skybox
  51647. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51648. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51649. * @returns a new mesh holding the sky box
  51650. */
  51651. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51652. /**
  51653. * Creates a new environment
  51654. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51655. * @param options defines the options you can use to configure the environment
  51656. * @returns the new EnvironmentHelper
  51657. */
  51658. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51659. /**
  51660. * Creates a new VREXperienceHelper
  51661. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51662. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51663. * @returns a new VREXperienceHelper
  51664. */
  51665. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51666. /**
  51667. * Creates a new WebXRDefaultExperience
  51668. * @see http://doc.babylonjs.com/how_to/webxr
  51669. * @param options experience options
  51670. * @returns a promise for a new WebXRDefaultExperience
  51671. */
  51672. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51673. }
  51674. }
  51675. }
  51676. declare module "babylonjs/Helpers/videoDome" {
  51677. import { Scene } from "babylonjs/scene";
  51678. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51679. import { Mesh } from "babylonjs/Meshes/mesh";
  51680. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51681. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51682. import "babylonjs/Meshes/Builders/sphereBuilder";
  51683. /**
  51684. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51685. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51686. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51687. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51688. */
  51689. export class VideoDome extends TransformNode {
  51690. /**
  51691. * Define the video source as a Monoscopic panoramic 360 video.
  51692. */
  51693. static readonly MODE_MONOSCOPIC: number;
  51694. /**
  51695. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51696. */
  51697. static readonly MODE_TOPBOTTOM: number;
  51698. /**
  51699. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51700. */
  51701. static readonly MODE_SIDEBYSIDE: number;
  51702. private _halfDome;
  51703. private _useDirectMapping;
  51704. /**
  51705. * The video texture being displayed on the sphere
  51706. */
  51707. protected _videoTexture: VideoTexture;
  51708. /**
  51709. * Gets the video texture being displayed on the sphere
  51710. */
  51711. readonly videoTexture: VideoTexture;
  51712. /**
  51713. * The skybox material
  51714. */
  51715. protected _material: BackgroundMaterial;
  51716. /**
  51717. * The surface used for the skybox
  51718. */
  51719. protected _mesh: Mesh;
  51720. /**
  51721. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51722. */
  51723. private _halfDomeMask;
  51724. /**
  51725. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51726. * Also see the options.resolution property.
  51727. */
  51728. fovMultiplier: number;
  51729. private _videoMode;
  51730. /**
  51731. * Gets or set the current video mode for the video. It can be:
  51732. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51733. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51734. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51735. */
  51736. videoMode: number;
  51737. /**
  51738. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51739. *
  51740. */
  51741. /**
  51742. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51743. */
  51744. halfDome: boolean;
  51745. /**
  51746. * Oberserver used in Stereoscopic VR Mode.
  51747. */
  51748. private _onBeforeCameraRenderObserver;
  51749. /**
  51750. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51751. * @param name Element's name, child elements will append suffixes for their own names.
  51752. * @param urlsOrVideo defines the url(s) or the video element to use
  51753. * @param options An object containing optional or exposed sub element properties
  51754. */
  51755. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51756. resolution?: number;
  51757. clickToPlay?: boolean;
  51758. autoPlay?: boolean;
  51759. loop?: boolean;
  51760. size?: number;
  51761. poster?: string;
  51762. faceForward?: boolean;
  51763. useDirectMapping?: boolean;
  51764. halfDomeMode?: boolean;
  51765. }, scene: Scene);
  51766. private _changeVideoMode;
  51767. /**
  51768. * Releases resources associated with this node.
  51769. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51770. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51771. */
  51772. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51773. }
  51774. }
  51775. declare module "babylonjs/Helpers/index" {
  51776. export * from "babylonjs/Helpers/environmentHelper";
  51777. export * from "babylonjs/Helpers/photoDome";
  51778. export * from "babylonjs/Helpers/sceneHelpers";
  51779. export * from "babylonjs/Helpers/videoDome";
  51780. }
  51781. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51782. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51783. import { IDisposable } from "babylonjs/scene";
  51784. import { Engine } from "babylonjs/Engines/engine";
  51785. /**
  51786. * This class can be used to get instrumentation data from a Babylon engine
  51787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51788. */
  51789. export class EngineInstrumentation implements IDisposable {
  51790. /**
  51791. * Define the instrumented engine.
  51792. */
  51793. engine: Engine;
  51794. private _captureGPUFrameTime;
  51795. private _gpuFrameTimeToken;
  51796. private _gpuFrameTime;
  51797. private _captureShaderCompilationTime;
  51798. private _shaderCompilationTime;
  51799. private _onBeginFrameObserver;
  51800. private _onEndFrameObserver;
  51801. private _onBeforeShaderCompilationObserver;
  51802. private _onAfterShaderCompilationObserver;
  51803. /**
  51804. * Gets the perf counter used for GPU frame time
  51805. */
  51806. readonly gpuFrameTimeCounter: PerfCounter;
  51807. /**
  51808. * Gets the GPU frame time capture status
  51809. */
  51810. /**
  51811. * Enable or disable the GPU frame time capture
  51812. */
  51813. captureGPUFrameTime: boolean;
  51814. /**
  51815. * Gets the perf counter used for shader compilation time
  51816. */
  51817. readonly shaderCompilationTimeCounter: PerfCounter;
  51818. /**
  51819. * Gets the shader compilation time capture status
  51820. */
  51821. /**
  51822. * Enable or disable the shader compilation time capture
  51823. */
  51824. captureShaderCompilationTime: boolean;
  51825. /**
  51826. * Instantiates a new engine instrumentation.
  51827. * This class can be used to get instrumentation data from a Babylon engine
  51828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51829. * @param engine Defines the engine to instrument
  51830. */
  51831. constructor(
  51832. /**
  51833. * Define the instrumented engine.
  51834. */
  51835. engine: Engine);
  51836. /**
  51837. * Dispose and release associated resources.
  51838. */
  51839. dispose(): void;
  51840. }
  51841. }
  51842. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51843. import { Scene, IDisposable } from "babylonjs/scene";
  51844. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51845. /**
  51846. * This class can be used to get instrumentation data from a Babylon engine
  51847. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51848. */
  51849. export class SceneInstrumentation implements IDisposable {
  51850. /**
  51851. * Defines the scene to instrument
  51852. */
  51853. scene: Scene;
  51854. private _captureActiveMeshesEvaluationTime;
  51855. private _activeMeshesEvaluationTime;
  51856. private _captureRenderTargetsRenderTime;
  51857. private _renderTargetsRenderTime;
  51858. private _captureFrameTime;
  51859. private _frameTime;
  51860. private _captureRenderTime;
  51861. private _renderTime;
  51862. private _captureInterFrameTime;
  51863. private _interFrameTime;
  51864. private _captureParticlesRenderTime;
  51865. private _particlesRenderTime;
  51866. private _captureSpritesRenderTime;
  51867. private _spritesRenderTime;
  51868. private _capturePhysicsTime;
  51869. private _physicsTime;
  51870. private _captureAnimationsTime;
  51871. private _animationsTime;
  51872. private _captureCameraRenderTime;
  51873. private _cameraRenderTime;
  51874. private _onBeforeActiveMeshesEvaluationObserver;
  51875. private _onAfterActiveMeshesEvaluationObserver;
  51876. private _onBeforeRenderTargetsRenderObserver;
  51877. private _onAfterRenderTargetsRenderObserver;
  51878. private _onAfterRenderObserver;
  51879. private _onBeforeDrawPhaseObserver;
  51880. private _onAfterDrawPhaseObserver;
  51881. private _onBeforeAnimationsObserver;
  51882. private _onBeforeParticlesRenderingObserver;
  51883. private _onAfterParticlesRenderingObserver;
  51884. private _onBeforeSpritesRenderingObserver;
  51885. private _onAfterSpritesRenderingObserver;
  51886. private _onBeforePhysicsObserver;
  51887. private _onAfterPhysicsObserver;
  51888. private _onAfterAnimationsObserver;
  51889. private _onBeforeCameraRenderObserver;
  51890. private _onAfterCameraRenderObserver;
  51891. /**
  51892. * Gets the perf counter used for active meshes evaluation time
  51893. */
  51894. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51895. /**
  51896. * Gets the active meshes evaluation time capture status
  51897. */
  51898. /**
  51899. * Enable or disable the active meshes evaluation time capture
  51900. */
  51901. captureActiveMeshesEvaluationTime: boolean;
  51902. /**
  51903. * Gets the perf counter used for render targets render time
  51904. */
  51905. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51906. /**
  51907. * Gets the render targets render time capture status
  51908. */
  51909. /**
  51910. * Enable or disable the render targets render time capture
  51911. */
  51912. captureRenderTargetsRenderTime: boolean;
  51913. /**
  51914. * Gets the perf counter used for particles render time
  51915. */
  51916. readonly particlesRenderTimeCounter: PerfCounter;
  51917. /**
  51918. * Gets the particles render time capture status
  51919. */
  51920. /**
  51921. * Enable or disable the particles render time capture
  51922. */
  51923. captureParticlesRenderTime: boolean;
  51924. /**
  51925. * Gets the perf counter used for sprites render time
  51926. */
  51927. readonly spritesRenderTimeCounter: PerfCounter;
  51928. /**
  51929. * Gets the sprites render time capture status
  51930. */
  51931. /**
  51932. * Enable or disable the sprites render time capture
  51933. */
  51934. captureSpritesRenderTime: boolean;
  51935. /**
  51936. * Gets the perf counter used for physics time
  51937. */
  51938. readonly physicsTimeCounter: PerfCounter;
  51939. /**
  51940. * Gets the physics time capture status
  51941. */
  51942. /**
  51943. * Enable or disable the physics time capture
  51944. */
  51945. capturePhysicsTime: boolean;
  51946. /**
  51947. * Gets the perf counter used for animations time
  51948. */
  51949. readonly animationsTimeCounter: PerfCounter;
  51950. /**
  51951. * Gets the animations time capture status
  51952. */
  51953. /**
  51954. * Enable or disable the animations time capture
  51955. */
  51956. captureAnimationsTime: boolean;
  51957. /**
  51958. * Gets the perf counter used for frame time capture
  51959. */
  51960. readonly frameTimeCounter: PerfCounter;
  51961. /**
  51962. * Gets the frame time capture status
  51963. */
  51964. /**
  51965. * Enable or disable the frame time capture
  51966. */
  51967. captureFrameTime: boolean;
  51968. /**
  51969. * Gets the perf counter used for inter-frames time capture
  51970. */
  51971. readonly interFrameTimeCounter: PerfCounter;
  51972. /**
  51973. * Gets the inter-frames time capture status
  51974. */
  51975. /**
  51976. * Enable or disable the inter-frames time capture
  51977. */
  51978. captureInterFrameTime: boolean;
  51979. /**
  51980. * Gets the perf counter used for render time capture
  51981. */
  51982. readonly renderTimeCounter: PerfCounter;
  51983. /**
  51984. * Gets the render time capture status
  51985. */
  51986. /**
  51987. * Enable or disable the render time capture
  51988. */
  51989. captureRenderTime: boolean;
  51990. /**
  51991. * Gets the perf counter used for camera render time capture
  51992. */
  51993. readonly cameraRenderTimeCounter: PerfCounter;
  51994. /**
  51995. * Gets the camera render time capture status
  51996. */
  51997. /**
  51998. * Enable or disable the camera render time capture
  51999. */
  52000. captureCameraRenderTime: boolean;
  52001. /**
  52002. * Gets the perf counter used for draw calls
  52003. */
  52004. readonly drawCallsCounter: PerfCounter;
  52005. /**
  52006. * Instantiates a new scene instrumentation.
  52007. * This class can be used to get instrumentation data from a Babylon engine
  52008. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52009. * @param scene Defines the scene to instrument
  52010. */
  52011. constructor(
  52012. /**
  52013. * Defines the scene to instrument
  52014. */
  52015. scene: Scene);
  52016. /**
  52017. * Dispose and release associated resources.
  52018. */
  52019. dispose(): void;
  52020. }
  52021. }
  52022. declare module "babylonjs/Instrumentation/index" {
  52023. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52024. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52025. export * from "babylonjs/Instrumentation/timeToken";
  52026. }
  52027. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52028. /** @hidden */
  52029. export var glowMapGenerationPixelShader: {
  52030. name: string;
  52031. shader: string;
  52032. };
  52033. }
  52034. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52035. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52038. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52039. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52040. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52041. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52042. /** @hidden */
  52043. export var glowMapGenerationVertexShader: {
  52044. name: string;
  52045. shader: string;
  52046. };
  52047. }
  52048. declare module "babylonjs/Layers/effectLayer" {
  52049. import { Observable } from "babylonjs/Misc/observable";
  52050. import { Nullable } from "babylonjs/types";
  52051. import { Camera } from "babylonjs/Cameras/camera";
  52052. import { Scene } from "babylonjs/scene";
  52053. import { ISize } from "babylonjs/Maths/math.size";
  52054. import { Color4 } from "babylonjs/Maths/math.color";
  52055. import { Engine } from "babylonjs/Engines/engine";
  52056. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52058. import { Mesh } from "babylonjs/Meshes/mesh";
  52059. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52061. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52062. import { Effect } from "babylonjs/Materials/effect";
  52063. import { Material } from "babylonjs/Materials/material";
  52064. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52065. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52066. /**
  52067. * Effect layer options. This helps customizing the behaviour
  52068. * of the effect layer.
  52069. */
  52070. export interface IEffectLayerOptions {
  52071. /**
  52072. * Multiplication factor apply to the canvas size to compute the render target size
  52073. * used to generated the objects (the smaller the faster).
  52074. */
  52075. mainTextureRatio: number;
  52076. /**
  52077. * Enforces a fixed size texture to ensure effect stability across devices.
  52078. */
  52079. mainTextureFixedSize?: number;
  52080. /**
  52081. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52082. */
  52083. alphaBlendingMode: number;
  52084. /**
  52085. * The camera attached to the layer.
  52086. */
  52087. camera: Nullable<Camera>;
  52088. /**
  52089. * The rendering group to draw the layer in.
  52090. */
  52091. renderingGroupId: number;
  52092. }
  52093. /**
  52094. * The effect layer Helps adding post process effect blended with the main pass.
  52095. *
  52096. * This can be for instance use to generate glow or higlight effects on the scene.
  52097. *
  52098. * The effect layer class can not be used directly and is intented to inherited from to be
  52099. * customized per effects.
  52100. */
  52101. export abstract class EffectLayer {
  52102. private _vertexBuffers;
  52103. private _indexBuffer;
  52104. private _cachedDefines;
  52105. private _effectLayerMapGenerationEffect;
  52106. private _effectLayerOptions;
  52107. private _mergeEffect;
  52108. protected _scene: Scene;
  52109. protected _engine: Engine;
  52110. protected _maxSize: number;
  52111. protected _mainTextureDesiredSize: ISize;
  52112. protected _mainTexture: RenderTargetTexture;
  52113. protected _shouldRender: boolean;
  52114. protected _postProcesses: PostProcess[];
  52115. protected _textures: BaseTexture[];
  52116. protected _emissiveTextureAndColor: {
  52117. texture: Nullable<BaseTexture>;
  52118. color: Color4;
  52119. };
  52120. /**
  52121. * The name of the layer
  52122. */
  52123. name: string;
  52124. /**
  52125. * The clear color of the texture used to generate the glow map.
  52126. */
  52127. neutralColor: Color4;
  52128. /**
  52129. * Specifies wether the highlight layer is enabled or not.
  52130. */
  52131. isEnabled: boolean;
  52132. /**
  52133. * Gets the camera attached to the layer.
  52134. */
  52135. readonly camera: Nullable<Camera>;
  52136. /**
  52137. * Gets the rendering group id the layer should render in.
  52138. */
  52139. renderingGroupId: number;
  52140. /**
  52141. * An event triggered when the effect layer has been disposed.
  52142. */
  52143. onDisposeObservable: Observable<EffectLayer>;
  52144. /**
  52145. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52146. */
  52147. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52148. /**
  52149. * An event triggered when the generated texture is being merged in the scene.
  52150. */
  52151. onBeforeComposeObservable: Observable<EffectLayer>;
  52152. /**
  52153. * An event triggered when the mesh is rendered into the effect render target.
  52154. */
  52155. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52156. /**
  52157. * An event triggered after the mesh has been rendered into the effect render target.
  52158. */
  52159. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52160. /**
  52161. * An event triggered when the generated texture has been merged in the scene.
  52162. */
  52163. onAfterComposeObservable: Observable<EffectLayer>;
  52164. /**
  52165. * An event triggered when the efffect layer changes its size.
  52166. */
  52167. onSizeChangedObservable: Observable<EffectLayer>;
  52168. /** @hidden */
  52169. static _SceneComponentInitialization: (scene: Scene) => void;
  52170. /**
  52171. * Instantiates a new effect Layer and references it in the scene.
  52172. * @param name The name of the layer
  52173. * @param scene The scene to use the layer in
  52174. */
  52175. constructor(
  52176. /** The Friendly of the effect in the scene */
  52177. name: string, scene: Scene);
  52178. /**
  52179. * Get the effect name of the layer.
  52180. * @return The effect name
  52181. */
  52182. abstract getEffectName(): string;
  52183. /**
  52184. * Checks for the readiness of the element composing the layer.
  52185. * @param subMesh the mesh to check for
  52186. * @param useInstances specify wether or not to use instances to render the mesh
  52187. * @return true if ready otherwise, false
  52188. */
  52189. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52190. /**
  52191. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52192. * @returns true if the effect requires stencil during the main canvas render pass.
  52193. */
  52194. abstract needStencil(): boolean;
  52195. /**
  52196. * Create the merge effect. This is the shader use to blit the information back
  52197. * to the main canvas at the end of the scene rendering.
  52198. * @returns The effect containing the shader used to merge the effect on the main canvas
  52199. */
  52200. protected abstract _createMergeEffect(): Effect;
  52201. /**
  52202. * Creates the render target textures and post processes used in the effect layer.
  52203. */
  52204. protected abstract _createTextureAndPostProcesses(): void;
  52205. /**
  52206. * Implementation specific of rendering the generating effect on the main canvas.
  52207. * @param effect The effect used to render through
  52208. */
  52209. protected abstract _internalRender(effect: Effect): void;
  52210. /**
  52211. * Sets the required values for both the emissive texture and and the main color.
  52212. */
  52213. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52214. /**
  52215. * Free any resources and references associated to a mesh.
  52216. * Internal use
  52217. * @param mesh The mesh to free.
  52218. */
  52219. abstract _disposeMesh(mesh: Mesh): void;
  52220. /**
  52221. * Serializes this layer (Glow or Highlight for example)
  52222. * @returns a serialized layer object
  52223. */
  52224. abstract serialize?(): any;
  52225. /**
  52226. * Initializes the effect layer with the required options.
  52227. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52228. */
  52229. protected _init(options: Partial<IEffectLayerOptions>): void;
  52230. /**
  52231. * Generates the index buffer of the full screen quad blending to the main canvas.
  52232. */
  52233. private _generateIndexBuffer;
  52234. /**
  52235. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52236. */
  52237. private _generateVertexBuffer;
  52238. /**
  52239. * Sets the main texture desired size which is the closest power of two
  52240. * of the engine canvas size.
  52241. */
  52242. private _setMainTextureSize;
  52243. /**
  52244. * Creates the main texture for the effect layer.
  52245. */
  52246. protected _createMainTexture(): void;
  52247. /**
  52248. * Adds specific effects defines.
  52249. * @param defines The defines to add specifics to.
  52250. */
  52251. protected _addCustomEffectDefines(defines: string[]): void;
  52252. /**
  52253. * Checks for the readiness of the element composing the layer.
  52254. * @param subMesh the mesh to check for
  52255. * @param useInstances specify wether or not to use instances to render the mesh
  52256. * @param emissiveTexture the associated emissive texture used to generate the glow
  52257. * @return true if ready otherwise, false
  52258. */
  52259. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52260. /**
  52261. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52262. */
  52263. render(): void;
  52264. /**
  52265. * Determine if a given mesh will be used in the current effect.
  52266. * @param mesh mesh to test
  52267. * @returns true if the mesh will be used
  52268. */
  52269. hasMesh(mesh: AbstractMesh): boolean;
  52270. /**
  52271. * Returns true if the layer contains information to display, otherwise false.
  52272. * @returns true if the glow layer should be rendered
  52273. */
  52274. shouldRender(): boolean;
  52275. /**
  52276. * Returns true if the mesh should render, otherwise false.
  52277. * @param mesh The mesh to render
  52278. * @returns true if it should render otherwise false
  52279. */
  52280. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52281. /**
  52282. * Returns true if the mesh can be rendered, otherwise false.
  52283. * @param mesh The mesh to render
  52284. * @param material The material used on the mesh
  52285. * @returns true if it can be rendered otherwise false
  52286. */
  52287. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52288. /**
  52289. * Returns true if the mesh should render, otherwise false.
  52290. * @param mesh The mesh to render
  52291. * @returns true if it should render otherwise false
  52292. */
  52293. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52294. /**
  52295. * Renders the submesh passed in parameter to the generation map.
  52296. */
  52297. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52298. /**
  52299. * Defines wether the current material of the mesh should be use to render the effect.
  52300. * @param mesh defines the current mesh to render
  52301. */
  52302. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52303. /**
  52304. * Rebuild the required buffers.
  52305. * @hidden Internal use only.
  52306. */
  52307. _rebuild(): void;
  52308. /**
  52309. * Dispose only the render target textures and post process.
  52310. */
  52311. private _disposeTextureAndPostProcesses;
  52312. /**
  52313. * Dispose the highlight layer and free resources.
  52314. */
  52315. dispose(): void;
  52316. /**
  52317. * Gets the class name of the effect layer
  52318. * @returns the string with the class name of the effect layer
  52319. */
  52320. getClassName(): string;
  52321. /**
  52322. * Creates an effect layer from parsed effect layer data
  52323. * @param parsedEffectLayer defines effect layer data
  52324. * @param scene defines the current scene
  52325. * @param rootUrl defines the root URL containing the effect layer information
  52326. * @returns a parsed effect Layer
  52327. */
  52328. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52329. }
  52330. }
  52331. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52332. import { Scene } from "babylonjs/scene";
  52333. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52334. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52335. import { AbstractScene } from "babylonjs/abstractScene";
  52336. module "babylonjs/abstractScene" {
  52337. interface AbstractScene {
  52338. /**
  52339. * The list of effect layers (highlights/glow) added to the scene
  52340. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52341. * @see http://doc.babylonjs.com/how_to/glow_layer
  52342. */
  52343. effectLayers: Array<EffectLayer>;
  52344. /**
  52345. * Removes the given effect layer from this scene.
  52346. * @param toRemove defines the effect layer to remove
  52347. * @returns the index of the removed effect layer
  52348. */
  52349. removeEffectLayer(toRemove: EffectLayer): number;
  52350. /**
  52351. * Adds the given effect layer to this scene
  52352. * @param newEffectLayer defines the effect layer to add
  52353. */
  52354. addEffectLayer(newEffectLayer: EffectLayer): void;
  52355. }
  52356. }
  52357. /**
  52358. * Defines the layer scene component responsible to manage any effect layers
  52359. * in a given scene.
  52360. */
  52361. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52362. /**
  52363. * The component name helpfull to identify the component in the list of scene components.
  52364. */
  52365. readonly name: string;
  52366. /**
  52367. * The scene the component belongs to.
  52368. */
  52369. scene: Scene;
  52370. private _engine;
  52371. private _renderEffects;
  52372. private _needStencil;
  52373. private _previousStencilState;
  52374. /**
  52375. * Creates a new instance of the component for the given scene
  52376. * @param scene Defines the scene to register the component in
  52377. */
  52378. constructor(scene: Scene);
  52379. /**
  52380. * Registers the component in a given scene
  52381. */
  52382. register(): void;
  52383. /**
  52384. * Rebuilds the elements related to this component in case of
  52385. * context lost for instance.
  52386. */
  52387. rebuild(): void;
  52388. /**
  52389. * Serializes the component data to the specified json object
  52390. * @param serializationObject The object to serialize to
  52391. */
  52392. serialize(serializationObject: any): void;
  52393. /**
  52394. * Adds all the elements from the container to the scene
  52395. * @param container the container holding the elements
  52396. */
  52397. addFromContainer(container: AbstractScene): void;
  52398. /**
  52399. * Removes all the elements in the container from the scene
  52400. * @param container contains the elements to remove
  52401. * @param dispose if the removed element should be disposed (default: false)
  52402. */
  52403. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52404. /**
  52405. * Disposes the component and the associated ressources.
  52406. */
  52407. dispose(): void;
  52408. private _isReadyForMesh;
  52409. private _renderMainTexture;
  52410. private _setStencil;
  52411. private _setStencilBack;
  52412. private _draw;
  52413. private _drawCamera;
  52414. private _drawRenderingGroup;
  52415. }
  52416. }
  52417. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52418. /** @hidden */
  52419. export var glowMapMergePixelShader: {
  52420. name: string;
  52421. shader: string;
  52422. };
  52423. }
  52424. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52425. /** @hidden */
  52426. export var glowMapMergeVertexShader: {
  52427. name: string;
  52428. shader: string;
  52429. };
  52430. }
  52431. declare module "babylonjs/Layers/glowLayer" {
  52432. import { Nullable } from "babylonjs/types";
  52433. import { Camera } from "babylonjs/Cameras/camera";
  52434. import { Scene } from "babylonjs/scene";
  52435. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52437. import { Mesh } from "babylonjs/Meshes/mesh";
  52438. import { Texture } from "babylonjs/Materials/Textures/texture";
  52439. import { Effect } from "babylonjs/Materials/effect";
  52440. import { Material } from "babylonjs/Materials/material";
  52441. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52442. import { Color4 } from "babylonjs/Maths/math.color";
  52443. import "babylonjs/Shaders/glowMapMerge.fragment";
  52444. import "babylonjs/Shaders/glowMapMerge.vertex";
  52445. import "babylonjs/Layers/effectLayerSceneComponent";
  52446. module "babylonjs/abstractScene" {
  52447. interface AbstractScene {
  52448. /**
  52449. * Return a the first highlight layer of the scene with a given name.
  52450. * @param name The name of the highlight layer to look for.
  52451. * @return The highlight layer if found otherwise null.
  52452. */
  52453. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52454. }
  52455. }
  52456. /**
  52457. * Glow layer options. This helps customizing the behaviour
  52458. * of the glow layer.
  52459. */
  52460. export interface IGlowLayerOptions {
  52461. /**
  52462. * Multiplication factor apply to the canvas size to compute the render target size
  52463. * used to generated the glowing objects (the smaller the faster).
  52464. */
  52465. mainTextureRatio: number;
  52466. /**
  52467. * Enforces a fixed size texture to ensure resize independant blur.
  52468. */
  52469. mainTextureFixedSize?: number;
  52470. /**
  52471. * How big is the kernel of the blur texture.
  52472. */
  52473. blurKernelSize: number;
  52474. /**
  52475. * The camera attached to the layer.
  52476. */
  52477. camera: Nullable<Camera>;
  52478. /**
  52479. * Enable MSAA by chosing the number of samples.
  52480. */
  52481. mainTextureSamples?: number;
  52482. /**
  52483. * The rendering group to draw the layer in.
  52484. */
  52485. renderingGroupId: number;
  52486. }
  52487. /**
  52488. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52489. *
  52490. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52491. *
  52492. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52493. */
  52494. export class GlowLayer extends EffectLayer {
  52495. /**
  52496. * Effect Name of the layer.
  52497. */
  52498. static readonly EffectName: string;
  52499. /**
  52500. * The default blur kernel size used for the glow.
  52501. */
  52502. static DefaultBlurKernelSize: number;
  52503. /**
  52504. * The default texture size ratio used for the glow.
  52505. */
  52506. static DefaultTextureRatio: number;
  52507. /**
  52508. * Sets the kernel size of the blur.
  52509. */
  52510. /**
  52511. * Gets the kernel size of the blur.
  52512. */
  52513. blurKernelSize: number;
  52514. /**
  52515. * Sets the glow intensity.
  52516. */
  52517. /**
  52518. * Gets the glow intensity.
  52519. */
  52520. intensity: number;
  52521. private _options;
  52522. private _intensity;
  52523. private _horizontalBlurPostprocess1;
  52524. private _verticalBlurPostprocess1;
  52525. private _horizontalBlurPostprocess2;
  52526. private _verticalBlurPostprocess2;
  52527. private _blurTexture1;
  52528. private _blurTexture2;
  52529. private _postProcesses1;
  52530. private _postProcesses2;
  52531. private _includedOnlyMeshes;
  52532. private _excludedMeshes;
  52533. private _meshesUsingTheirOwnMaterials;
  52534. /**
  52535. * Callback used to let the user override the color selection on a per mesh basis
  52536. */
  52537. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52538. /**
  52539. * Callback used to let the user override the texture selection on a per mesh basis
  52540. */
  52541. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52542. /**
  52543. * Instantiates a new glow Layer and references it to the scene.
  52544. * @param name The name of the layer
  52545. * @param scene The scene to use the layer in
  52546. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52547. */
  52548. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52549. /**
  52550. * Get the effect name of the layer.
  52551. * @return The effect name
  52552. */
  52553. getEffectName(): string;
  52554. /**
  52555. * Create the merge effect. This is the shader use to blit the information back
  52556. * to the main canvas at the end of the scene rendering.
  52557. */
  52558. protected _createMergeEffect(): Effect;
  52559. /**
  52560. * Creates the render target textures and post processes used in the glow layer.
  52561. */
  52562. protected _createTextureAndPostProcesses(): void;
  52563. /**
  52564. * Checks for the readiness of the element composing the layer.
  52565. * @param subMesh the mesh to check for
  52566. * @param useInstances specify wether or not to use instances to render the mesh
  52567. * @param emissiveTexture the associated emissive texture used to generate the glow
  52568. * @return true if ready otherwise, false
  52569. */
  52570. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52571. /**
  52572. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52573. */
  52574. needStencil(): boolean;
  52575. /**
  52576. * Returns true if the mesh can be rendered, otherwise false.
  52577. * @param mesh The mesh to render
  52578. * @param material The material used on the mesh
  52579. * @returns true if it can be rendered otherwise false
  52580. */
  52581. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52582. /**
  52583. * Implementation specific of rendering the generating effect on the main canvas.
  52584. * @param effect The effect used to render through
  52585. */
  52586. protected _internalRender(effect: Effect): void;
  52587. /**
  52588. * Sets the required values for both the emissive texture and and the main color.
  52589. */
  52590. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52591. /**
  52592. * Returns true if the mesh should render, otherwise false.
  52593. * @param mesh The mesh to render
  52594. * @returns true if it should render otherwise false
  52595. */
  52596. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52597. /**
  52598. * Adds specific effects defines.
  52599. * @param defines The defines to add specifics to.
  52600. */
  52601. protected _addCustomEffectDefines(defines: string[]): void;
  52602. /**
  52603. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52604. * @param mesh The mesh to exclude from the glow layer
  52605. */
  52606. addExcludedMesh(mesh: Mesh): void;
  52607. /**
  52608. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52609. * @param mesh The mesh to remove
  52610. */
  52611. removeExcludedMesh(mesh: Mesh): void;
  52612. /**
  52613. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52614. * @param mesh The mesh to include in the glow layer
  52615. */
  52616. addIncludedOnlyMesh(mesh: Mesh): void;
  52617. /**
  52618. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52619. * @param mesh The mesh to remove
  52620. */
  52621. removeIncludedOnlyMesh(mesh: Mesh): void;
  52622. /**
  52623. * Determine if a given mesh will be used in the glow layer
  52624. * @param mesh The mesh to test
  52625. * @returns true if the mesh will be highlighted by the current glow layer
  52626. */
  52627. hasMesh(mesh: AbstractMesh): boolean;
  52628. /**
  52629. * Defines wether the current material of the mesh should be use to render the effect.
  52630. * @param mesh defines the current mesh to render
  52631. */
  52632. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52633. /**
  52634. * Add a mesh to be rendered through its own material and not with emissive only.
  52635. * @param mesh The mesh for which we need to use its material
  52636. */
  52637. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52638. /**
  52639. * Remove a mesh from being rendered through its own material and not with emissive only.
  52640. * @param mesh The mesh for which we need to not use its material
  52641. */
  52642. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52643. /**
  52644. * Free any resources and references associated to a mesh.
  52645. * Internal use
  52646. * @param mesh The mesh to free.
  52647. * @hidden
  52648. */
  52649. _disposeMesh(mesh: Mesh): void;
  52650. /**
  52651. * Gets the class name of the effect layer
  52652. * @returns the string with the class name of the effect layer
  52653. */
  52654. getClassName(): string;
  52655. /**
  52656. * Serializes this glow layer
  52657. * @returns a serialized glow layer object
  52658. */
  52659. serialize(): any;
  52660. /**
  52661. * Creates a Glow Layer from parsed glow layer data
  52662. * @param parsedGlowLayer defines glow layer data
  52663. * @param scene defines the current scene
  52664. * @param rootUrl defines the root URL containing the glow layer information
  52665. * @returns a parsed Glow Layer
  52666. */
  52667. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52668. }
  52669. }
  52670. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52671. /** @hidden */
  52672. export var glowBlurPostProcessPixelShader: {
  52673. name: string;
  52674. shader: string;
  52675. };
  52676. }
  52677. declare module "babylonjs/Layers/highlightLayer" {
  52678. import { Observable } from "babylonjs/Misc/observable";
  52679. import { Nullable } from "babylonjs/types";
  52680. import { Camera } from "babylonjs/Cameras/camera";
  52681. import { Scene } from "babylonjs/scene";
  52682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52684. import { Mesh } from "babylonjs/Meshes/mesh";
  52685. import { Effect } from "babylonjs/Materials/effect";
  52686. import { Material } from "babylonjs/Materials/material";
  52687. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52688. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52689. import "babylonjs/Shaders/glowMapMerge.fragment";
  52690. import "babylonjs/Shaders/glowMapMerge.vertex";
  52691. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52692. module "babylonjs/abstractScene" {
  52693. interface AbstractScene {
  52694. /**
  52695. * Return a the first highlight layer of the scene with a given name.
  52696. * @param name The name of the highlight layer to look for.
  52697. * @return The highlight layer if found otherwise null.
  52698. */
  52699. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52700. }
  52701. }
  52702. /**
  52703. * Highlight layer options. This helps customizing the behaviour
  52704. * of the highlight layer.
  52705. */
  52706. export interface IHighlightLayerOptions {
  52707. /**
  52708. * Multiplication factor apply to the canvas size to compute the render target size
  52709. * used to generated the glowing objects (the smaller the faster).
  52710. */
  52711. mainTextureRatio: number;
  52712. /**
  52713. * Enforces a fixed size texture to ensure resize independant blur.
  52714. */
  52715. mainTextureFixedSize?: number;
  52716. /**
  52717. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52718. * of the picture to blur (the smaller the faster).
  52719. */
  52720. blurTextureSizeRatio: number;
  52721. /**
  52722. * How big in texel of the blur texture is the vertical blur.
  52723. */
  52724. blurVerticalSize: number;
  52725. /**
  52726. * How big in texel of the blur texture is the horizontal blur.
  52727. */
  52728. blurHorizontalSize: number;
  52729. /**
  52730. * Alpha blending mode used to apply the blur. Default is combine.
  52731. */
  52732. alphaBlendingMode: number;
  52733. /**
  52734. * The camera attached to the layer.
  52735. */
  52736. camera: Nullable<Camera>;
  52737. /**
  52738. * Should we display highlight as a solid stroke?
  52739. */
  52740. isStroke?: boolean;
  52741. /**
  52742. * The rendering group to draw the layer in.
  52743. */
  52744. renderingGroupId: number;
  52745. }
  52746. /**
  52747. * The highlight layer Helps adding a glow effect around a mesh.
  52748. *
  52749. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52750. * glowy meshes to your scene.
  52751. *
  52752. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52753. */
  52754. export class HighlightLayer extends EffectLayer {
  52755. name: string;
  52756. /**
  52757. * Effect Name of the highlight layer.
  52758. */
  52759. static readonly EffectName: string;
  52760. /**
  52761. * The neutral color used during the preparation of the glow effect.
  52762. * This is black by default as the blend operation is a blend operation.
  52763. */
  52764. static NeutralColor: Color4;
  52765. /**
  52766. * Stencil value used for glowing meshes.
  52767. */
  52768. static GlowingMeshStencilReference: number;
  52769. /**
  52770. * Stencil value used for the other meshes in the scene.
  52771. */
  52772. static NormalMeshStencilReference: number;
  52773. /**
  52774. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52775. */
  52776. innerGlow: boolean;
  52777. /**
  52778. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52779. */
  52780. outerGlow: boolean;
  52781. /**
  52782. * Specifies the horizontal size of the blur.
  52783. */
  52784. /**
  52785. * Gets the horizontal size of the blur.
  52786. */
  52787. blurHorizontalSize: number;
  52788. /**
  52789. * Specifies the vertical size of the blur.
  52790. */
  52791. /**
  52792. * Gets the vertical size of the blur.
  52793. */
  52794. blurVerticalSize: number;
  52795. /**
  52796. * An event triggered when the highlight layer is being blurred.
  52797. */
  52798. onBeforeBlurObservable: Observable<HighlightLayer>;
  52799. /**
  52800. * An event triggered when the highlight layer has been blurred.
  52801. */
  52802. onAfterBlurObservable: Observable<HighlightLayer>;
  52803. private _instanceGlowingMeshStencilReference;
  52804. private _options;
  52805. private _downSamplePostprocess;
  52806. private _horizontalBlurPostprocess;
  52807. private _verticalBlurPostprocess;
  52808. private _blurTexture;
  52809. private _meshes;
  52810. private _excludedMeshes;
  52811. /**
  52812. * Instantiates a new highlight Layer and references it to the scene..
  52813. * @param name The name of the layer
  52814. * @param scene The scene to use the layer in
  52815. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52816. */
  52817. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52818. /**
  52819. * Get the effect name of the layer.
  52820. * @return The effect name
  52821. */
  52822. getEffectName(): string;
  52823. /**
  52824. * Create the merge effect. This is the shader use to blit the information back
  52825. * to the main canvas at the end of the scene rendering.
  52826. */
  52827. protected _createMergeEffect(): Effect;
  52828. /**
  52829. * Creates the render target textures and post processes used in the highlight layer.
  52830. */
  52831. protected _createTextureAndPostProcesses(): void;
  52832. /**
  52833. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52834. */
  52835. needStencil(): boolean;
  52836. /**
  52837. * Checks for the readiness of the element composing the layer.
  52838. * @param subMesh the mesh to check for
  52839. * @param useInstances specify wether or not to use instances to render the mesh
  52840. * @param emissiveTexture the associated emissive texture used to generate the glow
  52841. * @return true if ready otherwise, false
  52842. */
  52843. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52844. /**
  52845. * Implementation specific of rendering the generating effect on the main canvas.
  52846. * @param effect The effect used to render through
  52847. */
  52848. protected _internalRender(effect: Effect): void;
  52849. /**
  52850. * Returns true if the layer contains information to display, otherwise false.
  52851. */
  52852. shouldRender(): boolean;
  52853. /**
  52854. * Returns true if the mesh should render, otherwise false.
  52855. * @param mesh The mesh to render
  52856. * @returns true if it should render otherwise false
  52857. */
  52858. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52859. /**
  52860. * Sets the required values for both the emissive texture and and the main color.
  52861. */
  52862. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52863. /**
  52864. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52865. * @param mesh The mesh to exclude from the highlight layer
  52866. */
  52867. addExcludedMesh(mesh: Mesh): void;
  52868. /**
  52869. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52870. * @param mesh The mesh to highlight
  52871. */
  52872. removeExcludedMesh(mesh: Mesh): void;
  52873. /**
  52874. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52875. * @param mesh mesh to test
  52876. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52877. */
  52878. hasMesh(mesh: AbstractMesh): boolean;
  52879. /**
  52880. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52881. * @param mesh The mesh to highlight
  52882. * @param color The color of the highlight
  52883. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52884. */
  52885. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52886. /**
  52887. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52888. * @param mesh The mesh to highlight
  52889. */
  52890. removeMesh(mesh: Mesh): void;
  52891. /**
  52892. * Force the stencil to the normal expected value for none glowing parts
  52893. */
  52894. private _defaultStencilReference;
  52895. /**
  52896. * Free any resources and references associated to a mesh.
  52897. * Internal use
  52898. * @param mesh The mesh to free.
  52899. * @hidden
  52900. */
  52901. _disposeMesh(mesh: Mesh): void;
  52902. /**
  52903. * Dispose the highlight layer and free resources.
  52904. */
  52905. dispose(): void;
  52906. /**
  52907. * Gets the class name of the effect layer
  52908. * @returns the string with the class name of the effect layer
  52909. */
  52910. getClassName(): string;
  52911. /**
  52912. * Serializes this Highlight layer
  52913. * @returns a serialized Highlight layer object
  52914. */
  52915. serialize(): any;
  52916. /**
  52917. * Creates a Highlight layer from parsed Highlight layer data
  52918. * @param parsedHightlightLayer defines the Highlight layer data
  52919. * @param scene defines the current scene
  52920. * @param rootUrl defines the root URL containing the Highlight layer information
  52921. * @returns a parsed Highlight layer
  52922. */
  52923. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52924. }
  52925. }
  52926. declare module "babylonjs/Layers/layerSceneComponent" {
  52927. import { Scene } from "babylonjs/scene";
  52928. import { ISceneComponent } from "babylonjs/sceneComponent";
  52929. import { Layer } from "babylonjs/Layers/layer";
  52930. import { AbstractScene } from "babylonjs/abstractScene";
  52931. module "babylonjs/abstractScene" {
  52932. interface AbstractScene {
  52933. /**
  52934. * The list of layers (background and foreground) of the scene
  52935. */
  52936. layers: Array<Layer>;
  52937. }
  52938. }
  52939. /**
  52940. * Defines the layer scene component responsible to manage any layers
  52941. * in a given scene.
  52942. */
  52943. export class LayerSceneComponent implements ISceneComponent {
  52944. /**
  52945. * The component name helpfull to identify the component in the list of scene components.
  52946. */
  52947. readonly name: string;
  52948. /**
  52949. * The scene the component belongs to.
  52950. */
  52951. scene: Scene;
  52952. private _engine;
  52953. /**
  52954. * Creates a new instance of the component for the given scene
  52955. * @param scene Defines the scene to register the component in
  52956. */
  52957. constructor(scene: Scene);
  52958. /**
  52959. * Registers the component in a given scene
  52960. */
  52961. register(): void;
  52962. /**
  52963. * Rebuilds the elements related to this component in case of
  52964. * context lost for instance.
  52965. */
  52966. rebuild(): void;
  52967. /**
  52968. * Disposes the component and the associated ressources.
  52969. */
  52970. dispose(): void;
  52971. private _draw;
  52972. private _drawCameraPredicate;
  52973. private _drawCameraBackground;
  52974. private _drawCameraForeground;
  52975. private _drawRenderTargetPredicate;
  52976. private _drawRenderTargetBackground;
  52977. private _drawRenderTargetForeground;
  52978. /**
  52979. * Adds all the elements from the container to the scene
  52980. * @param container the container holding the elements
  52981. */
  52982. addFromContainer(container: AbstractScene): void;
  52983. /**
  52984. * Removes all the elements in the container from the scene
  52985. * @param container contains the elements to remove
  52986. * @param dispose if the removed element should be disposed (default: false)
  52987. */
  52988. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52989. }
  52990. }
  52991. declare module "babylonjs/Shaders/layer.fragment" {
  52992. /** @hidden */
  52993. export var layerPixelShader: {
  52994. name: string;
  52995. shader: string;
  52996. };
  52997. }
  52998. declare module "babylonjs/Shaders/layer.vertex" {
  52999. /** @hidden */
  53000. export var layerVertexShader: {
  53001. name: string;
  53002. shader: string;
  53003. };
  53004. }
  53005. declare module "babylonjs/Layers/layer" {
  53006. import { Observable } from "babylonjs/Misc/observable";
  53007. import { Nullable } from "babylonjs/types";
  53008. import { Scene } from "babylonjs/scene";
  53009. import { Vector2 } from "babylonjs/Maths/math.vector";
  53010. import { Color4 } from "babylonjs/Maths/math.color";
  53011. import { Texture } from "babylonjs/Materials/Textures/texture";
  53012. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53013. import "babylonjs/Shaders/layer.fragment";
  53014. import "babylonjs/Shaders/layer.vertex";
  53015. /**
  53016. * This represents a full screen 2d layer.
  53017. * This can be useful to display a picture in the background of your scene for instance.
  53018. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53019. */
  53020. export class Layer {
  53021. /**
  53022. * Define the name of the layer.
  53023. */
  53024. name: string;
  53025. /**
  53026. * Define the texture the layer should display.
  53027. */
  53028. texture: Nullable<Texture>;
  53029. /**
  53030. * Is the layer in background or foreground.
  53031. */
  53032. isBackground: boolean;
  53033. /**
  53034. * Define the color of the layer (instead of texture).
  53035. */
  53036. color: Color4;
  53037. /**
  53038. * Define the scale of the layer in order to zoom in out of the texture.
  53039. */
  53040. scale: Vector2;
  53041. /**
  53042. * Define an offset for the layer in order to shift the texture.
  53043. */
  53044. offset: Vector2;
  53045. /**
  53046. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53047. */
  53048. alphaBlendingMode: number;
  53049. /**
  53050. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53051. * Alpha test will not mix with the background color in case of transparency.
  53052. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53053. */
  53054. alphaTest: boolean;
  53055. /**
  53056. * Define a mask to restrict the layer to only some of the scene cameras.
  53057. */
  53058. layerMask: number;
  53059. /**
  53060. * Define the list of render target the layer is visible into.
  53061. */
  53062. renderTargetTextures: RenderTargetTexture[];
  53063. /**
  53064. * Define if the layer is only used in renderTarget or if it also
  53065. * renders in the main frame buffer of the canvas.
  53066. */
  53067. renderOnlyInRenderTargetTextures: boolean;
  53068. private _scene;
  53069. private _vertexBuffers;
  53070. private _indexBuffer;
  53071. private _effect;
  53072. private _alphaTestEffect;
  53073. /**
  53074. * An event triggered when the layer is disposed.
  53075. */
  53076. onDisposeObservable: Observable<Layer>;
  53077. private _onDisposeObserver;
  53078. /**
  53079. * Back compatibility with callback before the onDisposeObservable existed.
  53080. * The set callback will be triggered when the layer has been disposed.
  53081. */
  53082. onDispose: () => void;
  53083. /**
  53084. * An event triggered before rendering the scene
  53085. */
  53086. onBeforeRenderObservable: Observable<Layer>;
  53087. private _onBeforeRenderObserver;
  53088. /**
  53089. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53090. * The set callback will be triggered just before rendering the layer.
  53091. */
  53092. onBeforeRender: () => void;
  53093. /**
  53094. * An event triggered after rendering the scene
  53095. */
  53096. onAfterRenderObservable: Observable<Layer>;
  53097. private _onAfterRenderObserver;
  53098. /**
  53099. * Back compatibility with callback before the onAfterRenderObservable existed.
  53100. * The set callback will be triggered just after rendering the layer.
  53101. */
  53102. onAfterRender: () => void;
  53103. /**
  53104. * Instantiates a new layer.
  53105. * This represents a full screen 2d layer.
  53106. * This can be useful to display a picture in the background of your scene for instance.
  53107. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53108. * @param name Define the name of the layer in the scene
  53109. * @param imgUrl Define the url of the texture to display in the layer
  53110. * @param scene Define the scene the layer belongs to
  53111. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53112. * @param color Defines a color for the layer
  53113. */
  53114. constructor(
  53115. /**
  53116. * Define the name of the layer.
  53117. */
  53118. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53119. private _createIndexBuffer;
  53120. /** @hidden */
  53121. _rebuild(): void;
  53122. /**
  53123. * Renders the layer in the scene.
  53124. */
  53125. render(): void;
  53126. /**
  53127. * Disposes and releases the associated ressources.
  53128. */
  53129. dispose(): void;
  53130. }
  53131. }
  53132. declare module "babylonjs/Layers/index" {
  53133. export * from "babylonjs/Layers/effectLayer";
  53134. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53135. export * from "babylonjs/Layers/glowLayer";
  53136. export * from "babylonjs/Layers/highlightLayer";
  53137. export * from "babylonjs/Layers/layer";
  53138. export * from "babylonjs/Layers/layerSceneComponent";
  53139. }
  53140. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53141. /** @hidden */
  53142. export var lensFlarePixelShader: {
  53143. name: string;
  53144. shader: string;
  53145. };
  53146. }
  53147. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53148. /** @hidden */
  53149. export var lensFlareVertexShader: {
  53150. name: string;
  53151. shader: string;
  53152. };
  53153. }
  53154. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53155. import { Scene } from "babylonjs/scene";
  53156. import { Vector3 } from "babylonjs/Maths/math.vector";
  53157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53158. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53159. import "babylonjs/Shaders/lensFlare.fragment";
  53160. import "babylonjs/Shaders/lensFlare.vertex";
  53161. import { Viewport } from "babylonjs/Maths/math.viewport";
  53162. /**
  53163. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53164. * It is usually composed of several `lensFlare`.
  53165. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53166. */
  53167. export class LensFlareSystem {
  53168. /**
  53169. * Define the name of the lens flare system
  53170. */
  53171. name: string;
  53172. /**
  53173. * List of lens flares used in this system.
  53174. */
  53175. lensFlares: LensFlare[];
  53176. /**
  53177. * Define a limit from the border the lens flare can be visible.
  53178. */
  53179. borderLimit: number;
  53180. /**
  53181. * Define a viewport border we do not want to see the lens flare in.
  53182. */
  53183. viewportBorder: number;
  53184. /**
  53185. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53186. */
  53187. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53188. /**
  53189. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53190. */
  53191. layerMask: number;
  53192. /**
  53193. * Define the id of the lens flare system in the scene.
  53194. * (equal to name by default)
  53195. */
  53196. id: string;
  53197. private _scene;
  53198. private _emitter;
  53199. private _vertexBuffers;
  53200. private _indexBuffer;
  53201. private _effect;
  53202. private _positionX;
  53203. private _positionY;
  53204. private _isEnabled;
  53205. /** @hidden */
  53206. static _SceneComponentInitialization: (scene: Scene) => void;
  53207. /**
  53208. * Instantiates a lens flare system.
  53209. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53210. * It is usually composed of several `lensFlare`.
  53211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53212. * @param name Define the name of the lens flare system in the scene
  53213. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53214. * @param scene Define the scene the lens flare system belongs to
  53215. */
  53216. constructor(
  53217. /**
  53218. * Define the name of the lens flare system
  53219. */
  53220. name: string, emitter: any, scene: Scene);
  53221. /**
  53222. * Define if the lens flare system is enabled.
  53223. */
  53224. isEnabled: boolean;
  53225. /**
  53226. * Get the scene the effects belongs to.
  53227. * @returns the scene holding the lens flare system
  53228. */
  53229. getScene(): Scene;
  53230. /**
  53231. * Get the emitter of the lens flare system.
  53232. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53233. * @returns the emitter of the lens flare system
  53234. */
  53235. getEmitter(): any;
  53236. /**
  53237. * Set the emitter of the lens flare system.
  53238. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53239. * @param newEmitter Define the new emitter of the system
  53240. */
  53241. setEmitter(newEmitter: any): void;
  53242. /**
  53243. * Get the lens flare system emitter position.
  53244. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53245. * @returns the position
  53246. */
  53247. getEmitterPosition(): Vector3;
  53248. /**
  53249. * @hidden
  53250. */
  53251. computeEffectivePosition(globalViewport: Viewport): boolean;
  53252. /** @hidden */
  53253. _isVisible(): boolean;
  53254. /**
  53255. * @hidden
  53256. */
  53257. render(): boolean;
  53258. /**
  53259. * Dispose and release the lens flare with its associated resources.
  53260. */
  53261. dispose(): void;
  53262. /**
  53263. * Parse a lens flare system from a JSON repressentation
  53264. * @param parsedLensFlareSystem Define the JSON to parse
  53265. * @param scene Define the scene the parsed system should be instantiated in
  53266. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53267. * @returns the parsed system
  53268. */
  53269. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53270. /**
  53271. * Serialize the current Lens Flare System into a JSON representation.
  53272. * @returns the serialized JSON
  53273. */
  53274. serialize(): any;
  53275. }
  53276. }
  53277. declare module "babylonjs/LensFlares/lensFlare" {
  53278. import { Nullable } from "babylonjs/types";
  53279. import { Color3 } from "babylonjs/Maths/math.color";
  53280. import { Texture } from "babylonjs/Materials/Textures/texture";
  53281. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53282. /**
  53283. * This represents one of the lens effect in a `lensFlareSystem`.
  53284. * It controls one of the indiviual texture used in the effect.
  53285. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53286. */
  53287. export class LensFlare {
  53288. /**
  53289. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53290. */
  53291. size: number;
  53292. /**
  53293. * 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.
  53294. */
  53295. position: number;
  53296. /**
  53297. * Define the lens color.
  53298. */
  53299. color: Color3;
  53300. /**
  53301. * Define the lens texture.
  53302. */
  53303. texture: Nullable<Texture>;
  53304. /**
  53305. * Define the alpha mode to render this particular lens.
  53306. */
  53307. alphaMode: number;
  53308. private _system;
  53309. /**
  53310. * Creates a new Lens Flare.
  53311. * This represents one of the lens effect in a `lensFlareSystem`.
  53312. * It controls one of the indiviual texture used in the effect.
  53313. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53314. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53315. * @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.
  53316. * @param color Define the lens color
  53317. * @param imgUrl Define the lens texture url
  53318. * @param system Define the `lensFlareSystem` this flare is part of
  53319. * @returns The newly created Lens Flare
  53320. */
  53321. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53322. /**
  53323. * Instantiates a new Lens Flare.
  53324. * This represents one of the lens effect in a `lensFlareSystem`.
  53325. * It controls one of the indiviual texture used in the effect.
  53326. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53327. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53328. * @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.
  53329. * @param color Define the lens color
  53330. * @param imgUrl Define the lens texture url
  53331. * @param system Define the `lensFlareSystem` this flare is part of
  53332. */
  53333. constructor(
  53334. /**
  53335. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53336. */
  53337. size: number,
  53338. /**
  53339. * 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.
  53340. */
  53341. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53342. /**
  53343. * Dispose and release the lens flare with its associated resources.
  53344. */
  53345. dispose(): void;
  53346. }
  53347. }
  53348. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53349. import { Nullable } from "babylonjs/types";
  53350. import { Scene } from "babylonjs/scene";
  53351. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53352. import { AbstractScene } from "babylonjs/abstractScene";
  53353. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53354. module "babylonjs/abstractScene" {
  53355. interface AbstractScene {
  53356. /**
  53357. * The list of lens flare system added to the scene
  53358. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53359. */
  53360. lensFlareSystems: Array<LensFlareSystem>;
  53361. /**
  53362. * Removes the given lens flare system from this scene.
  53363. * @param toRemove The lens flare system to remove
  53364. * @returns The index of the removed lens flare system
  53365. */
  53366. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53367. /**
  53368. * Adds the given lens flare system to this scene
  53369. * @param newLensFlareSystem The lens flare system to add
  53370. */
  53371. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53372. /**
  53373. * Gets a lens flare system using its name
  53374. * @param name defines the name to look for
  53375. * @returns the lens flare system or null if not found
  53376. */
  53377. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53378. /**
  53379. * Gets a lens flare system using its id
  53380. * @param id defines the id to look for
  53381. * @returns the lens flare system or null if not found
  53382. */
  53383. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53384. }
  53385. }
  53386. /**
  53387. * Defines the lens flare scene component responsible to manage any lens flares
  53388. * in a given scene.
  53389. */
  53390. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53391. /**
  53392. * The component name helpfull to identify the component in the list of scene components.
  53393. */
  53394. readonly name: string;
  53395. /**
  53396. * The scene the component belongs to.
  53397. */
  53398. scene: Scene;
  53399. /**
  53400. * Creates a new instance of the component for the given scene
  53401. * @param scene Defines the scene to register the component in
  53402. */
  53403. constructor(scene: Scene);
  53404. /**
  53405. * Registers the component in a given scene
  53406. */
  53407. register(): void;
  53408. /**
  53409. * Rebuilds the elements related to this component in case of
  53410. * context lost for instance.
  53411. */
  53412. rebuild(): void;
  53413. /**
  53414. * Adds all the elements from the container to the scene
  53415. * @param container the container holding the elements
  53416. */
  53417. addFromContainer(container: AbstractScene): void;
  53418. /**
  53419. * Removes all the elements in the container from the scene
  53420. * @param container contains the elements to remove
  53421. * @param dispose if the removed element should be disposed (default: false)
  53422. */
  53423. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53424. /**
  53425. * Serializes the component data to the specified json object
  53426. * @param serializationObject The object to serialize to
  53427. */
  53428. serialize(serializationObject: any): void;
  53429. /**
  53430. * Disposes the component and the associated ressources.
  53431. */
  53432. dispose(): void;
  53433. private _draw;
  53434. }
  53435. }
  53436. declare module "babylonjs/LensFlares/index" {
  53437. export * from "babylonjs/LensFlares/lensFlare";
  53438. export * from "babylonjs/LensFlares/lensFlareSystem";
  53439. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53440. }
  53441. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53442. import { Scene } from "babylonjs/scene";
  53443. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53444. import { AbstractScene } from "babylonjs/abstractScene";
  53445. /**
  53446. * Defines the shadow generator component responsible to manage any shadow generators
  53447. * in a given scene.
  53448. */
  53449. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53450. /**
  53451. * The component name helpfull to identify the component in the list of scene components.
  53452. */
  53453. readonly name: string;
  53454. /**
  53455. * The scene the component belongs to.
  53456. */
  53457. scene: Scene;
  53458. /**
  53459. * Creates a new instance of the component for the given scene
  53460. * @param scene Defines the scene to register the component in
  53461. */
  53462. constructor(scene: Scene);
  53463. /**
  53464. * Registers the component in a given scene
  53465. */
  53466. register(): void;
  53467. /**
  53468. * Rebuilds the elements related to this component in case of
  53469. * context lost for instance.
  53470. */
  53471. rebuild(): void;
  53472. /**
  53473. * Serializes the component data to the specified json object
  53474. * @param serializationObject The object to serialize to
  53475. */
  53476. serialize(serializationObject: any): void;
  53477. /**
  53478. * Adds all the elements from the container to the scene
  53479. * @param container the container holding the elements
  53480. */
  53481. addFromContainer(container: AbstractScene): void;
  53482. /**
  53483. * Removes all the elements in the container from the scene
  53484. * @param container contains the elements to remove
  53485. * @param dispose if the removed element should be disposed (default: false)
  53486. */
  53487. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53488. /**
  53489. * Rebuilds the elements related to this component in case of
  53490. * context lost for instance.
  53491. */
  53492. dispose(): void;
  53493. private _gatherRenderTargets;
  53494. }
  53495. }
  53496. declare module "babylonjs/Lights/Shadows/index" {
  53497. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53498. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53499. }
  53500. declare module "babylonjs/Lights/pointLight" {
  53501. import { Scene } from "babylonjs/scene";
  53502. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53504. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53505. import { Effect } from "babylonjs/Materials/effect";
  53506. /**
  53507. * A point light is a light defined by an unique point in world space.
  53508. * The light is emitted in every direction from this point.
  53509. * A good example of a point light is a standard light bulb.
  53510. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53511. */
  53512. export class PointLight extends ShadowLight {
  53513. private _shadowAngle;
  53514. /**
  53515. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53516. * This specifies what angle the shadow will use to be created.
  53517. *
  53518. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53519. */
  53520. /**
  53521. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53522. * This specifies what angle the shadow will use to be created.
  53523. *
  53524. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53525. */
  53526. shadowAngle: number;
  53527. /**
  53528. * Gets the direction if it has been set.
  53529. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53530. */
  53531. /**
  53532. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53533. */
  53534. direction: Vector3;
  53535. /**
  53536. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53537. * A PointLight emits the light in every direction.
  53538. * It can cast shadows.
  53539. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53540. * ```javascript
  53541. * var pointLight = new PointLight("pl", camera.position, scene);
  53542. * ```
  53543. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53544. * @param name The light friendly name
  53545. * @param position The position of the point light in the scene
  53546. * @param scene The scene the lights belongs to
  53547. */
  53548. constructor(name: string, position: Vector3, scene: Scene);
  53549. /**
  53550. * Returns the string "PointLight"
  53551. * @returns the class name
  53552. */
  53553. getClassName(): string;
  53554. /**
  53555. * Returns the integer 0.
  53556. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53557. */
  53558. getTypeID(): number;
  53559. /**
  53560. * Specifies wether or not the shadowmap should be a cube texture.
  53561. * @returns true if the shadowmap needs to be a cube texture.
  53562. */
  53563. needCube(): boolean;
  53564. /**
  53565. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53566. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53567. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53568. */
  53569. getShadowDirection(faceIndex?: number): Vector3;
  53570. /**
  53571. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53572. * - fov = PI / 2
  53573. * - aspect ratio : 1.0
  53574. * - z-near and far equal to the active camera minZ and maxZ.
  53575. * Returns the PointLight.
  53576. */
  53577. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53578. protected _buildUniformLayout(): void;
  53579. /**
  53580. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53581. * @param effect The effect to update
  53582. * @param lightIndex The index of the light in the effect to update
  53583. * @returns The point light
  53584. */
  53585. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53586. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53587. /**
  53588. * Prepares the list of defines specific to the light type.
  53589. * @param defines the list of defines
  53590. * @param lightIndex defines the index of the light for the effect
  53591. */
  53592. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53593. }
  53594. }
  53595. declare module "babylonjs/Lights/index" {
  53596. export * from "babylonjs/Lights/light";
  53597. export * from "babylonjs/Lights/shadowLight";
  53598. export * from "babylonjs/Lights/Shadows/index";
  53599. export * from "babylonjs/Lights/directionalLight";
  53600. export * from "babylonjs/Lights/hemisphericLight";
  53601. export * from "babylonjs/Lights/pointLight";
  53602. export * from "babylonjs/Lights/spotLight";
  53603. }
  53604. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53605. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53606. /**
  53607. * Header information of HDR texture files.
  53608. */
  53609. export interface HDRInfo {
  53610. /**
  53611. * The height of the texture in pixels.
  53612. */
  53613. height: number;
  53614. /**
  53615. * The width of the texture in pixels.
  53616. */
  53617. width: number;
  53618. /**
  53619. * The index of the beginning of the data in the binary file.
  53620. */
  53621. dataPosition: number;
  53622. }
  53623. /**
  53624. * This groups tools to convert HDR texture to native colors array.
  53625. */
  53626. export class HDRTools {
  53627. private static Ldexp;
  53628. private static Rgbe2float;
  53629. private static readStringLine;
  53630. /**
  53631. * Reads header information from an RGBE texture stored in a native array.
  53632. * More information on this format are available here:
  53633. * https://en.wikipedia.org/wiki/RGBE_image_format
  53634. *
  53635. * @param uint8array The binary file stored in native array.
  53636. * @return The header information.
  53637. */
  53638. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53639. /**
  53640. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53641. * This RGBE texture needs to store the information as a panorama.
  53642. *
  53643. * More information on this format are available here:
  53644. * https://en.wikipedia.org/wiki/RGBE_image_format
  53645. *
  53646. * @param buffer The binary file stored in an array buffer.
  53647. * @param size The expected size of the extracted cubemap.
  53648. * @return The Cube Map information.
  53649. */
  53650. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53651. /**
  53652. * Returns the pixels data extracted from an RGBE texture.
  53653. * This pixels will be stored left to right up to down in the R G B order in one array.
  53654. *
  53655. * More information on this format are available here:
  53656. * https://en.wikipedia.org/wiki/RGBE_image_format
  53657. *
  53658. * @param uint8array The binary file stored in an array buffer.
  53659. * @param hdrInfo The header information of the file.
  53660. * @return The pixels data in RGB right to left up to down order.
  53661. */
  53662. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53663. private static RGBE_ReadPixels_RLE;
  53664. }
  53665. }
  53666. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53667. import { Nullable } from "babylonjs/types";
  53668. import { Scene } from "babylonjs/scene";
  53669. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53671. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53672. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53673. /**
  53674. * This represents a texture coming from an HDR input.
  53675. *
  53676. * The only supported format is currently panorama picture stored in RGBE format.
  53677. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53678. */
  53679. export class HDRCubeTexture extends BaseTexture {
  53680. private static _facesMapping;
  53681. private _generateHarmonics;
  53682. private _noMipmap;
  53683. private _textureMatrix;
  53684. private _size;
  53685. private _onLoad;
  53686. private _onError;
  53687. /**
  53688. * The texture URL.
  53689. */
  53690. url: string;
  53691. /**
  53692. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53693. */
  53694. coordinatesMode: number;
  53695. protected _isBlocking: boolean;
  53696. /**
  53697. * Sets wether or not the texture is blocking during loading.
  53698. */
  53699. /**
  53700. * Gets wether or not the texture is blocking during loading.
  53701. */
  53702. isBlocking: boolean;
  53703. protected _rotationY: number;
  53704. /**
  53705. * Sets texture matrix rotation angle around Y axis in radians.
  53706. */
  53707. /**
  53708. * Gets texture matrix rotation angle around Y axis radians.
  53709. */
  53710. rotationY: number;
  53711. /**
  53712. * Gets or sets the center of the bounding box associated with the cube texture
  53713. * It must define where the camera used to render the texture was set
  53714. */
  53715. boundingBoxPosition: Vector3;
  53716. private _boundingBoxSize;
  53717. /**
  53718. * Gets or sets the size of the bounding box associated with the cube texture
  53719. * When defined, the cubemap will switch to local mode
  53720. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53721. * @example https://www.babylonjs-playground.com/#RNASML
  53722. */
  53723. boundingBoxSize: Vector3;
  53724. /**
  53725. * Instantiates an HDRTexture from the following parameters.
  53726. *
  53727. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53728. * @param scene The scene the texture will be used in
  53729. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53730. * @param noMipmap Forces to not generate the mipmap if true
  53731. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53732. * @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)
  53733. * @param reserved Reserved flag for internal use.
  53734. */
  53735. 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>);
  53736. /**
  53737. * Get the current class name of the texture useful for serialization or dynamic coding.
  53738. * @returns "HDRCubeTexture"
  53739. */
  53740. getClassName(): string;
  53741. /**
  53742. * Occurs when the file is raw .hdr file.
  53743. */
  53744. private loadTexture;
  53745. clone(): HDRCubeTexture;
  53746. delayLoad(): void;
  53747. /**
  53748. * Get the texture reflection matrix used to rotate/transform the reflection.
  53749. * @returns the reflection matrix
  53750. */
  53751. getReflectionTextureMatrix(): Matrix;
  53752. /**
  53753. * Set the texture reflection matrix used to rotate/transform the reflection.
  53754. * @param value Define the reflection matrix to set
  53755. */
  53756. setReflectionTextureMatrix(value: Matrix): void;
  53757. /**
  53758. * Parses a JSON representation of an HDR Texture in order to create the texture
  53759. * @param parsedTexture Define the JSON representation
  53760. * @param scene Define the scene the texture should be created in
  53761. * @param rootUrl Define the root url in case we need to load relative dependencies
  53762. * @returns the newly created texture after parsing
  53763. */
  53764. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53765. serialize(): any;
  53766. }
  53767. }
  53768. declare module "babylonjs/Physics/physicsEngine" {
  53769. import { Nullable } from "babylonjs/types";
  53770. import { Vector3 } from "babylonjs/Maths/math.vector";
  53771. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53772. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53773. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53774. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53775. /**
  53776. * Class used to control physics engine
  53777. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53778. */
  53779. export class PhysicsEngine implements IPhysicsEngine {
  53780. private _physicsPlugin;
  53781. /**
  53782. * Global value used to control the smallest number supported by the simulation
  53783. */
  53784. static Epsilon: number;
  53785. private _impostors;
  53786. private _joints;
  53787. /**
  53788. * Gets the gravity vector used by the simulation
  53789. */
  53790. gravity: Vector3;
  53791. /**
  53792. * Factory used to create the default physics plugin.
  53793. * @returns The default physics plugin
  53794. */
  53795. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53796. /**
  53797. * Creates a new Physics Engine
  53798. * @param gravity defines the gravity vector used by the simulation
  53799. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53800. */
  53801. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53802. /**
  53803. * Sets the gravity vector used by the simulation
  53804. * @param gravity defines the gravity vector to use
  53805. */
  53806. setGravity(gravity: Vector3): void;
  53807. /**
  53808. * Set the time step of the physics engine.
  53809. * Default is 1/60.
  53810. * To slow it down, enter 1/600 for example.
  53811. * To speed it up, 1/30
  53812. * @param newTimeStep defines the new timestep to apply to this world.
  53813. */
  53814. setTimeStep(newTimeStep?: number): void;
  53815. /**
  53816. * Get the time step of the physics engine.
  53817. * @returns the current time step
  53818. */
  53819. getTimeStep(): number;
  53820. /**
  53821. * Release all resources
  53822. */
  53823. dispose(): void;
  53824. /**
  53825. * Gets the name of the current physics plugin
  53826. * @returns the name of the plugin
  53827. */
  53828. getPhysicsPluginName(): string;
  53829. /**
  53830. * Adding a new impostor for the impostor tracking.
  53831. * This will be done by the impostor itself.
  53832. * @param impostor the impostor to add
  53833. */
  53834. addImpostor(impostor: PhysicsImpostor): void;
  53835. /**
  53836. * Remove an impostor from the engine.
  53837. * This impostor and its mesh will not longer be updated by the physics engine.
  53838. * @param impostor the impostor to remove
  53839. */
  53840. removeImpostor(impostor: PhysicsImpostor): void;
  53841. /**
  53842. * Add a joint to the physics engine
  53843. * @param mainImpostor defines the main impostor to which the joint is added.
  53844. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53845. * @param joint defines the joint that will connect both impostors.
  53846. */
  53847. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53848. /**
  53849. * Removes a joint from the simulation
  53850. * @param mainImpostor defines the impostor used with the joint
  53851. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53852. * @param joint defines the joint to remove
  53853. */
  53854. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53855. /**
  53856. * Called by the scene. No need to call it.
  53857. * @param delta defines the timespam between frames
  53858. */
  53859. _step(delta: number): void;
  53860. /**
  53861. * Gets the current plugin used to run the simulation
  53862. * @returns current plugin
  53863. */
  53864. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53865. /**
  53866. * Gets the list of physic impostors
  53867. * @returns an array of PhysicsImpostor
  53868. */
  53869. getImpostors(): Array<PhysicsImpostor>;
  53870. /**
  53871. * Gets the impostor for a physics enabled object
  53872. * @param object defines the object impersonated by the impostor
  53873. * @returns the PhysicsImpostor or null if not found
  53874. */
  53875. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53876. /**
  53877. * Gets the impostor for a physics body object
  53878. * @param body defines physics body used by the impostor
  53879. * @returns the PhysicsImpostor or null if not found
  53880. */
  53881. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53882. /**
  53883. * Does a raycast in the physics world
  53884. * @param from when should the ray start?
  53885. * @param to when should the ray end?
  53886. * @returns PhysicsRaycastResult
  53887. */
  53888. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53889. }
  53890. }
  53891. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53892. import { Nullable } from "babylonjs/types";
  53893. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53895. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53896. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53897. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53898. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53899. /** @hidden */
  53900. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53901. private _useDeltaForWorldStep;
  53902. world: any;
  53903. name: string;
  53904. private _physicsMaterials;
  53905. private _fixedTimeStep;
  53906. private _cannonRaycastResult;
  53907. private _raycastResult;
  53908. private _physicsBodysToRemoveAfterStep;
  53909. BJSCANNON: any;
  53910. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53911. setGravity(gravity: Vector3): void;
  53912. setTimeStep(timeStep: number): void;
  53913. getTimeStep(): number;
  53914. executeStep(delta: number): void;
  53915. private _removeMarkedPhysicsBodiesFromWorld;
  53916. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53917. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53918. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53919. private _processChildMeshes;
  53920. removePhysicsBody(impostor: PhysicsImpostor): void;
  53921. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53922. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53923. private _addMaterial;
  53924. private _checkWithEpsilon;
  53925. private _createShape;
  53926. private _createHeightmap;
  53927. private _minus90X;
  53928. private _plus90X;
  53929. private _tmpPosition;
  53930. private _tmpDeltaPosition;
  53931. private _tmpUnityRotation;
  53932. private _updatePhysicsBodyTransformation;
  53933. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53934. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53935. isSupported(): boolean;
  53936. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53937. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53938. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53939. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53940. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53941. getBodyMass(impostor: PhysicsImpostor): number;
  53942. getBodyFriction(impostor: PhysicsImpostor): number;
  53943. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53944. getBodyRestitution(impostor: PhysicsImpostor): number;
  53945. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53946. sleepBody(impostor: PhysicsImpostor): void;
  53947. wakeUpBody(impostor: PhysicsImpostor): void;
  53948. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53949. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53950. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53951. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53952. getRadius(impostor: PhysicsImpostor): number;
  53953. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53954. dispose(): void;
  53955. private _extendNamespace;
  53956. /**
  53957. * Does a raycast in the physics world
  53958. * @param from when should the ray start?
  53959. * @param to when should the ray end?
  53960. * @returns PhysicsRaycastResult
  53961. */
  53962. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53963. }
  53964. }
  53965. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53966. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53967. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53968. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53970. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53971. import { Nullable } from "babylonjs/types";
  53972. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53973. /** @hidden */
  53974. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53975. world: any;
  53976. name: string;
  53977. BJSOIMO: any;
  53978. private _raycastResult;
  53979. constructor(iterations?: number, oimoInjection?: any);
  53980. setGravity(gravity: Vector3): void;
  53981. setTimeStep(timeStep: number): void;
  53982. getTimeStep(): number;
  53983. private _tmpImpostorsArray;
  53984. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53985. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53986. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53987. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53988. private _tmpPositionVector;
  53989. removePhysicsBody(impostor: PhysicsImpostor): void;
  53990. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53991. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53992. isSupported(): boolean;
  53993. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53994. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53995. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53996. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53997. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53998. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53999. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54000. getBodyMass(impostor: PhysicsImpostor): number;
  54001. getBodyFriction(impostor: PhysicsImpostor): number;
  54002. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54003. getBodyRestitution(impostor: PhysicsImpostor): number;
  54004. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54005. sleepBody(impostor: PhysicsImpostor): void;
  54006. wakeUpBody(impostor: PhysicsImpostor): void;
  54007. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54008. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54009. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54010. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54011. getRadius(impostor: PhysicsImpostor): number;
  54012. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54013. dispose(): void;
  54014. /**
  54015. * Does a raycast in the physics world
  54016. * @param from when should the ray start?
  54017. * @param to when should the ray end?
  54018. * @returns PhysicsRaycastResult
  54019. */
  54020. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54021. }
  54022. }
  54023. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54024. import { Nullable } from "babylonjs/types";
  54025. import { Scene } from "babylonjs/scene";
  54026. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54027. import { Color4 } from "babylonjs/Maths/math.color";
  54028. import { Mesh } from "babylonjs/Meshes/mesh";
  54029. /**
  54030. * Class containing static functions to help procedurally build meshes
  54031. */
  54032. export class RibbonBuilder {
  54033. /**
  54034. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54035. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54036. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54037. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54038. * * 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
  54039. * * 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
  54040. * * 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
  54041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54043. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54044. * * 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
  54045. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54046. * * 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
  54047. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54049. * @param name defines the name of the mesh
  54050. * @param options defines the options used to create the mesh
  54051. * @param scene defines the hosting scene
  54052. * @returns the ribbon mesh
  54053. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54054. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54055. */
  54056. static CreateRibbon(name: string, options: {
  54057. pathArray: Vector3[][];
  54058. closeArray?: boolean;
  54059. closePath?: boolean;
  54060. offset?: number;
  54061. updatable?: boolean;
  54062. sideOrientation?: number;
  54063. frontUVs?: Vector4;
  54064. backUVs?: Vector4;
  54065. instance?: Mesh;
  54066. invertUV?: boolean;
  54067. uvs?: Vector2[];
  54068. colors?: Color4[];
  54069. }, scene?: Nullable<Scene>): Mesh;
  54070. }
  54071. }
  54072. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54073. import { Nullable } from "babylonjs/types";
  54074. import { Scene } from "babylonjs/scene";
  54075. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54076. import { Mesh } from "babylonjs/Meshes/mesh";
  54077. /**
  54078. * Class containing static functions to help procedurally build meshes
  54079. */
  54080. export class ShapeBuilder {
  54081. /**
  54082. * 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.
  54083. * * 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.
  54084. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54085. * * 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.
  54086. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54087. * * 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
  54088. * * 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
  54089. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54092. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54094. * @param name defines the name of the mesh
  54095. * @param options defines the options used to create the mesh
  54096. * @param scene defines the hosting scene
  54097. * @returns the extruded shape mesh
  54098. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54100. */
  54101. static ExtrudeShape(name: string, options: {
  54102. shape: Vector3[];
  54103. path: Vector3[];
  54104. scale?: number;
  54105. rotation?: number;
  54106. cap?: number;
  54107. updatable?: boolean;
  54108. sideOrientation?: number;
  54109. frontUVs?: Vector4;
  54110. backUVs?: Vector4;
  54111. instance?: Mesh;
  54112. invertUV?: boolean;
  54113. }, scene?: Nullable<Scene>): Mesh;
  54114. /**
  54115. * Creates an custom extruded shape mesh.
  54116. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54117. * * 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.
  54118. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54119. * * 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
  54120. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54121. * * 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
  54122. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54123. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54124. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54125. * * 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
  54126. * * 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
  54127. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54130. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54132. * @param name defines the name of the mesh
  54133. * @param options defines the options used to create the mesh
  54134. * @param scene defines the hosting scene
  54135. * @returns the custom extruded shape mesh
  54136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54137. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54139. */
  54140. static ExtrudeShapeCustom(name: string, options: {
  54141. shape: Vector3[];
  54142. path: Vector3[];
  54143. scaleFunction?: any;
  54144. rotationFunction?: any;
  54145. ribbonCloseArray?: boolean;
  54146. ribbonClosePath?: boolean;
  54147. cap?: number;
  54148. updatable?: boolean;
  54149. sideOrientation?: number;
  54150. frontUVs?: Vector4;
  54151. backUVs?: Vector4;
  54152. instance?: Mesh;
  54153. invertUV?: boolean;
  54154. }, scene?: Nullable<Scene>): Mesh;
  54155. private static _ExtrudeShapeGeneric;
  54156. }
  54157. }
  54158. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54159. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54160. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54161. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54162. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54163. import { Nullable } from "babylonjs/types";
  54164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54165. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54166. /**
  54167. * AmmoJS Physics plugin
  54168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54169. * @see https://github.com/kripken/ammo.js/
  54170. */
  54171. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54172. private _useDeltaForWorldStep;
  54173. /**
  54174. * Reference to the Ammo library
  54175. */
  54176. bjsAMMO: any;
  54177. /**
  54178. * Created ammoJS world which physics bodies are added to
  54179. */
  54180. world: any;
  54181. /**
  54182. * Name of the plugin
  54183. */
  54184. name: string;
  54185. private _timeStep;
  54186. private _fixedTimeStep;
  54187. private _maxSteps;
  54188. private _tmpQuaternion;
  54189. private _tmpAmmoTransform;
  54190. private _tmpAmmoQuaternion;
  54191. private _tmpAmmoConcreteContactResultCallback;
  54192. private _collisionConfiguration;
  54193. private _dispatcher;
  54194. private _overlappingPairCache;
  54195. private _solver;
  54196. private _softBodySolver;
  54197. private _tmpAmmoVectorA;
  54198. private _tmpAmmoVectorB;
  54199. private _tmpAmmoVectorC;
  54200. private _tmpAmmoVectorD;
  54201. private _tmpContactCallbackResult;
  54202. private _tmpAmmoVectorRCA;
  54203. private _tmpAmmoVectorRCB;
  54204. private _raycastResult;
  54205. private static readonly DISABLE_COLLISION_FLAG;
  54206. private static readonly KINEMATIC_FLAG;
  54207. private static readonly DISABLE_DEACTIVATION_FLAG;
  54208. /**
  54209. * Initializes the ammoJS plugin
  54210. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54211. * @param ammoInjection can be used to inject your own ammo reference
  54212. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54213. */
  54214. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54215. /**
  54216. * Sets the gravity of the physics world (m/(s^2))
  54217. * @param gravity Gravity to set
  54218. */
  54219. setGravity(gravity: Vector3): void;
  54220. /**
  54221. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54222. * @param timeStep timestep to use in seconds
  54223. */
  54224. setTimeStep(timeStep: number): void;
  54225. /**
  54226. * 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)
  54227. * @param fixedTimeStep fixedTimeStep to use in seconds
  54228. */
  54229. setFixedTimeStep(fixedTimeStep: number): void;
  54230. /**
  54231. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54232. * @param maxSteps the maximum number of steps by the physics engine per frame
  54233. */
  54234. setMaxSteps(maxSteps: number): void;
  54235. /**
  54236. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54237. * @returns the current timestep in seconds
  54238. */
  54239. getTimeStep(): number;
  54240. private _isImpostorInContact;
  54241. private _isImpostorPairInContact;
  54242. private _stepSimulation;
  54243. /**
  54244. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54245. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54246. * After the step the babylon meshes are set to the position of the physics imposters
  54247. * @param delta amount of time to step forward
  54248. * @param impostors array of imposters to update before/after the step
  54249. */
  54250. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54251. /**
  54252. * Update babylon mesh to match physics world object
  54253. * @param impostor imposter to match
  54254. */
  54255. private _afterSoftStep;
  54256. /**
  54257. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54258. * @param impostor imposter to match
  54259. */
  54260. private _ropeStep;
  54261. /**
  54262. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54263. * @param impostor imposter to match
  54264. */
  54265. private _softbodyOrClothStep;
  54266. private _tmpVector;
  54267. private _tmpMatrix;
  54268. /**
  54269. * Applies an impulse on the imposter
  54270. * @param impostor imposter to apply impulse to
  54271. * @param force amount of force to be applied to the imposter
  54272. * @param contactPoint the location to apply the impulse on the imposter
  54273. */
  54274. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54275. /**
  54276. * Applies a force on the imposter
  54277. * @param impostor imposter to apply force
  54278. * @param force amount of force to be applied to the imposter
  54279. * @param contactPoint the location to apply the force on the imposter
  54280. */
  54281. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54282. /**
  54283. * Creates a physics body using the plugin
  54284. * @param impostor the imposter to create the physics body on
  54285. */
  54286. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54287. /**
  54288. * Removes the physics body from the imposter and disposes of the body's memory
  54289. * @param impostor imposter to remove the physics body from
  54290. */
  54291. removePhysicsBody(impostor: PhysicsImpostor): void;
  54292. /**
  54293. * Generates a joint
  54294. * @param impostorJoint the imposter joint to create the joint with
  54295. */
  54296. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54297. /**
  54298. * Removes a joint
  54299. * @param impostorJoint the imposter joint to remove the joint from
  54300. */
  54301. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54302. private _addMeshVerts;
  54303. /**
  54304. * Initialise the soft body vertices to match its object's (mesh) vertices
  54305. * Softbody vertices (nodes) are in world space and to match this
  54306. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54307. * @param impostor to create the softbody for
  54308. */
  54309. private _softVertexData;
  54310. /**
  54311. * Create an impostor's soft body
  54312. * @param impostor to create the softbody for
  54313. */
  54314. private _createSoftbody;
  54315. /**
  54316. * Create cloth for an impostor
  54317. * @param impostor to create the softbody for
  54318. */
  54319. private _createCloth;
  54320. /**
  54321. * Create rope for an impostor
  54322. * @param impostor to create the softbody for
  54323. */
  54324. private _createRope;
  54325. private _addHullVerts;
  54326. private _createShape;
  54327. /**
  54328. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54329. * @param impostor imposter containing the physics body and babylon object
  54330. */
  54331. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54332. /**
  54333. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54334. * @param impostor imposter containing the physics body and babylon object
  54335. * @param newPosition new position
  54336. * @param newRotation new rotation
  54337. */
  54338. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54339. /**
  54340. * If this plugin is supported
  54341. * @returns true if its supported
  54342. */
  54343. isSupported(): boolean;
  54344. /**
  54345. * Sets the linear velocity of the physics body
  54346. * @param impostor imposter to set the velocity on
  54347. * @param velocity velocity to set
  54348. */
  54349. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54350. /**
  54351. * Sets the angular velocity of the physics body
  54352. * @param impostor imposter to set the velocity on
  54353. * @param velocity velocity to set
  54354. */
  54355. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54356. /**
  54357. * gets the linear velocity
  54358. * @param impostor imposter to get linear velocity from
  54359. * @returns linear velocity
  54360. */
  54361. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54362. /**
  54363. * gets the angular velocity
  54364. * @param impostor imposter to get angular velocity from
  54365. * @returns angular velocity
  54366. */
  54367. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54368. /**
  54369. * Sets the mass of physics body
  54370. * @param impostor imposter to set the mass on
  54371. * @param mass mass to set
  54372. */
  54373. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54374. /**
  54375. * Gets the mass of the physics body
  54376. * @param impostor imposter to get the mass from
  54377. * @returns mass
  54378. */
  54379. getBodyMass(impostor: PhysicsImpostor): number;
  54380. /**
  54381. * Gets friction of the impostor
  54382. * @param impostor impostor to get friction from
  54383. * @returns friction value
  54384. */
  54385. getBodyFriction(impostor: PhysicsImpostor): number;
  54386. /**
  54387. * Sets friction of the impostor
  54388. * @param impostor impostor to set friction on
  54389. * @param friction friction value
  54390. */
  54391. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54392. /**
  54393. * Gets restitution of the impostor
  54394. * @param impostor impostor to get restitution from
  54395. * @returns restitution value
  54396. */
  54397. getBodyRestitution(impostor: PhysicsImpostor): number;
  54398. /**
  54399. * Sets resitution of the impostor
  54400. * @param impostor impostor to set resitution on
  54401. * @param restitution resitution value
  54402. */
  54403. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54404. /**
  54405. * Gets pressure inside the impostor
  54406. * @param impostor impostor to get pressure from
  54407. * @returns pressure value
  54408. */
  54409. getBodyPressure(impostor: PhysicsImpostor): number;
  54410. /**
  54411. * Sets pressure inside a soft body impostor
  54412. * Cloth and rope must remain 0 pressure
  54413. * @param impostor impostor to set pressure on
  54414. * @param pressure pressure value
  54415. */
  54416. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54417. /**
  54418. * Gets stiffness of the impostor
  54419. * @param impostor impostor to get stiffness from
  54420. * @returns pressure value
  54421. */
  54422. getBodyStiffness(impostor: PhysicsImpostor): number;
  54423. /**
  54424. * Sets stiffness of the impostor
  54425. * @param impostor impostor to set stiffness on
  54426. * @param stiffness stiffness value from 0 to 1
  54427. */
  54428. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54429. /**
  54430. * Gets velocityIterations of the impostor
  54431. * @param impostor impostor to get velocity iterations from
  54432. * @returns velocityIterations value
  54433. */
  54434. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54435. /**
  54436. * Sets velocityIterations of the impostor
  54437. * @param impostor impostor to set velocity iterations on
  54438. * @param velocityIterations velocityIterations value
  54439. */
  54440. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54441. /**
  54442. * Gets positionIterations of the impostor
  54443. * @param impostor impostor to get position iterations from
  54444. * @returns positionIterations value
  54445. */
  54446. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54447. /**
  54448. * Sets positionIterations of the impostor
  54449. * @param impostor impostor to set position on
  54450. * @param positionIterations positionIterations value
  54451. */
  54452. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54453. /**
  54454. * Append an anchor to a cloth object
  54455. * @param impostor is the cloth impostor to add anchor to
  54456. * @param otherImpostor is the rigid impostor to anchor to
  54457. * @param width ratio across width from 0 to 1
  54458. * @param height ratio up height from 0 to 1
  54459. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54460. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54461. */
  54462. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54463. /**
  54464. * Append an hook to a rope object
  54465. * @param impostor is the rope impostor to add hook to
  54466. * @param otherImpostor is the rigid impostor to hook to
  54467. * @param length ratio along the rope from 0 to 1
  54468. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54469. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54470. */
  54471. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54472. /**
  54473. * Sleeps the physics body and stops it from being active
  54474. * @param impostor impostor to sleep
  54475. */
  54476. sleepBody(impostor: PhysicsImpostor): void;
  54477. /**
  54478. * Activates the physics body
  54479. * @param impostor impostor to activate
  54480. */
  54481. wakeUpBody(impostor: PhysicsImpostor): void;
  54482. /**
  54483. * Updates the distance parameters of the joint
  54484. * @param joint joint to update
  54485. * @param maxDistance maximum distance of the joint
  54486. * @param minDistance minimum distance of the joint
  54487. */
  54488. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54489. /**
  54490. * Sets a motor on the joint
  54491. * @param joint joint to set motor on
  54492. * @param speed speed of the motor
  54493. * @param maxForce maximum force of the motor
  54494. * @param motorIndex index of the motor
  54495. */
  54496. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54497. /**
  54498. * Sets the motors limit
  54499. * @param joint joint to set limit on
  54500. * @param upperLimit upper limit
  54501. * @param lowerLimit lower limit
  54502. */
  54503. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54504. /**
  54505. * Syncs the position and rotation of a mesh with the impostor
  54506. * @param mesh mesh to sync
  54507. * @param impostor impostor to update the mesh with
  54508. */
  54509. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54510. /**
  54511. * Gets the radius of the impostor
  54512. * @param impostor impostor to get radius from
  54513. * @returns the radius
  54514. */
  54515. getRadius(impostor: PhysicsImpostor): number;
  54516. /**
  54517. * Gets the box size of the impostor
  54518. * @param impostor impostor to get box size from
  54519. * @param result the resulting box size
  54520. */
  54521. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54522. /**
  54523. * Disposes of the impostor
  54524. */
  54525. dispose(): void;
  54526. /**
  54527. * Does a raycast in the physics world
  54528. * @param from when should the ray start?
  54529. * @param to when should the ray end?
  54530. * @returns PhysicsRaycastResult
  54531. */
  54532. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54533. }
  54534. }
  54535. declare module "babylonjs/Probes/reflectionProbe" {
  54536. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54537. import { Vector3 } from "babylonjs/Maths/math.vector";
  54538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54539. import { Nullable } from "babylonjs/types";
  54540. import { Scene } from "babylonjs/scene";
  54541. module "babylonjs/abstractScene" {
  54542. interface AbstractScene {
  54543. /**
  54544. * The list of reflection probes added to the scene
  54545. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54546. */
  54547. reflectionProbes: Array<ReflectionProbe>;
  54548. /**
  54549. * Removes the given reflection probe from this scene.
  54550. * @param toRemove The reflection probe to remove
  54551. * @returns The index of the removed reflection probe
  54552. */
  54553. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54554. /**
  54555. * Adds the given reflection probe to this scene.
  54556. * @param newReflectionProbe The reflection probe to add
  54557. */
  54558. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54559. }
  54560. }
  54561. /**
  54562. * Class used to generate realtime reflection / refraction cube textures
  54563. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54564. */
  54565. export class ReflectionProbe {
  54566. /** defines the name of the probe */
  54567. name: string;
  54568. private _scene;
  54569. private _renderTargetTexture;
  54570. private _projectionMatrix;
  54571. private _viewMatrix;
  54572. private _target;
  54573. private _add;
  54574. private _attachedMesh;
  54575. private _invertYAxis;
  54576. /** Gets or sets probe position (center of the cube map) */
  54577. position: Vector3;
  54578. /**
  54579. * Creates a new reflection probe
  54580. * @param name defines the name of the probe
  54581. * @param size defines the texture resolution (for each face)
  54582. * @param scene defines the hosting scene
  54583. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54584. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54585. */
  54586. constructor(
  54587. /** defines the name of the probe */
  54588. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54589. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54590. samples: number;
  54591. /** Gets or sets the refresh rate to use (on every frame by default) */
  54592. refreshRate: number;
  54593. /**
  54594. * Gets the hosting scene
  54595. * @returns a Scene
  54596. */
  54597. getScene(): Scene;
  54598. /** Gets the internal CubeTexture used to render to */
  54599. readonly cubeTexture: RenderTargetTexture;
  54600. /** Gets the list of meshes to render */
  54601. readonly renderList: Nullable<AbstractMesh[]>;
  54602. /**
  54603. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54604. * @param mesh defines the mesh to attach to
  54605. */
  54606. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54607. /**
  54608. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54609. * @param renderingGroupId The rendering group id corresponding to its index
  54610. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54611. */
  54612. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54613. /**
  54614. * Clean all associated resources
  54615. */
  54616. dispose(): void;
  54617. /**
  54618. * Converts the reflection probe information to a readable string for debug purpose.
  54619. * @param fullDetails Supports for multiple levels of logging within scene loading
  54620. * @returns the human readable reflection probe info
  54621. */
  54622. toString(fullDetails?: boolean): string;
  54623. /**
  54624. * Get the class name of the relfection probe.
  54625. * @returns "ReflectionProbe"
  54626. */
  54627. getClassName(): string;
  54628. /**
  54629. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54630. * @returns The JSON representation of the texture
  54631. */
  54632. serialize(): any;
  54633. /**
  54634. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54635. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54636. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54637. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54638. * @returns The parsed reflection probe if successful
  54639. */
  54640. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54641. }
  54642. }
  54643. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54644. /** @hidden */
  54645. export var _BabylonLoaderRegistered: boolean;
  54646. /**
  54647. * Helps setting up some configuration for the babylon file loader.
  54648. */
  54649. export class BabylonFileLoaderConfiguration {
  54650. /**
  54651. * The loader does not allow injecting custom physix engine into the plugins.
  54652. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54653. * So you could set this variable to your engine import to make it work.
  54654. */
  54655. static LoaderInjectedPhysicsEngine: any;
  54656. }
  54657. }
  54658. declare module "babylonjs/Loading/Plugins/index" {
  54659. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54660. }
  54661. declare module "babylonjs/Loading/index" {
  54662. export * from "babylonjs/Loading/loadingScreen";
  54663. export * from "babylonjs/Loading/Plugins/index";
  54664. export * from "babylonjs/Loading/sceneLoader";
  54665. export * from "babylonjs/Loading/sceneLoaderFlags";
  54666. }
  54667. declare module "babylonjs/Materials/Background/index" {
  54668. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54669. }
  54670. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54671. import { Scene } from "babylonjs/scene";
  54672. import { Color3 } from "babylonjs/Maths/math.color";
  54673. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54675. /**
  54676. * The Physically based simple base material of BJS.
  54677. *
  54678. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54679. * It is used as the base class for both the specGloss and metalRough conventions.
  54680. */
  54681. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54682. /**
  54683. * Number of Simultaneous lights allowed on the material.
  54684. */
  54685. maxSimultaneousLights: number;
  54686. /**
  54687. * If sets to true, disables all the lights affecting the material.
  54688. */
  54689. disableLighting: boolean;
  54690. /**
  54691. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54692. */
  54693. environmentTexture: BaseTexture;
  54694. /**
  54695. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54696. */
  54697. invertNormalMapX: boolean;
  54698. /**
  54699. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54700. */
  54701. invertNormalMapY: boolean;
  54702. /**
  54703. * Normal map used in the model.
  54704. */
  54705. normalTexture: BaseTexture;
  54706. /**
  54707. * Emissivie color used to self-illuminate the model.
  54708. */
  54709. emissiveColor: Color3;
  54710. /**
  54711. * Emissivie texture used to self-illuminate the model.
  54712. */
  54713. emissiveTexture: BaseTexture;
  54714. /**
  54715. * Occlusion Channel Strenght.
  54716. */
  54717. occlusionStrength: number;
  54718. /**
  54719. * Occlusion Texture of the material (adding extra occlusion effects).
  54720. */
  54721. occlusionTexture: BaseTexture;
  54722. /**
  54723. * Defines the alpha limits in alpha test mode.
  54724. */
  54725. alphaCutOff: number;
  54726. /**
  54727. * Gets the current double sided mode.
  54728. */
  54729. /**
  54730. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54731. */
  54732. doubleSided: boolean;
  54733. /**
  54734. * Stores the pre-calculated light information of a mesh in a texture.
  54735. */
  54736. lightmapTexture: BaseTexture;
  54737. /**
  54738. * If true, the light map contains occlusion information instead of lighting info.
  54739. */
  54740. useLightmapAsShadowmap: boolean;
  54741. /**
  54742. * Instantiates a new PBRMaterial instance.
  54743. *
  54744. * @param name The material name
  54745. * @param scene The scene the material will be use in.
  54746. */
  54747. constructor(name: string, scene: Scene);
  54748. getClassName(): string;
  54749. }
  54750. }
  54751. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54752. import { Scene } from "babylonjs/scene";
  54753. import { Color3 } from "babylonjs/Maths/math.color";
  54754. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54755. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54756. /**
  54757. * The PBR material of BJS following the metal roughness convention.
  54758. *
  54759. * This fits to the PBR convention in the GLTF definition:
  54760. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54761. */
  54762. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54763. /**
  54764. * The base color has two different interpretations depending on the value of metalness.
  54765. * When the material is a metal, the base color is the specific measured reflectance value
  54766. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54767. * of the material.
  54768. */
  54769. baseColor: Color3;
  54770. /**
  54771. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54772. * well as opacity information in the alpha channel.
  54773. */
  54774. baseTexture: BaseTexture;
  54775. /**
  54776. * Specifies the metallic scalar value of the material.
  54777. * Can also be used to scale the metalness values of the metallic texture.
  54778. */
  54779. metallic: number;
  54780. /**
  54781. * Specifies the roughness scalar value of the material.
  54782. * Can also be used to scale the roughness values of the metallic texture.
  54783. */
  54784. roughness: number;
  54785. /**
  54786. * Texture containing both the metallic value in the B channel and the
  54787. * roughness value in the G channel to keep better precision.
  54788. */
  54789. metallicRoughnessTexture: BaseTexture;
  54790. /**
  54791. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54792. *
  54793. * @param name The material name
  54794. * @param scene The scene the material will be use in.
  54795. */
  54796. constructor(name: string, scene: Scene);
  54797. /**
  54798. * Return the currrent class name of the material.
  54799. */
  54800. getClassName(): string;
  54801. /**
  54802. * Makes a duplicate of the current material.
  54803. * @param name - name to use for the new material.
  54804. */
  54805. clone(name: string): PBRMetallicRoughnessMaterial;
  54806. /**
  54807. * Serialize the material to a parsable JSON object.
  54808. */
  54809. serialize(): any;
  54810. /**
  54811. * Parses a JSON object correponding to the serialize function.
  54812. */
  54813. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54814. }
  54815. }
  54816. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54817. import { Scene } from "babylonjs/scene";
  54818. import { Color3 } from "babylonjs/Maths/math.color";
  54819. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54820. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54821. /**
  54822. * The PBR material of BJS following the specular glossiness convention.
  54823. *
  54824. * This fits to the PBR convention in the GLTF definition:
  54825. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54826. */
  54827. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54828. /**
  54829. * Specifies the diffuse color of the material.
  54830. */
  54831. diffuseColor: Color3;
  54832. /**
  54833. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54834. * channel.
  54835. */
  54836. diffuseTexture: BaseTexture;
  54837. /**
  54838. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54839. */
  54840. specularColor: Color3;
  54841. /**
  54842. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54843. */
  54844. glossiness: number;
  54845. /**
  54846. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54847. */
  54848. specularGlossinessTexture: BaseTexture;
  54849. /**
  54850. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54851. *
  54852. * @param name The material name
  54853. * @param scene The scene the material will be use in.
  54854. */
  54855. constructor(name: string, scene: Scene);
  54856. /**
  54857. * Return the currrent class name of the material.
  54858. */
  54859. getClassName(): string;
  54860. /**
  54861. * Makes a duplicate of the current material.
  54862. * @param name - name to use for the new material.
  54863. */
  54864. clone(name: string): PBRSpecularGlossinessMaterial;
  54865. /**
  54866. * Serialize the material to a parsable JSON object.
  54867. */
  54868. serialize(): any;
  54869. /**
  54870. * Parses a JSON object correponding to the serialize function.
  54871. */
  54872. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54873. }
  54874. }
  54875. declare module "babylonjs/Materials/PBR/index" {
  54876. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54877. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54878. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54879. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54880. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54881. }
  54882. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54883. import { Nullable } from "babylonjs/types";
  54884. import { Scene } from "babylonjs/scene";
  54885. import { Matrix } from "babylonjs/Maths/math.vector";
  54886. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54887. /**
  54888. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54889. * It can help converting any input color in a desired output one. This can then be used to create effects
  54890. * from sepia, black and white to sixties or futuristic rendering...
  54891. *
  54892. * The only supported format is currently 3dl.
  54893. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54894. */
  54895. export class ColorGradingTexture extends BaseTexture {
  54896. /**
  54897. * The current texture matrix. (will always be identity in color grading texture)
  54898. */
  54899. private _textureMatrix;
  54900. /**
  54901. * The texture URL.
  54902. */
  54903. url: string;
  54904. /**
  54905. * Empty line regex stored for GC.
  54906. */
  54907. private static _noneEmptyLineRegex;
  54908. private _engine;
  54909. /**
  54910. * Instantiates a ColorGradingTexture from the following parameters.
  54911. *
  54912. * @param url The location of the color gradind data (currently only supporting 3dl)
  54913. * @param scene The scene the texture will be used in
  54914. */
  54915. constructor(url: string, scene: Scene);
  54916. /**
  54917. * Returns the texture matrix used in most of the material.
  54918. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54919. */
  54920. getTextureMatrix(): Matrix;
  54921. /**
  54922. * Occurs when the file being loaded is a .3dl LUT file.
  54923. */
  54924. private load3dlTexture;
  54925. /**
  54926. * Starts the loading process of the texture.
  54927. */
  54928. private loadTexture;
  54929. /**
  54930. * Clones the color gradind texture.
  54931. */
  54932. clone(): ColorGradingTexture;
  54933. /**
  54934. * Called during delayed load for textures.
  54935. */
  54936. delayLoad(): void;
  54937. /**
  54938. * Parses a color grading texture serialized by Babylon.
  54939. * @param parsedTexture The texture information being parsedTexture
  54940. * @param scene The scene to load the texture in
  54941. * @param rootUrl The root url of the data assets to load
  54942. * @return A color gradind texture
  54943. */
  54944. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54945. /**
  54946. * Serializes the LUT texture to json format.
  54947. */
  54948. serialize(): any;
  54949. }
  54950. }
  54951. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54953. import { Scene } from "babylonjs/scene";
  54954. import { Nullable } from "babylonjs/types";
  54955. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54956. /**
  54957. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54958. */
  54959. export class EquiRectangularCubeTexture extends BaseTexture {
  54960. /** The six faces of the cube. */
  54961. private static _FacesMapping;
  54962. private _noMipmap;
  54963. private _onLoad;
  54964. private _onError;
  54965. /** The size of the cubemap. */
  54966. private _size;
  54967. /** The buffer of the image. */
  54968. private _buffer;
  54969. /** The width of the input image. */
  54970. private _width;
  54971. /** The height of the input image. */
  54972. private _height;
  54973. /** The URL to the image. */
  54974. url: string;
  54975. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54976. coordinatesMode: number;
  54977. /**
  54978. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54979. * @param url The location of the image
  54980. * @param scene The scene the texture will be used in
  54981. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54982. * @param noMipmap Forces to not generate the mipmap if true
  54983. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54984. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54985. * @param onLoad — defines a callback called when texture is loaded
  54986. * @param onError — defines a callback called if there is an error
  54987. */
  54988. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54989. /**
  54990. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54991. */
  54992. private loadImage;
  54993. /**
  54994. * Convert the image buffer into a cubemap and create a CubeTexture.
  54995. */
  54996. private loadTexture;
  54997. /**
  54998. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54999. * @param buffer The ArrayBuffer that should be converted.
  55000. * @returns The buffer as Float32Array.
  55001. */
  55002. private getFloat32ArrayFromArrayBuffer;
  55003. /**
  55004. * Get the current class name of the texture useful for serialization or dynamic coding.
  55005. * @returns "EquiRectangularCubeTexture"
  55006. */
  55007. getClassName(): string;
  55008. /**
  55009. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55010. * @returns A clone of the current EquiRectangularCubeTexture.
  55011. */
  55012. clone(): EquiRectangularCubeTexture;
  55013. }
  55014. }
  55015. declare module "babylonjs/Misc/tga" {
  55016. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55017. /**
  55018. * Based on jsTGALoader - Javascript loader for TGA file
  55019. * By Vincent Thibault
  55020. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55021. */
  55022. export class TGATools {
  55023. private static _TYPE_INDEXED;
  55024. private static _TYPE_RGB;
  55025. private static _TYPE_GREY;
  55026. private static _TYPE_RLE_INDEXED;
  55027. private static _TYPE_RLE_RGB;
  55028. private static _TYPE_RLE_GREY;
  55029. private static _ORIGIN_MASK;
  55030. private static _ORIGIN_SHIFT;
  55031. private static _ORIGIN_BL;
  55032. private static _ORIGIN_BR;
  55033. private static _ORIGIN_UL;
  55034. private static _ORIGIN_UR;
  55035. /**
  55036. * Gets the header of a TGA file
  55037. * @param data defines the TGA data
  55038. * @returns the header
  55039. */
  55040. static GetTGAHeader(data: Uint8Array): any;
  55041. /**
  55042. * Uploads TGA content to a Babylon Texture
  55043. * @hidden
  55044. */
  55045. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55046. /** @hidden */
  55047. 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;
  55048. /** @hidden */
  55049. 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;
  55050. /** @hidden */
  55051. 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;
  55052. /** @hidden */
  55053. 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;
  55054. /** @hidden */
  55055. 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;
  55056. /** @hidden */
  55057. 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;
  55058. }
  55059. }
  55060. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55061. import { Nullable } from "babylonjs/types";
  55062. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55063. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55064. /**
  55065. * Implementation of the TGA Texture Loader.
  55066. * @hidden
  55067. */
  55068. export class _TGATextureLoader implements IInternalTextureLoader {
  55069. /**
  55070. * Defines wether the loader supports cascade loading the different faces.
  55071. */
  55072. readonly supportCascades: boolean;
  55073. /**
  55074. * This returns if the loader support the current file information.
  55075. * @param extension defines the file extension of the file being loaded
  55076. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55077. * @param fallback defines the fallback internal texture if any
  55078. * @param isBase64 defines whether the texture is encoded as a base64
  55079. * @param isBuffer defines whether the texture data are stored as a buffer
  55080. * @returns true if the loader can load the specified file
  55081. */
  55082. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55083. /**
  55084. * Transform the url before loading if required.
  55085. * @param rootUrl the url of the texture
  55086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55087. * @returns the transformed texture
  55088. */
  55089. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55090. /**
  55091. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55092. * @param rootUrl the url of the texture
  55093. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55094. * @returns the fallback texture
  55095. */
  55096. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55097. /**
  55098. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55099. * @param data contains the texture data
  55100. * @param texture defines the BabylonJS internal texture
  55101. * @param createPolynomials will be true if polynomials have been requested
  55102. * @param onLoad defines the callback to trigger once the texture is ready
  55103. * @param onError defines the callback to trigger in case of error
  55104. */
  55105. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55106. /**
  55107. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55108. * @param data contains the texture data
  55109. * @param texture defines the BabylonJS internal texture
  55110. * @param callback defines the method to call once ready to upload
  55111. */
  55112. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55113. }
  55114. }
  55115. declare module "babylonjs/Misc/basis" {
  55116. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55117. /**
  55118. * Info about the .basis files
  55119. */
  55120. class BasisFileInfo {
  55121. /**
  55122. * If the file has alpha
  55123. */
  55124. hasAlpha: boolean;
  55125. /**
  55126. * Info about each image of the basis file
  55127. */
  55128. images: Array<{
  55129. levels: Array<{
  55130. width: number;
  55131. height: number;
  55132. transcodedPixels: ArrayBufferView;
  55133. }>;
  55134. }>;
  55135. }
  55136. /**
  55137. * Result of transcoding a basis file
  55138. */
  55139. class TranscodeResult {
  55140. /**
  55141. * Info about the .basis file
  55142. */
  55143. fileInfo: BasisFileInfo;
  55144. /**
  55145. * Format to use when loading the file
  55146. */
  55147. format: number;
  55148. }
  55149. /**
  55150. * Configuration options for the Basis transcoder
  55151. */
  55152. export class BasisTranscodeConfiguration {
  55153. /**
  55154. * Supported compression formats used to determine the supported output format of the transcoder
  55155. */
  55156. supportedCompressionFormats?: {
  55157. /**
  55158. * etc1 compression format
  55159. */
  55160. etc1?: boolean;
  55161. /**
  55162. * s3tc compression format
  55163. */
  55164. s3tc?: boolean;
  55165. /**
  55166. * pvrtc compression format
  55167. */
  55168. pvrtc?: boolean;
  55169. /**
  55170. * etc2 compression format
  55171. */
  55172. etc2?: boolean;
  55173. };
  55174. /**
  55175. * If mipmap levels should be loaded for transcoded images (Default: true)
  55176. */
  55177. loadMipmapLevels?: boolean;
  55178. /**
  55179. * Index of a single image to load (Default: all images)
  55180. */
  55181. loadSingleImage?: number;
  55182. }
  55183. /**
  55184. * Used to load .Basis files
  55185. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55186. */
  55187. export class BasisTools {
  55188. private static _IgnoreSupportedFormats;
  55189. /**
  55190. * URL to use when loading the basis transcoder
  55191. */
  55192. static JSModuleURL: string;
  55193. /**
  55194. * URL to use when loading the wasm module for the transcoder
  55195. */
  55196. static WasmModuleURL: string;
  55197. /**
  55198. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55199. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55200. * @returns internal format corresponding to the Basis format
  55201. */
  55202. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55203. private static _WorkerPromise;
  55204. private static _Worker;
  55205. private static _actionId;
  55206. private static _CreateWorkerAsync;
  55207. /**
  55208. * Transcodes a loaded image file to compressed pixel data
  55209. * @param imageData image data to transcode
  55210. * @param config configuration options for the transcoding
  55211. * @returns a promise resulting in the transcoded image
  55212. */
  55213. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55214. /**
  55215. * Loads a texture from the transcode result
  55216. * @param texture texture load to
  55217. * @param transcodeResult the result of transcoding the basis file to load from
  55218. */
  55219. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55220. }
  55221. }
  55222. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55223. import { Nullable } from "babylonjs/types";
  55224. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55225. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55226. /**
  55227. * Loader for .basis file format
  55228. */
  55229. export class _BasisTextureLoader implements IInternalTextureLoader {
  55230. /**
  55231. * Defines whether the loader supports cascade loading the different faces.
  55232. */
  55233. readonly supportCascades: boolean;
  55234. /**
  55235. * This returns if the loader support the current file information.
  55236. * @param extension defines the file extension of the file being loaded
  55237. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55238. * @param fallback defines the fallback internal texture if any
  55239. * @param isBase64 defines whether the texture is encoded as a base64
  55240. * @param isBuffer defines whether the texture data are stored as a buffer
  55241. * @returns true if the loader can load the specified file
  55242. */
  55243. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55244. /**
  55245. * Transform the url before loading if required.
  55246. * @param rootUrl the url of the texture
  55247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55248. * @returns the transformed texture
  55249. */
  55250. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55251. /**
  55252. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55253. * @param rootUrl the url of the texture
  55254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55255. * @returns the fallback texture
  55256. */
  55257. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55258. /**
  55259. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55260. * @param data contains the texture data
  55261. * @param texture defines the BabylonJS internal texture
  55262. * @param createPolynomials will be true if polynomials have been requested
  55263. * @param onLoad defines the callback to trigger once the texture is ready
  55264. * @param onError defines the callback to trigger in case of error
  55265. */
  55266. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55267. /**
  55268. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55269. * @param data contains the texture data
  55270. * @param texture defines the BabylonJS internal texture
  55271. * @param callback defines the method to call once ready to upload
  55272. */
  55273. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55274. }
  55275. }
  55276. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55277. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55278. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55279. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55280. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55281. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55282. }
  55283. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55284. import { Scene } from "babylonjs/scene";
  55285. import { Texture } from "babylonjs/Materials/Textures/texture";
  55286. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55287. /**
  55288. * 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.
  55289. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55290. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55291. */
  55292. export class CustomProceduralTexture extends ProceduralTexture {
  55293. private _animate;
  55294. private _time;
  55295. private _config;
  55296. private _texturePath;
  55297. /**
  55298. * Instantiates a new Custom Procedural Texture.
  55299. * 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.
  55300. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55301. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55302. * @param name Define the name of the texture
  55303. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55304. * @param size Define the size of the texture to create
  55305. * @param scene Define the scene the texture belongs to
  55306. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55307. * @param generateMipMaps Define if the texture should creates mip maps or not
  55308. */
  55309. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55310. private _loadJson;
  55311. /**
  55312. * Is the texture ready to be used ? (rendered at least once)
  55313. * @returns true if ready, otherwise, false.
  55314. */
  55315. isReady(): boolean;
  55316. /**
  55317. * Render the texture to its associated render target.
  55318. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55319. */
  55320. render(useCameraPostProcess?: boolean): void;
  55321. /**
  55322. * Update the list of dependant textures samplers in the shader.
  55323. */
  55324. updateTextures(): void;
  55325. /**
  55326. * Update the uniform values of the procedural texture in the shader.
  55327. */
  55328. updateShaderUniforms(): void;
  55329. /**
  55330. * Define if the texture animates or not.
  55331. */
  55332. animate: boolean;
  55333. }
  55334. }
  55335. declare module "babylonjs/Shaders/noise.fragment" {
  55336. /** @hidden */
  55337. export var noisePixelShader: {
  55338. name: string;
  55339. shader: string;
  55340. };
  55341. }
  55342. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55343. import { Nullable } from "babylonjs/types";
  55344. import { Scene } from "babylonjs/scene";
  55345. import { Texture } from "babylonjs/Materials/Textures/texture";
  55346. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55347. import "babylonjs/Shaders/noise.fragment";
  55348. /**
  55349. * Class used to generate noise procedural textures
  55350. */
  55351. export class NoiseProceduralTexture extends ProceduralTexture {
  55352. private _time;
  55353. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55354. brightness: number;
  55355. /** Defines the number of octaves to process */
  55356. octaves: number;
  55357. /** Defines the level of persistence (0.8 by default) */
  55358. persistence: number;
  55359. /** Gets or sets animation speed factor (default is 1) */
  55360. animationSpeedFactor: number;
  55361. /**
  55362. * Creates a new NoiseProceduralTexture
  55363. * @param name defines the name fo the texture
  55364. * @param size defines the size of the texture (default is 256)
  55365. * @param scene defines the hosting scene
  55366. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55367. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55368. */
  55369. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55370. private _updateShaderUniforms;
  55371. protected _getDefines(): string;
  55372. /** Generate the current state of the procedural texture */
  55373. render(useCameraPostProcess?: boolean): void;
  55374. /**
  55375. * Serializes this noise procedural texture
  55376. * @returns a serialized noise procedural texture object
  55377. */
  55378. serialize(): any;
  55379. /**
  55380. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55381. * @param parsedTexture defines parsed texture data
  55382. * @param scene defines the current scene
  55383. * @param rootUrl defines the root URL containing noise procedural texture information
  55384. * @returns a parsed NoiseProceduralTexture
  55385. */
  55386. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55387. }
  55388. }
  55389. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55390. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55391. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55392. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55393. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55394. }
  55395. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55396. import { Nullable } from "babylonjs/types";
  55397. import { Scene } from "babylonjs/scene";
  55398. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55400. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55401. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55402. /**
  55403. * Raw cube texture where the raw buffers are passed in
  55404. */
  55405. export class RawCubeTexture extends CubeTexture {
  55406. /**
  55407. * Creates a cube texture where the raw buffers are passed in.
  55408. * @param scene defines the scene the texture is attached to
  55409. * @param data defines the array of data to use to create each face
  55410. * @param size defines the size of the textures
  55411. * @param format defines the format of the data
  55412. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55413. * @param generateMipMaps defines if the engine should generate the mip levels
  55414. * @param invertY defines if data must be stored with Y axis inverted
  55415. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55416. * @param compression defines the compression used (null by default)
  55417. */
  55418. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55419. /**
  55420. * Updates the raw cube texture.
  55421. * @param data defines the data to store
  55422. * @param format defines the data format
  55423. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55424. * @param invertY defines if data must be stored with Y axis inverted
  55425. * @param compression defines the compression used (null by default)
  55426. * @param level defines which level of the texture to update
  55427. */
  55428. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55429. /**
  55430. * Updates a raw cube texture with RGBD encoded data.
  55431. * @param data defines the array of data [mipmap][face] to use to create each face
  55432. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55433. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55434. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55435. * @returns a promsie that resolves when the operation is complete
  55436. */
  55437. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55438. /**
  55439. * Clones the raw cube texture.
  55440. * @return a new cube texture
  55441. */
  55442. clone(): CubeTexture;
  55443. /** @hidden */
  55444. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55445. }
  55446. }
  55447. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55448. import { Scene } from "babylonjs/scene";
  55449. import { Texture } from "babylonjs/Materials/Textures/texture";
  55450. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55451. /**
  55452. * Class used to store 3D textures containing user data
  55453. */
  55454. export class RawTexture3D extends Texture {
  55455. /** Gets or sets the texture format to use */
  55456. format: number;
  55457. private _engine;
  55458. /**
  55459. * Create a new RawTexture3D
  55460. * @param data defines the data of the texture
  55461. * @param width defines the width of the texture
  55462. * @param height defines the height of the texture
  55463. * @param depth defines the depth of the texture
  55464. * @param format defines the texture format to use
  55465. * @param scene defines the hosting scene
  55466. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55467. * @param invertY defines if texture must be stored with Y axis inverted
  55468. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55469. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55470. */
  55471. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55472. /** Gets or sets the texture format to use */
  55473. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55474. /**
  55475. * Update the texture with new data
  55476. * @param data defines the data to store in the texture
  55477. */
  55478. update(data: ArrayBufferView): void;
  55479. }
  55480. }
  55481. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55482. import { Scene } from "babylonjs/scene";
  55483. import { Texture } from "babylonjs/Materials/Textures/texture";
  55484. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55485. /**
  55486. * Class used to store 2D array textures containing user data
  55487. */
  55488. export class RawTexture2DArray extends Texture {
  55489. /** Gets or sets the texture format to use */
  55490. format: number;
  55491. private _engine;
  55492. /**
  55493. * Create a new RawTexture2DArray
  55494. * @param data defines the data of the texture
  55495. * @param width defines the width of the texture
  55496. * @param height defines the height of the texture
  55497. * @param depth defines the number of layers of the texture
  55498. * @param format defines the texture format to use
  55499. * @param scene defines the hosting scene
  55500. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55501. * @param invertY defines if texture must be stored with Y axis inverted
  55502. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55503. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55504. */
  55505. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55506. /** Gets or sets the texture format to use */
  55507. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55508. /**
  55509. * Update the texture with new data
  55510. * @param data defines the data to store in the texture
  55511. */
  55512. update(data: ArrayBufferView): void;
  55513. }
  55514. }
  55515. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55516. import { Scene } from "babylonjs/scene";
  55517. import { Plane } from "babylonjs/Maths/math.plane";
  55518. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55519. /**
  55520. * Creates a refraction texture used by refraction channel of the standard material.
  55521. * It is like a mirror but to see through a material.
  55522. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55523. */
  55524. export class RefractionTexture extends RenderTargetTexture {
  55525. /**
  55526. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55527. * 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.
  55528. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55529. */
  55530. refractionPlane: Plane;
  55531. /**
  55532. * Define how deep under the surface we should see.
  55533. */
  55534. depth: number;
  55535. /**
  55536. * Creates a refraction texture used by refraction channel of the standard material.
  55537. * It is like a mirror but to see through a material.
  55538. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55539. * @param name Define the texture name
  55540. * @param size Define the size of the underlying texture
  55541. * @param scene Define the scene the refraction belongs to
  55542. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55543. */
  55544. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55545. /**
  55546. * Clone the refraction texture.
  55547. * @returns the cloned texture
  55548. */
  55549. clone(): RefractionTexture;
  55550. /**
  55551. * Serialize the texture to a JSON representation you could use in Parse later on
  55552. * @returns the serialized JSON representation
  55553. */
  55554. serialize(): any;
  55555. }
  55556. }
  55557. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55558. import { Nullable } from "babylonjs/types";
  55559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55560. import { Matrix } from "babylonjs/Maths/math.vector";
  55561. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55562. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55563. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55564. import { Scene } from "babylonjs/scene";
  55565. /**
  55566. * Defines the options related to the creation of an HtmlElementTexture
  55567. */
  55568. export interface IHtmlElementTextureOptions {
  55569. /**
  55570. * Defines wether mip maps should be created or not.
  55571. */
  55572. generateMipMaps?: boolean;
  55573. /**
  55574. * Defines the sampling mode of the texture.
  55575. */
  55576. samplingMode?: number;
  55577. /**
  55578. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55579. */
  55580. engine: Nullable<ThinEngine>;
  55581. /**
  55582. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55583. */
  55584. scene: Nullable<Scene>;
  55585. }
  55586. /**
  55587. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55588. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55589. * is automatically managed.
  55590. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55591. * in your application.
  55592. *
  55593. * As the update is not automatic, you need to call them manually.
  55594. */
  55595. export class HtmlElementTexture extends BaseTexture {
  55596. /**
  55597. * The texture URL.
  55598. */
  55599. element: HTMLVideoElement | HTMLCanvasElement;
  55600. private static readonly DefaultOptions;
  55601. private _textureMatrix;
  55602. private _engine;
  55603. private _isVideo;
  55604. private _generateMipMaps;
  55605. private _samplingMode;
  55606. /**
  55607. * Instantiates a HtmlElementTexture from the following parameters.
  55608. *
  55609. * @param name Defines the name of the texture
  55610. * @param element Defines the video or canvas the texture is filled with
  55611. * @param options Defines the other none mandatory texture creation options
  55612. */
  55613. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55614. private _createInternalTexture;
  55615. /**
  55616. * Returns the texture matrix used in most of the material.
  55617. */
  55618. getTextureMatrix(): Matrix;
  55619. /**
  55620. * Updates the content of the texture.
  55621. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55622. */
  55623. update(invertY?: Nullable<boolean>): void;
  55624. }
  55625. }
  55626. declare module "babylonjs/Materials/Textures/index" {
  55627. export * from "babylonjs/Materials/Textures/baseTexture";
  55628. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55629. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55630. export * from "babylonjs/Materials/Textures/cubeTexture";
  55631. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55632. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55633. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55634. export * from "babylonjs/Materials/Textures/internalTexture";
  55635. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55636. export * from "babylonjs/Materials/Textures/Loaders/index";
  55637. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55638. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55639. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55640. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55641. export * from "babylonjs/Materials/Textures/rawTexture";
  55642. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55643. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55644. export * from "babylonjs/Materials/Textures/refractionTexture";
  55645. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55646. export * from "babylonjs/Materials/Textures/texture";
  55647. export * from "babylonjs/Materials/Textures/videoTexture";
  55648. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55649. }
  55650. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55651. /**
  55652. * Enum used to define the target of a block
  55653. */
  55654. export enum NodeMaterialBlockTargets {
  55655. /** Vertex shader */
  55656. Vertex = 1,
  55657. /** Fragment shader */
  55658. Fragment = 2,
  55659. /** Neutral */
  55660. Neutral = 4,
  55661. /** Vertex and Fragment */
  55662. VertexAndFragment = 3
  55663. }
  55664. }
  55665. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55666. /**
  55667. * Defines the kind of connection point for node based material
  55668. */
  55669. export enum NodeMaterialBlockConnectionPointTypes {
  55670. /** Float */
  55671. Float = 1,
  55672. /** Int */
  55673. Int = 2,
  55674. /** Vector2 */
  55675. Vector2 = 4,
  55676. /** Vector3 */
  55677. Vector3 = 8,
  55678. /** Vector4 */
  55679. Vector4 = 16,
  55680. /** Color3 */
  55681. Color3 = 32,
  55682. /** Color4 */
  55683. Color4 = 64,
  55684. /** Matrix */
  55685. Matrix = 128,
  55686. /** Detect type based on connection */
  55687. AutoDetect = 1024,
  55688. /** Output type that will be defined by input type */
  55689. BasedOnInput = 2048
  55690. }
  55691. }
  55692. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55693. /**
  55694. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55695. */
  55696. export enum NodeMaterialBlockConnectionPointMode {
  55697. /** Value is an uniform */
  55698. Uniform = 0,
  55699. /** Value is a mesh attribute */
  55700. Attribute = 1,
  55701. /** Value is a varying between vertex and fragment shaders */
  55702. Varying = 2,
  55703. /** Mode is undefined */
  55704. Undefined = 3
  55705. }
  55706. }
  55707. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55708. /**
  55709. * Enum used to define system values e.g. values automatically provided by the system
  55710. */
  55711. export enum NodeMaterialSystemValues {
  55712. /** World */
  55713. World = 1,
  55714. /** View */
  55715. View = 2,
  55716. /** Projection */
  55717. Projection = 3,
  55718. /** ViewProjection */
  55719. ViewProjection = 4,
  55720. /** WorldView */
  55721. WorldView = 5,
  55722. /** WorldViewProjection */
  55723. WorldViewProjection = 6,
  55724. /** CameraPosition */
  55725. CameraPosition = 7,
  55726. /** Fog Color */
  55727. FogColor = 8,
  55728. /** Delta time */
  55729. DeltaTime = 9
  55730. }
  55731. }
  55732. declare module "babylonjs/Materials/Node/Enums/index" {
  55733. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55734. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55735. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55736. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55737. }
  55738. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55740. /**
  55741. * Root class for all node material optimizers
  55742. */
  55743. export class NodeMaterialOptimizer {
  55744. /**
  55745. * Function used to optimize a NodeMaterial graph
  55746. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55747. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55748. */
  55749. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55750. }
  55751. }
  55752. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55756. import { Scene } from "babylonjs/scene";
  55757. /**
  55758. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55759. */
  55760. export class TransformBlock extends NodeMaterialBlock {
  55761. /**
  55762. * Defines the value to use to complement W value to transform it to a Vector4
  55763. */
  55764. complementW: number;
  55765. /**
  55766. * Defines the value to use to complement z value to transform it to a Vector4
  55767. */
  55768. complementZ: number;
  55769. /**
  55770. * Creates a new TransformBlock
  55771. * @param name defines the block name
  55772. */
  55773. constructor(name: string);
  55774. /**
  55775. * Gets the current class name
  55776. * @returns the class name
  55777. */
  55778. getClassName(): string;
  55779. /**
  55780. * Gets the vector input
  55781. */
  55782. readonly vector: NodeMaterialConnectionPoint;
  55783. /**
  55784. * Gets the output component
  55785. */
  55786. readonly output: NodeMaterialConnectionPoint;
  55787. /**
  55788. * Gets the matrix transform input
  55789. */
  55790. readonly transform: NodeMaterialConnectionPoint;
  55791. protected _buildBlock(state: NodeMaterialBuildState): this;
  55792. serialize(): any;
  55793. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55794. protected _dumpPropertiesCode(): string;
  55795. }
  55796. }
  55797. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55801. /**
  55802. * Block used to output the vertex position
  55803. */
  55804. export class VertexOutputBlock extends NodeMaterialBlock {
  55805. /**
  55806. * Creates a new VertexOutputBlock
  55807. * @param name defines the block name
  55808. */
  55809. constructor(name: string);
  55810. /**
  55811. * Gets the current class name
  55812. * @returns the class name
  55813. */
  55814. getClassName(): string;
  55815. /**
  55816. * Gets the vector input component
  55817. */
  55818. readonly vector: NodeMaterialConnectionPoint;
  55819. protected _buildBlock(state: NodeMaterialBuildState): this;
  55820. }
  55821. }
  55822. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55826. /**
  55827. * Block used to output the final color
  55828. */
  55829. export class FragmentOutputBlock extends NodeMaterialBlock {
  55830. /**
  55831. * Create a new FragmentOutputBlock
  55832. * @param name defines the block name
  55833. */
  55834. constructor(name: string);
  55835. /**
  55836. * Gets the current class name
  55837. * @returns the class name
  55838. */
  55839. getClassName(): string;
  55840. /**
  55841. * Gets the rgba input component
  55842. */
  55843. readonly rgba: NodeMaterialConnectionPoint;
  55844. /**
  55845. * Gets the rgb input component
  55846. */
  55847. readonly rgb: NodeMaterialConnectionPoint;
  55848. /**
  55849. * Gets the a input component
  55850. */
  55851. readonly a: NodeMaterialConnectionPoint;
  55852. protected _buildBlock(state: NodeMaterialBuildState): this;
  55853. }
  55854. }
  55855. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55861. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55862. import { Effect } from "babylonjs/Materials/effect";
  55863. import { Mesh } from "babylonjs/Meshes/mesh";
  55864. import { Nullable } from "babylonjs/types";
  55865. import { Scene } from "babylonjs/scene";
  55866. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55867. /**
  55868. * Block used to read a reflection texture from a sampler
  55869. */
  55870. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55871. private _define3DName;
  55872. private _defineCubicName;
  55873. private _defineExplicitName;
  55874. private _defineProjectionName;
  55875. private _defineLocalCubicName;
  55876. private _defineSphericalName;
  55877. private _definePlanarName;
  55878. private _defineEquirectangularName;
  55879. private _defineMirroredEquirectangularFixedName;
  55880. private _defineEquirectangularFixedName;
  55881. private _defineSkyboxName;
  55882. private _cubeSamplerName;
  55883. private _2DSamplerName;
  55884. private _positionUVWName;
  55885. private _directionWName;
  55886. private _reflectionCoordsName;
  55887. private _reflection2DCoordsName;
  55888. private _reflectionColorName;
  55889. private _reflectionMatrixName;
  55890. /**
  55891. * Gets or sets the texture associated with the node
  55892. */
  55893. texture: Nullable<BaseTexture>;
  55894. /**
  55895. * Create a new TextureBlock
  55896. * @param name defines the block name
  55897. */
  55898. constructor(name: string);
  55899. /**
  55900. * Gets the current class name
  55901. * @returns the class name
  55902. */
  55903. getClassName(): string;
  55904. /**
  55905. * Gets the world position input component
  55906. */
  55907. readonly position: NodeMaterialConnectionPoint;
  55908. /**
  55909. * Gets the world position input component
  55910. */
  55911. readonly worldPosition: NodeMaterialConnectionPoint;
  55912. /**
  55913. * Gets the world normal input component
  55914. */
  55915. readonly worldNormal: NodeMaterialConnectionPoint;
  55916. /**
  55917. * Gets the world input component
  55918. */
  55919. readonly world: NodeMaterialConnectionPoint;
  55920. /**
  55921. * Gets the camera (or eye) position component
  55922. */
  55923. readonly cameraPosition: NodeMaterialConnectionPoint;
  55924. /**
  55925. * Gets the view input component
  55926. */
  55927. readonly view: NodeMaterialConnectionPoint;
  55928. /**
  55929. * Gets the rgb output component
  55930. */
  55931. readonly rgb: NodeMaterialConnectionPoint;
  55932. /**
  55933. * Gets the r output component
  55934. */
  55935. readonly r: NodeMaterialConnectionPoint;
  55936. /**
  55937. * Gets the g output component
  55938. */
  55939. readonly g: NodeMaterialConnectionPoint;
  55940. /**
  55941. * Gets the b output component
  55942. */
  55943. readonly b: NodeMaterialConnectionPoint;
  55944. autoConfigure(material: NodeMaterial): void;
  55945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55946. isReady(): boolean;
  55947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55948. private _injectVertexCode;
  55949. private _writeOutput;
  55950. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55951. protected _dumpPropertiesCode(): string;
  55952. serialize(): any;
  55953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55954. }
  55955. }
  55956. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55958. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55959. import { Scene } from "babylonjs/scene";
  55960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55961. import { Matrix } from "babylonjs/Maths/math.vector";
  55962. import { Mesh } from "babylonjs/Meshes/mesh";
  55963. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55964. import { Observable } from "babylonjs/Misc/observable";
  55965. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55966. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55967. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55968. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55969. import { Nullable } from "babylonjs/types";
  55970. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55971. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55972. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55973. /**
  55974. * Interface used to configure the node material editor
  55975. */
  55976. export interface INodeMaterialEditorOptions {
  55977. /** Define the URl to load node editor script */
  55978. editorURL?: string;
  55979. }
  55980. /** @hidden */
  55981. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55982. /** BONES */
  55983. NUM_BONE_INFLUENCERS: number;
  55984. BonesPerMesh: number;
  55985. BONETEXTURE: boolean;
  55986. /** MORPH TARGETS */
  55987. MORPHTARGETS: boolean;
  55988. MORPHTARGETS_NORMAL: boolean;
  55989. MORPHTARGETS_TANGENT: boolean;
  55990. MORPHTARGETS_UV: boolean;
  55991. NUM_MORPH_INFLUENCERS: number;
  55992. /** IMAGE PROCESSING */
  55993. IMAGEPROCESSING: boolean;
  55994. VIGNETTE: boolean;
  55995. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55996. VIGNETTEBLENDMODEOPAQUE: boolean;
  55997. TONEMAPPING: boolean;
  55998. TONEMAPPING_ACES: boolean;
  55999. CONTRAST: boolean;
  56000. EXPOSURE: boolean;
  56001. COLORCURVES: boolean;
  56002. COLORGRADING: boolean;
  56003. COLORGRADING3D: boolean;
  56004. SAMPLER3DGREENDEPTH: boolean;
  56005. SAMPLER3DBGRMAP: boolean;
  56006. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56007. /** MISC. */
  56008. BUMPDIRECTUV: number;
  56009. constructor();
  56010. setValue(name: string, value: boolean): void;
  56011. }
  56012. /**
  56013. * Class used to configure NodeMaterial
  56014. */
  56015. export interface INodeMaterialOptions {
  56016. /**
  56017. * Defines if blocks should emit comments
  56018. */
  56019. emitComments: boolean;
  56020. }
  56021. /**
  56022. * Class used to create a node based material built by assembling shader blocks
  56023. */
  56024. export class NodeMaterial extends PushMaterial {
  56025. private static _BuildIdGenerator;
  56026. private _options;
  56027. private _vertexCompilationState;
  56028. private _fragmentCompilationState;
  56029. private _sharedData;
  56030. private _buildId;
  56031. private _buildWasSuccessful;
  56032. private _cachedWorldViewMatrix;
  56033. private _cachedWorldViewProjectionMatrix;
  56034. private _optimizers;
  56035. private _animationFrame;
  56036. /** Define the URl to load node editor script */
  56037. static EditorURL: string;
  56038. private BJSNODEMATERIALEDITOR;
  56039. /** Get the inspector from bundle or global */
  56040. private _getGlobalNodeMaterialEditor;
  56041. /**
  56042. * 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)
  56043. */
  56044. ignoreAlpha: boolean;
  56045. /**
  56046. * Defines the maximum number of lights that can be used in the material
  56047. */
  56048. maxSimultaneousLights: number;
  56049. /**
  56050. * Observable raised when the material is built
  56051. */
  56052. onBuildObservable: Observable<NodeMaterial>;
  56053. /**
  56054. * Gets or sets the root nodes of the material vertex shader
  56055. */
  56056. _vertexOutputNodes: NodeMaterialBlock[];
  56057. /**
  56058. * Gets or sets the root nodes of the material fragment (pixel) shader
  56059. */
  56060. _fragmentOutputNodes: NodeMaterialBlock[];
  56061. /** Gets or sets options to control the node material overall behavior */
  56062. options: INodeMaterialOptions;
  56063. /**
  56064. * Default configuration related to image processing available in the standard Material.
  56065. */
  56066. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56067. /**
  56068. * Gets the image processing configuration used either in this material.
  56069. */
  56070. /**
  56071. * Sets the Default image processing configuration used either in the this material.
  56072. *
  56073. * If sets to null, the scene one is in use.
  56074. */
  56075. imageProcessingConfiguration: ImageProcessingConfiguration;
  56076. /**
  56077. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56078. */
  56079. attachedBlocks: NodeMaterialBlock[];
  56080. /**
  56081. * Create a new node based material
  56082. * @param name defines the material name
  56083. * @param scene defines the hosting scene
  56084. * @param options defines creation option
  56085. */
  56086. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56087. /**
  56088. * Gets the current class name of the material e.g. "NodeMaterial"
  56089. * @returns the class name
  56090. */
  56091. getClassName(): string;
  56092. /**
  56093. * Keep track of the image processing observer to allow dispose and replace.
  56094. */
  56095. private _imageProcessingObserver;
  56096. /**
  56097. * Attaches a new image processing configuration to the Standard Material.
  56098. * @param configuration
  56099. */
  56100. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56101. /**
  56102. * Get a block by its name
  56103. * @param name defines the name of the block to retrieve
  56104. * @returns the required block or null if not found
  56105. */
  56106. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56107. /**
  56108. * Get a block by its name
  56109. * @param predicate defines the predicate used to find the good candidate
  56110. * @returns the required block or null if not found
  56111. */
  56112. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56113. /**
  56114. * Get an input block by its name
  56115. * @param predicate defines the predicate used to find the good candidate
  56116. * @returns the required input block or null if not found
  56117. */
  56118. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56119. /**
  56120. * Gets the list of input blocks attached to this material
  56121. * @returns an array of InputBlocks
  56122. */
  56123. getInputBlocks(): InputBlock[];
  56124. /**
  56125. * Adds a new optimizer to the list of optimizers
  56126. * @param optimizer defines the optimizers to add
  56127. * @returns the current material
  56128. */
  56129. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56130. /**
  56131. * Remove an optimizer from the list of optimizers
  56132. * @param optimizer defines the optimizers to remove
  56133. * @returns the current material
  56134. */
  56135. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56136. /**
  56137. * Add a new block to the list of output nodes
  56138. * @param node defines the node to add
  56139. * @returns the current material
  56140. */
  56141. addOutputNode(node: NodeMaterialBlock): this;
  56142. /**
  56143. * Remove a block from the list of root nodes
  56144. * @param node defines the node to remove
  56145. * @returns the current material
  56146. */
  56147. removeOutputNode(node: NodeMaterialBlock): this;
  56148. private _addVertexOutputNode;
  56149. private _removeVertexOutputNode;
  56150. private _addFragmentOutputNode;
  56151. private _removeFragmentOutputNode;
  56152. /**
  56153. * Specifies if the material will require alpha blending
  56154. * @returns a boolean specifying if alpha blending is needed
  56155. */
  56156. needAlphaBlending(): boolean;
  56157. /**
  56158. * Specifies if this material should be rendered in alpha test mode
  56159. * @returns a boolean specifying if an alpha test is needed.
  56160. */
  56161. needAlphaTesting(): boolean;
  56162. private _initializeBlock;
  56163. private _resetDualBlocks;
  56164. /**
  56165. * Build the material and generates the inner effect
  56166. * @param verbose defines if the build should log activity
  56167. */
  56168. build(verbose?: boolean): void;
  56169. /**
  56170. * Runs an otpimization phase to try to improve the shader code
  56171. */
  56172. optimize(): void;
  56173. private _prepareDefinesForAttributes;
  56174. /**
  56175. * Get if the submesh is ready to be used and all its information available.
  56176. * Child classes can use it to update shaders
  56177. * @param mesh defines the mesh to check
  56178. * @param subMesh defines which submesh to check
  56179. * @param useInstances specifies that instances should be used
  56180. * @returns a boolean indicating that the submesh is ready or not
  56181. */
  56182. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56183. /**
  56184. * Get a string representing the shaders built by the current node graph
  56185. */
  56186. readonly compiledShaders: string;
  56187. /**
  56188. * Binds the world matrix to the material
  56189. * @param world defines the world transformation matrix
  56190. */
  56191. bindOnlyWorldMatrix(world: Matrix): void;
  56192. /**
  56193. * Binds the submesh to this material by preparing the effect and shader to draw
  56194. * @param world defines the world transformation matrix
  56195. * @param mesh defines the mesh containing the submesh
  56196. * @param subMesh defines the submesh to bind the material to
  56197. */
  56198. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56199. /**
  56200. * Gets the active textures from the material
  56201. * @returns an array of textures
  56202. */
  56203. getActiveTextures(): BaseTexture[];
  56204. /**
  56205. * Gets the list of texture blocks
  56206. * @returns an array of texture blocks
  56207. */
  56208. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56209. /**
  56210. * Specifies if the material uses a texture
  56211. * @param texture defines the texture to check against the material
  56212. * @returns a boolean specifying if the material uses the texture
  56213. */
  56214. hasTexture(texture: BaseTexture): boolean;
  56215. /**
  56216. * Disposes the material
  56217. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56218. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56219. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56220. */
  56221. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56222. /** Creates the node editor window. */
  56223. private _createNodeEditor;
  56224. /**
  56225. * Launch the node material editor
  56226. * @param config Define the configuration of the editor
  56227. * @return a promise fulfilled when the node editor is visible
  56228. */
  56229. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56230. /**
  56231. * Clear the current material
  56232. */
  56233. clear(): void;
  56234. /**
  56235. * Clear the current material and set it to a default state
  56236. */
  56237. setToDefault(): void;
  56238. /**
  56239. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56240. * @param url defines the url to load from
  56241. * @returns a promise that will fullfil when the material is fully loaded
  56242. */
  56243. loadAsync(url: string): Promise<void>;
  56244. private _gatherBlocks;
  56245. /**
  56246. * Generate a string containing the code declaration required to create an equivalent of this material
  56247. * @returns a string
  56248. */
  56249. generateCode(): string;
  56250. /**
  56251. * Serializes this material in a JSON representation
  56252. * @returns the serialized material object
  56253. */
  56254. serialize(): any;
  56255. private _restoreConnections;
  56256. /**
  56257. * Clear the current graph and load a new one from a serialization object
  56258. * @param source defines the JSON representation of the material
  56259. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56260. */
  56261. loadFromSerialization(source: any, rootUrl?: string): void;
  56262. /**
  56263. * Creates a node material from parsed material data
  56264. * @param source defines the JSON representation of the material
  56265. * @param scene defines the hosting scene
  56266. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56267. * @returns a new node material
  56268. */
  56269. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56270. /**
  56271. * Creates a new node material set to default basic configuration
  56272. * @param name defines the name of the material
  56273. * @param scene defines the hosting scene
  56274. * @returns a new NodeMaterial
  56275. */
  56276. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56277. }
  56278. }
  56279. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56282. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56285. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56286. import { Effect } from "babylonjs/Materials/effect";
  56287. import { Mesh } from "babylonjs/Meshes/mesh";
  56288. import { Nullable } from "babylonjs/types";
  56289. import { Texture } from "babylonjs/Materials/Textures/texture";
  56290. import { Scene } from "babylonjs/scene";
  56291. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56292. /**
  56293. * Block used to read a texture from a sampler
  56294. */
  56295. export class TextureBlock extends NodeMaterialBlock {
  56296. private _defineName;
  56297. private _linearDefineName;
  56298. private _samplerName;
  56299. private _transformedUVName;
  56300. private _textureTransformName;
  56301. private _textureInfoName;
  56302. private _mainUVName;
  56303. private _mainUVDefineName;
  56304. /**
  56305. * Gets or sets the texture associated with the node
  56306. */
  56307. texture: Nullable<Texture>;
  56308. /**
  56309. * Create a new TextureBlock
  56310. * @param name defines the block name
  56311. */
  56312. constructor(name: string);
  56313. /**
  56314. * Gets the current class name
  56315. * @returns the class name
  56316. */
  56317. getClassName(): string;
  56318. /**
  56319. * Gets the uv input component
  56320. */
  56321. readonly uv: NodeMaterialConnectionPoint;
  56322. /**
  56323. * Gets the rgba output component
  56324. */
  56325. readonly rgba: NodeMaterialConnectionPoint;
  56326. /**
  56327. * Gets the rgb output component
  56328. */
  56329. readonly rgb: NodeMaterialConnectionPoint;
  56330. /**
  56331. * Gets the r output component
  56332. */
  56333. readonly r: NodeMaterialConnectionPoint;
  56334. /**
  56335. * Gets the g output component
  56336. */
  56337. readonly g: NodeMaterialConnectionPoint;
  56338. /**
  56339. * Gets the b output component
  56340. */
  56341. readonly b: NodeMaterialConnectionPoint;
  56342. /**
  56343. * Gets the a output component
  56344. */
  56345. readonly a: NodeMaterialConnectionPoint;
  56346. readonly target: NodeMaterialBlockTargets;
  56347. autoConfigure(material: NodeMaterial): void;
  56348. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56350. isReady(): boolean;
  56351. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56352. private readonly _isMixed;
  56353. private _injectVertexCode;
  56354. private _writeOutput;
  56355. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56356. protected _dumpPropertiesCode(): string;
  56357. serialize(): any;
  56358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56359. }
  56360. }
  56361. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56363. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56364. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56365. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56366. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56367. import { Scene } from "babylonjs/scene";
  56368. /**
  56369. * Class used to store shared data between 2 NodeMaterialBuildState
  56370. */
  56371. export class NodeMaterialBuildStateSharedData {
  56372. /**
  56373. * Gets the list of emitted varyings
  56374. */
  56375. temps: string[];
  56376. /**
  56377. * Gets the list of emitted varyings
  56378. */
  56379. varyings: string[];
  56380. /**
  56381. * Gets the varying declaration string
  56382. */
  56383. varyingDeclaration: string;
  56384. /**
  56385. * Input blocks
  56386. */
  56387. inputBlocks: InputBlock[];
  56388. /**
  56389. * Input blocks
  56390. */
  56391. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56392. /**
  56393. * Bindable blocks (Blocks that need to set data to the effect)
  56394. */
  56395. bindableBlocks: NodeMaterialBlock[];
  56396. /**
  56397. * List of blocks that can provide a compilation fallback
  56398. */
  56399. blocksWithFallbacks: NodeMaterialBlock[];
  56400. /**
  56401. * List of blocks that can provide a define update
  56402. */
  56403. blocksWithDefines: NodeMaterialBlock[];
  56404. /**
  56405. * List of blocks that can provide a repeatable content
  56406. */
  56407. repeatableContentBlocks: NodeMaterialBlock[];
  56408. /**
  56409. * List of blocks that can provide a dynamic list of uniforms
  56410. */
  56411. dynamicUniformBlocks: NodeMaterialBlock[];
  56412. /**
  56413. * List of blocks that can block the isReady function for the material
  56414. */
  56415. blockingBlocks: NodeMaterialBlock[];
  56416. /**
  56417. * Gets the list of animated inputs
  56418. */
  56419. animatedInputs: InputBlock[];
  56420. /**
  56421. * Build Id used to avoid multiple recompilations
  56422. */
  56423. buildId: number;
  56424. /** List of emitted variables */
  56425. variableNames: {
  56426. [key: string]: number;
  56427. };
  56428. /** List of emitted defines */
  56429. defineNames: {
  56430. [key: string]: number;
  56431. };
  56432. /** Should emit comments? */
  56433. emitComments: boolean;
  56434. /** Emit build activity */
  56435. verbose: boolean;
  56436. /** Gets or sets the hosting scene */
  56437. scene: Scene;
  56438. /**
  56439. * Gets the compilation hints emitted at compilation time
  56440. */
  56441. hints: {
  56442. needWorldViewMatrix: boolean;
  56443. needWorldViewProjectionMatrix: boolean;
  56444. needAlphaBlending: boolean;
  56445. needAlphaTesting: boolean;
  56446. };
  56447. /**
  56448. * List of compilation checks
  56449. */
  56450. checks: {
  56451. emitVertex: boolean;
  56452. emitFragment: boolean;
  56453. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56454. };
  56455. /** Creates a new shared data */
  56456. constructor();
  56457. /**
  56458. * Emits console errors and exceptions if there is a failing check
  56459. */
  56460. emitErrors(): void;
  56461. }
  56462. }
  56463. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56464. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56465. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56466. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56467. /**
  56468. * Class used to store node based material build state
  56469. */
  56470. export class NodeMaterialBuildState {
  56471. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56472. supportUniformBuffers: boolean;
  56473. /**
  56474. * Gets the list of emitted attributes
  56475. */
  56476. attributes: string[];
  56477. /**
  56478. * Gets the list of emitted uniforms
  56479. */
  56480. uniforms: string[];
  56481. /**
  56482. * Gets the list of emitted constants
  56483. */
  56484. constants: string[];
  56485. /**
  56486. * Gets the list of emitted samplers
  56487. */
  56488. samplers: string[];
  56489. /**
  56490. * Gets the list of emitted functions
  56491. */
  56492. functions: {
  56493. [key: string]: string;
  56494. };
  56495. /**
  56496. * Gets the list of emitted extensions
  56497. */
  56498. extensions: {
  56499. [key: string]: string;
  56500. };
  56501. /**
  56502. * Gets the target of the compilation state
  56503. */
  56504. target: NodeMaterialBlockTargets;
  56505. /**
  56506. * Gets the list of emitted counters
  56507. */
  56508. counters: {
  56509. [key: string]: number;
  56510. };
  56511. /**
  56512. * Shared data between multiple NodeMaterialBuildState instances
  56513. */
  56514. sharedData: NodeMaterialBuildStateSharedData;
  56515. /** @hidden */
  56516. _vertexState: NodeMaterialBuildState;
  56517. /** @hidden */
  56518. _attributeDeclaration: string;
  56519. /** @hidden */
  56520. _uniformDeclaration: string;
  56521. /** @hidden */
  56522. _constantDeclaration: string;
  56523. /** @hidden */
  56524. _samplerDeclaration: string;
  56525. /** @hidden */
  56526. _varyingTransfer: string;
  56527. private _repeatableContentAnchorIndex;
  56528. /** @hidden */
  56529. _builtCompilationString: string;
  56530. /**
  56531. * Gets the emitted compilation strings
  56532. */
  56533. compilationString: string;
  56534. /**
  56535. * Finalize the compilation strings
  56536. * @param state defines the current compilation state
  56537. */
  56538. finalize(state: NodeMaterialBuildState): void;
  56539. /** @hidden */
  56540. readonly _repeatableContentAnchor: string;
  56541. /** @hidden */
  56542. _getFreeVariableName(prefix: string): string;
  56543. /** @hidden */
  56544. _getFreeDefineName(prefix: string): string;
  56545. /** @hidden */
  56546. _excludeVariableName(name: string): void;
  56547. /** @hidden */
  56548. _emit2DSampler(name: string): void;
  56549. /** @hidden */
  56550. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56551. /** @hidden */
  56552. _emitExtension(name: string, extension: string): void;
  56553. /** @hidden */
  56554. _emitFunction(name: string, code: string, comments: string): void;
  56555. /** @hidden */
  56556. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56557. replaceStrings?: {
  56558. search: RegExp;
  56559. replace: string;
  56560. }[];
  56561. repeatKey?: string;
  56562. }): string;
  56563. /** @hidden */
  56564. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56565. repeatKey?: string;
  56566. removeAttributes?: boolean;
  56567. removeUniforms?: boolean;
  56568. removeVaryings?: boolean;
  56569. removeIfDef?: boolean;
  56570. replaceStrings?: {
  56571. search: RegExp;
  56572. replace: string;
  56573. }[];
  56574. }, storeKey?: string): void;
  56575. /** @hidden */
  56576. _registerTempVariable(name: string): boolean;
  56577. /** @hidden */
  56578. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56579. /** @hidden */
  56580. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56581. /** @hidden */
  56582. _emitFloat(value: number): string;
  56583. }
  56584. }
  56585. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56586. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56588. import { Nullable } from "babylonjs/types";
  56589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56590. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56591. import { Effect } from "babylonjs/Materials/effect";
  56592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56593. import { Mesh } from "babylonjs/Meshes/mesh";
  56594. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56595. import { Scene } from "babylonjs/scene";
  56596. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56597. /**
  56598. * Defines a block that can be used inside a node based material
  56599. */
  56600. export class NodeMaterialBlock {
  56601. private _buildId;
  56602. private _buildTarget;
  56603. private _target;
  56604. private _isFinalMerger;
  56605. private _isInput;
  56606. protected _isUnique: boolean;
  56607. /** @hidden */
  56608. _codeVariableName: string;
  56609. /** @hidden */
  56610. _inputs: NodeMaterialConnectionPoint[];
  56611. /** @hidden */
  56612. _outputs: NodeMaterialConnectionPoint[];
  56613. /** @hidden */
  56614. _preparationId: number;
  56615. /**
  56616. * Gets or sets the name of the block
  56617. */
  56618. name: string;
  56619. /**
  56620. * Gets or sets the unique id of the node
  56621. */
  56622. uniqueId: number;
  56623. /**
  56624. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56625. */
  56626. readonly isUnique: boolean;
  56627. /**
  56628. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56629. */
  56630. readonly isFinalMerger: boolean;
  56631. /**
  56632. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56633. */
  56634. readonly isInput: boolean;
  56635. /**
  56636. * Gets or sets the build Id
  56637. */
  56638. buildId: number;
  56639. /**
  56640. * Gets or sets the target of the block
  56641. */
  56642. target: NodeMaterialBlockTargets;
  56643. /**
  56644. * Gets the list of input points
  56645. */
  56646. readonly inputs: NodeMaterialConnectionPoint[];
  56647. /** Gets the list of output points */
  56648. readonly outputs: NodeMaterialConnectionPoint[];
  56649. /**
  56650. * Find an input by its name
  56651. * @param name defines the name of the input to look for
  56652. * @returns the input or null if not found
  56653. */
  56654. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56655. /**
  56656. * Find an output by its name
  56657. * @param name defines the name of the outputto look for
  56658. * @returns the output or null if not found
  56659. */
  56660. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56661. /**
  56662. * Creates a new NodeMaterialBlock
  56663. * @param name defines the block name
  56664. * @param target defines the target of that block (Vertex by default)
  56665. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56666. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56667. */
  56668. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56669. /**
  56670. * Initialize the block and prepare the context for build
  56671. * @param state defines the state that will be used for the build
  56672. */
  56673. initialize(state: NodeMaterialBuildState): void;
  56674. /**
  56675. * Bind data to effect. Will only be called for blocks with isBindable === true
  56676. * @param effect defines the effect to bind data to
  56677. * @param nodeMaterial defines the hosting NodeMaterial
  56678. * @param mesh defines the mesh that will be rendered
  56679. */
  56680. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56681. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56682. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56683. protected _writeFloat(value: number): string;
  56684. /**
  56685. * Gets the current class name e.g. "NodeMaterialBlock"
  56686. * @returns the class name
  56687. */
  56688. getClassName(): string;
  56689. /**
  56690. * Register a new input. Must be called inside a block constructor
  56691. * @param name defines the connection point name
  56692. * @param type defines the connection point type
  56693. * @param isOptional defines a boolean indicating that this input can be omitted
  56694. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56695. * @returns the current block
  56696. */
  56697. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56698. /**
  56699. * Register a new output. Must be called inside a block constructor
  56700. * @param name defines the connection point name
  56701. * @param type defines the connection point type
  56702. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56703. * @returns the current block
  56704. */
  56705. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56706. /**
  56707. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56708. * @param forOutput defines an optional connection point to check compatibility with
  56709. * @returns the first available input or null
  56710. */
  56711. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56712. /**
  56713. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56714. * @param forBlock defines an optional block to check compatibility with
  56715. * @returns the first available input or null
  56716. */
  56717. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56718. /**
  56719. * Gets the sibling of the given output
  56720. * @param current defines the current output
  56721. * @returns the next output in the list or null
  56722. */
  56723. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56724. /**
  56725. * Connect current block with another block
  56726. * @param other defines the block to connect with
  56727. * @param options define the various options to help pick the right connections
  56728. * @returns the current block
  56729. */
  56730. connectTo(other: NodeMaterialBlock, options?: {
  56731. input?: string;
  56732. output?: string;
  56733. outputSwizzle?: string;
  56734. }): this | undefined;
  56735. protected _buildBlock(state: NodeMaterialBuildState): void;
  56736. /**
  56737. * Add uniforms, samplers and uniform buffers at compilation time
  56738. * @param state defines the state to update
  56739. * @param nodeMaterial defines the node material requesting the update
  56740. * @param defines defines the material defines to update
  56741. * @param uniformBuffers defines the list of uniform buffer names
  56742. */
  56743. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56744. /**
  56745. * Add potential fallbacks if shader compilation fails
  56746. * @param mesh defines the mesh to be rendered
  56747. * @param fallbacks defines the current prioritized list of fallbacks
  56748. */
  56749. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56750. /**
  56751. * Initialize defines for shader compilation
  56752. * @param mesh defines the mesh to be rendered
  56753. * @param nodeMaterial defines the node material requesting the update
  56754. * @param defines defines the material defines to update
  56755. * @param useInstances specifies that instances should be used
  56756. */
  56757. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56758. /**
  56759. * Update defines for shader compilation
  56760. * @param mesh defines the mesh to be rendered
  56761. * @param nodeMaterial defines the node material requesting the update
  56762. * @param defines defines the material defines to update
  56763. * @param useInstances specifies that instances should be used
  56764. */
  56765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56766. /**
  56767. * Lets the block try to connect some inputs automatically
  56768. * @param material defines the hosting NodeMaterial
  56769. */
  56770. autoConfigure(material: NodeMaterial): void;
  56771. /**
  56772. * Function called when a block is declared as repeatable content generator
  56773. * @param vertexShaderState defines the current compilation state for the vertex shader
  56774. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56775. * @param mesh defines the mesh to be rendered
  56776. * @param defines defines the material defines to update
  56777. */
  56778. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56779. /**
  56780. * Checks if the block is ready
  56781. * @param mesh defines the mesh to be rendered
  56782. * @param nodeMaterial defines the node material requesting the update
  56783. * @param defines defines the material defines to update
  56784. * @param useInstances specifies that instances should be used
  56785. * @returns true if the block is ready
  56786. */
  56787. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56788. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56789. private _processBuild;
  56790. /**
  56791. * Compile the current node and generate the shader code
  56792. * @param state defines the current compilation state (uniforms, samplers, current string)
  56793. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56794. * @returns true if already built
  56795. */
  56796. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56797. protected _inputRename(name: string): string;
  56798. protected _outputRename(name: string): string;
  56799. protected _dumpPropertiesCode(): string;
  56800. /** @hidden */
  56801. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56802. /** @hidden */
  56803. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56804. /**
  56805. * Clone the current block to a new identical block
  56806. * @param scene defines the hosting scene
  56807. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56808. * @returns a copy of the current block
  56809. */
  56810. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56811. /**
  56812. * Serializes this block in a JSON representation
  56813. * @returns the serialized block object
  56814. */
  56815. serialize(): any;
  56816. /** @hidden */
  56817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56818. /**
  56819. * Release resources
  56820. */
  56821. dispose(): void;
  56822. }
  56823. }
  56824. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56825. /**
  56826. * Enum defining the type of animations supported by InputBlock
  56827. */
  56828. export enum AnimatedInputBlockTypes {
  56829. /** No animation */
  56830. None = 0,
  56831. /** Time based animation. Will only work for floats */
  56832. Time = 1
  56833. }
  56834. }
  56835. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56837. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56838. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56839. import { Nullable } from "babylonjs/types";
  56840. import { Effect } from "babylonjs/Materials/effect";
  56841. import { Matrix } from "babylonjs/Maths/math.vector";
  56842. import { Scene } from "babylonjs/scene";
  56843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56845. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56846. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56847. /**
  56848. * Block used to expose an input value
  56849. */
  56850. export class InputBlock extends NodeMaterialBlock {
  56851. private _mode;
  56852. private _associatedVariableName;
  56853. private _storedValue;
  56854. private _valueCallback;
  56855. private _type;
  56856. private _animationType;
  56857. /** Gets or set a value used to limit the range of float values */
  56858. min: number;
  56859. /** Gets or set a value used to limit the range of float values */
  56860. max: number;
  56861. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56862. matrixMode: number;
  56863. /** @hidden */
  56864. _systemValue: Nullable<NodeMaterialSystemValues>;
  56865. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56866. visibleInInspector: boolean;
  56867. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56868. isConstant: boolean;
  56869. /**
  56870. * Gets or sets the connection point type (default is float)
  56871. */
  56872. readonly type: NodeMaterialBlockConnectionPointTypes;
  56873. /**
  56874. * Creates a new InputBlock
  56875. * @param name defines the block name
  56876. * @param target defines the target of that block (Vertex by default)
  56877. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56878. */
  56879. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56880. /**
  56881. * Gets the output component
  56882. */
  56883. readonly output: NodeMaterialConnectionPoint;
  56884. /**
  56885. * Set the source of this connection point to a vertex attribute
  56886. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56887. * @returns the current connection point
  56888. */
  56889. setAsAttribute(attributeName?: string): InputBlock;
  56890. /**
  56891. * Set the source of this connection point to a system value
  56892. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56893. * @returns the current connection point
  56894. */
  56895. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56896. /**
  56897. * Gets or sets the value of that point.
  56898. * Please note that this value will be ignored if valueCallback is defined
  56899. */
  56900. value: any;
  56901. /**
  56902. * Gets or sets a callback used to get the value of that point.
  56903. * Please note that setting this value will force the connection point to ignore the value property
  56904. */
  56905. valueCallback: () => any;
  56906. /**
  56907. * Gets or sets the associated variable name in the shader
  56908. */
  56909. associatedVariableName: string;
  56910. /** Gets or sets the type of animation applied to the input */
  56911. animationType: AnimatedInputBlockTypes;
  56912. /**
  56913. * Gets a boolean indicating that this connection point not defined yet
  56914. */
  56915. readonly isUndefined: boolean;
  56916. /**
  56917. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56918. * In this case the connection point name must be the name of the uniform to use.
  56919. * Can only be set on inputs
  56920. */
  56921. isUniform: boolean;
  56922. /**
  56923. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56924. * In this case the connection point name must be the name of the attribute to use
  56925. * Can only be set on inputs
  56926. */
  56927. isAttribute: boolean;
  56928. /**
  56929. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56930. * Can only be set on exit points
  56931. */
  56932. isVarying: boolean;
  56933. /**
  56934. * Gets a boolean indicating that the current connection point is a system value
  56935. */
  56936. readonly isSystemValue: boolean;
  56937. /**
  56938. * Gets or sets the current well known value or null if not defined as a system value
  56939. */
  56940. systemValue: Nullable<NodeMaterialSystemValues>;
  56941. /**
  56942. * Gets the current class name
  56943. * @returns the class name
  56944. */
  56945. getClassName(): string;
  56946. /**
  56947. * Animate the input if animationType !== None
  56948. * @param scene defines the rendering scene
  56949. */
  56950. animate(scene: Scene): void;
  56951. private _emitDefine;
  56952. initialize(state: NodeMaterialBuildState): void;
  56953. /**
  56954. * Set the input block to its default value (based on its type)
  56955. */
  56956. setDefaultValue(): void;
  56957. private _emitConstant;
  56958. private _emit;
  56959. /** @hidden */
  56960. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56961. /** @hidden */
  56962. _transmit(effect: Effect, scene: Scene): void;
  56963. protected _buildBlock(state: NodeMaterialBuildState): void;
  56964. protected _dumpPropertiesCode(): string;
  56965. serialize(): any;
  56966. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56967. }
  56968. }
  56969. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56970. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56971. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56972. import { Nullable } from "babylonjs/types";
  56973. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56974. import { Observable } from "babylonjs/Misc/observable";
  56975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56976. /**
  56977. * Enum used to define the compatibility state between two connection points
  56978. */
  56979. export enum NodeMaterialConnectionPointCompatibilityStates {
  56980. /** Points are compatibles */
  56981. Compatible = 0,
  56982. /** Points are incompatible because of their types */
  56983. TypeIncompatible = 1,
  56984. /** Points are incompatible because of their targets (vertex vs fragment) */
  56985. TargetIncompatible = 2
  56986. }
  56987. /**
  56988. * Defines a connection point for a block
  56989. */
  56990. export class NodeMaterialConnectionPoint {
  56991. /** @hidden */
  56992. _ownerBlock: NodeMaterialBlock;
  56993. /** @hidden */
  56994. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56995. private _endpoints;
  56996. private _associatedVariableName;
  56997. /** @hidden */
  56998. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56999. /** @hidden */
  57000. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57001. private _type;
  57002. /** @hidden */
  57003. _enforceAssociatedVariableName: boolean;
  57004. /**
  57005. * Gets or sets the additional types supported by this connection point
  57006. */
  57007. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57008. /**
  57009. * Gets or sets the additional types excluded by this connection point
  57010. */
  57011. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57012. /**
  57013. * Observable triggered when this point is connected
  57014. */
  57015. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57016. /**
  57017. * Gets or sets the associated variable name in the shader
  57018. */
  57019. associatedVariableName: string;
  57020. /**
  57021. * Gets or sets the connection point type (default is float)
  57022. */
  57023. type: NodeMaterialBlockConnectionPointTypes;
  57024. /**
  57025. * Gets or sets the connection point name
  57026. */
  57027. name: string;
  57028. /**
  57029. * Gets or sets a boolean indicating that this connection point can be omitted
  57030. */
  57031. isOptional: boolean;
  57032. /**
  57033. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57034. */
  57035. define: string;
  57036. /** @hidden */
  57037. _prioritizeVertex: boolean;
  57038. private _target;
  57039. /** Gets or sets the target of that connection point */
  57040. target: NodeMaterialBlockTargets;
  57041. /**
  57042. * Gets a boolean indicating that the current point is connected
  57043. */
  57044. readonly isConnected: boolean;
  57045. /**
  57046. * Gets a boolean indicating that the current point is connected to an input block
  57047. */
  57048. readonly isConnectedToInputBlock: boolean;
  57049. /**
  57050. * Gets a the connected input block (if any)
  57051. */
  57052. readonly connectInputBlock: Nullable<InputBlock>;
  57053. /** Get the other side of the connection (if any) */
  57054. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57055. /** Get the block that owns this connection point */
  57056. readonly ownerBlock: NodeMaterialBlock;
  57057. /** Get the block connected on the other side of this connection (if any) */
  57058. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57059. /** Get the block connected on the endpoints of this connection (if any) */
  57060. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57061. /** Gets the list of connected endpoints */
  57062. readonly endpoints: NodeMaterialConnectionPoint[];
  57063. /** Gets a boolean indicating if that output point is connected to at least one input */
  57064. readonly hasEndpoints: boolean;
  57065. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57066. readonly isConnectedInVertexShader: boolean;
  57067. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57068. readonly isConnectedInFragmentShader: boolean;
  57069. /**
  57070. * Creates a new connection point
  57071. * @param name defines the connection point name
  57072. * @param ownerBlock defines the block hosting this connection point
  57073. */
  57074. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57075. /**
  57076. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57077. * @returns the class name
  57078. */
  57079. getClassName(): string;
  57080. /**
  57081. * Gets a boolean indicating if the current point can be connected to another point
  57082. * @param connectionPoint defines the other connection point
  57083. * @returns a boolean
  57084. */
  57085. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57086. /**
  57087. * Gets a number indicating if the current point can be connected to another point
  57088. * @param connectionPoint defines the other connection point
  57089. * @returns a number defining the compatibility state
  57090. */
  57091. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57092. /**
  57093. * Connect this point to another connection point
  57094. * @param connectionPoint defines the other connection point
  57095. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57096. * @returns the current connection point
  57097. */
  57098. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57099. /**
  57100. * Disconnect this point from one of his endpoint
  57101. * @param endpoint defines the other connection point
  57102. * @returns the current connection point
  57103. */
  57104. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57105. /**
  57106. * Serializes this point in a JSON representation
  57107. * @returns the serialized point object
  57108. */
  57109. serialize(): any;
  57110. /**
  57111. * Release resources
  57112. */
  57113. dispose(): void;
  57114. }
  57115. }
  57116. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57120. import { Mesh } from "babylonjs/Meshes/mesh";
  57121. import { Effect } from "babylonjs/Materials/effect";
  57122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57123. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57124. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57125. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57126. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57127. /**
  57128. * Block used to add support for vertex skinning (bones)
  57129. */
  57130. export class BonesBlock extends NodeMaterialBlock {
  57131. /**
  57132. * Creates a new BonesBlock
  57133. * @param name defines the block name
  57134. */
  57135. constructor(name: string);
  57136. /**
  57137. * Initialize the block and prepare the context for build
  57138. * @param state defines the state that will be used for the build
  57139. */
  57140. initialize(state: NodeMaterialBuildState): void;
  57141. /**
  57142. * Gets the current class name
  57143. * @returns the class name
  57144. */
  57145. getClassName(): string;
  57146. /**
  57147. * Gets the matrix indices input component
  57148. */
  57149. readonly matricesIndices: NodeMaterialConnectionPoint;
  57150. /**
  57151. * Gets the matrix weights input component
  57152. */
  57153. readonly matricesWeights: NodeMaterialConnectionPoint;
  57154. /**
  57155. * Gets the extra matrix indices input component
  57156. */
  57157. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57158. /**
  57159. * Gets the extra matrix weights input component
  57160. */
  57161. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57162. /**
  57163. * Gets the world input component
  57164. */
  57165. readonly world: NodeMaterialConnectionPoint;
  57166. /**
  57167. * Gets the output component
  57168. */
  57169. readonly output: NodeMaterialConnectionPoint;
  57170. autoConfigure(material: NodeMaterial): void;
  57171. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57172. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57173. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57174. protected _buildBlock(state: NodeMaterialBuildState): this;
  57175. }
  57176. }
  57177. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57182. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57183. /**
  57184. * Block used to add support for instances
  57185. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57186. */
  57187. export class InstancesBlock extends NodeMaterialBlock {
  57188. /**
  57189. * Creates a new InstancesBlock
  57190. * @param name defines the block name
  57191. */
  57192. constructor(name: string);
  57193. /**
  57194. * Gets the current class name
  57195. * @returns the class name
  57196. */
  57197. getClassName(): string;
  57198. /**
  57199. * Gets the first world row input component
  57200. */
  57201. readonly world0: NodeMaterialConnectionPoint;
  57202. /**
  57203. * Gets the second world row input component
  57204. */
  57205. readonly world1: NodeMaterialConnectionPoint;
  57206. /**
  57207. * Gets the third world row input component
  57208. */
  57209. readonly world2: NodeMaterialConnectionPoint;
  57210. /**
  57211. * Gets the forth world row input component
  57212. */
  57213. readonly world3: NodeMaterialConnectionPoint;
  57214. /**
  57215. * Gets the world input component
  57216. */
  57217. readonly world: NodeMaterialConnectionPoint;
  57218. /**
  57219. * Gets the output component
  57220. */
  57221. readonly output: NodeMaterialConnectionPoint;
  57222. autoConfigure(material: NodeMaterial): void;
  57223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57224. protected _buildBlock(state: NodeMaterialBuildState): this;
  57225. }
  57226. }
  57227. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57232. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57233. import { Effect } from "babylonjs/Materials/effect";
  57234. import { Mesh } from "babylonjs/Meshes/mesh";
  57235. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57236. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57237. /**
  57238. * Block used to add morph targets support to vertex shader
  57239. */
  57240. export class MorphTargetsBlock extends NodeMaterialBlock {
  57241. private _repeatableContentAnchor;
  57242. private _repeatebleContentGenerated;
  57243. /**
  57244. * Create a new MorphTargetsBlock
  57245. * @param name defines the block name
  57246. */
  57247. constructor(name: string);
  57248. /**
  57249. * Gets the current class name
  57250. * @returns the class name
  57251. */
  57252. getClassName(): string;
  57253. /**
  57254. * Gets the position input component
  57255. */
  57256. readonly position: NodeMaterialConnectionPoint;
  57257. /**
  57258. * Gets the normal input component
  57259. */
  57260. readonly normal: NodeMaterialConnectionPoint;
  57261. /**
  57262. * Gets the tangent input component
  57263. */
  57264. readonly tangent: NodeMaterialConnectionPoint;
  57265. /**
  57266. * Gets the tangent input component
  57267. */
  57268. readonly uv: NodeMaterialConnectionPoint;
  57269. /**
  57270. * Gets the position output component
  57271. */
  57272. readonly positionOutput: NodeMaterialConnectionPoint;
  57273. /**
  57274. * Gets the normal output component
  57275. */
  57276. readonly normalOutput: NodeMaterialConnectionPoint;
  57277. /**
  57278. * Gets the tangent output component
  57279. */
  57280. readonly tangentOutput: NodeMaterialConnectionPoint;
  57281. /**
  57282. * Gets the tangent output component
  57283. */
  57284. readonly uvOutput: NodeMaterialConnectionPoint;
  57285. initialize(state: NodeMaterialBuildState): void;
  57286. autoConfigure(material: NodeMaterial): void;
  57287. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57288. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57289. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57290. protected _buildBlock(state: NodeMaterialBuildState): this;
  57291. }
  57292. }
  57293. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57297. import { Nullable } from "babylonjs/types";
  57298. import { Scene } from "babylonjs/scene";
  57299. import { Effect } from "babylonjs/Materials/effect";
  57300. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57301. import { Mesh } from "babylonjs/Meshes/mesh";
  57302. import { Light } from "babylonjs/Lights/light";
  57303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57304. /**
  57305. * Block used to get data information from a light
  57306. */
  57307. export class LightInformationBlock extends NodeMaterialBlock {
  57308. private _lightDataUniformName;
  57309. private _lightColorUniformName;
  57310. private _lightTypeDefineName;
  57311. /**
  57312. * Gets or sets the light associated with this block
  57313. */
  57314. light: Nullable<Light>;
  57315. /**
  57316. * Creates a new LightInformationBlock
  57317. * @param name defines the block name
  57318. */
  57319. constructor(name: string);
  57320. /**
  57321. * Gets the current class name
  57322. * @returns the class name
  57323. */
  57324. getClassName(): string;
  57325. /**
  57326. * Gets the world position input component
  57327. */
  57328. readonly worldPosition: NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the direction output component
  57331. */
  57332. readonly direction: NodeMaterialConnectionPoint;
  57333. /**
  57334. * Gets the direction output component
  57335. */
  57336. readonly color: NodeMaterialConnectionPoint;
  57337. /**
  57338. * Gets the direction output component
  57339. */
  57340. readonly intensity: NodeMaterialConnectionPoint;
  57341. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57343. protected _buildBlock(state: NodeMaterialBuildState): this;
  57344. serialize(): any;
  57345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57346. }
  57347. }
  57348. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57349. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57350. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57351. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57352. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57353. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57354. }
  57355. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57360. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57361. import { Effect } from "babylonjs/Materials/effect";
  57362. import { Mesh } from "babylonjs/Meshes/mesh";
  57363. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57364. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57365. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57366. /**
  57367. * Block used to add image processing support to fragment shader
  57368. */
  57369. export class ImageProcessingBlock extends NodeMaterialBlock {
  57370. /**
  57371. * Create a new ImageProcessingBlock
  57372. * @param name defines the block name
  57373. */
  57374. constructor(name: string);
  57375. /**
  57376. * Gets the current class name
  57377. * @returns the class name
  57378. */
  57379. getClassName(): string;
  57380. /**
  57381. * Gets the color input component
  57382. */
  57383. readonly color: NodeMaterialConnectionPoint;
  57384. /**
  57385. * Gets the output component
  57386. */
  57387. readonly output: NodeMaterialConnectionPoint;
  57388. /**
  57389. * Initialize the block and prepare the context for build
  57390. * @param state defines the state that will be used for the build
  57391. */
  57392. initialize(state: NodeMaterialBuildState): void;
  57393. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57394. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57395. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57396. protected _buildBlock(state: NodeMaterialBuildState): this;
  57397. }
  57398. }
  57399. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57403. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57405. import { Effect } from "babylonjs/Materials/effect";
  57406. import { Mesh } from "babylonjs/Meshes/mesh";
  57407. import { Scene } from "babylonjs/scene";
  57408. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57409. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57410. /**
  57411. * Block used to pertub normals based on a normal map
  57412. */
  57413. export class PerturbNormalBlock extends NodeMaterialBlock {
  57414. private _tangentSpaceParameterName;
  57415. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57416. invertX: boolean;
  57417. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57418. invertY: boolean;
  57419. /**
  57420. * Create a new PerturbNormalBlock
  57421. * @param name defines the block name
  57422. */
  57423. constructor(name: string);
  57424. /**
  57425. * Gets the current class name
  57426. * @returns the class name
  57427. */
  57428. getClassName(): string;
  57429. /**
  57430. * Gets the world position input component
  57431. */
  57432. readonly worldPosition: NodeMaterialConnectionPoint;
  57433. /**
  57434. * Gets the world normal input component
  57435. */
  57436. readonly worldNormal: NodeMaterialConnectionPoint;
  57437. /**
  57438. * Gets the uv input component
  57439. */
  57440. readonly uv: NodeMaterialConnectionPoint;
  57441. /**
  57442. * Gets the normal map color input component
  57443. */
  57444. readonly normalMapColor: NodeMaterialConnectionPoint;
  57445. /**
  57446. * Gets the strength input component
  57447. */
  57448. readonly strength: NodeMaterialConnectionPoint;
  57449. /**
  57450. * Gets the output component
  57451. */
  57452. readonly output: NodeMaterialConnectionPoint;
  57453. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57454. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57455. autoConfigure(material: NodeMaterial): void;
  57456. protected _buildBlock(state: NodeMaterialBuildState): this;
  57457. protected _dumpPropertiesCode(): string;
  57458. serialize(): any;
  57459. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57460. }
  57461. }
  57462. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57466. /**
  57467. * Block used to discard a pixel if a value is smaller than a cutoff
  57468. */
  57469. export class DiscardBlock extends NodeMaterialBlock {
  57470. /**
  57471. * Create a new DiscardBlock
  57472. * @param name defines the block name
  57473. */
  57474. constructor(name: string);
  57475. /**
  57476. * Gets the current class name
  57477. * @returns the class name
  57478. */
  57479. getClassName(): string;
  57480. /**
  57481. * Gets the color input component
  57482. */
  57483. readonly value: NodeMaterialConnectionPoint;
  57484. /**
  57485. * Gets the cutoff input component
  57486. */
  57487. readonly cutoff: NodeMaterialConnectionPoint;
  57488. protected _buildBlock(state: NodeMaterialBuildState): this;
  57489. }
  57490. }
  57491. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57495. /**
  57496. * Block used to test if the fragment shader is front facing
  57497. */
  57498. export class FrontFacingBlock extends NodeMaterialBlock {
  57499. /**
  57500. * Creates a new FrontFacingBlock
  57501. * @param name defines the block name
  57502. */
  57503. constructor(name: string);
  57504. /**
  57505. * Gets the current class name
  57506. * @returns the class name
  57507. */
  57508. getClassName(): string;
  57509. /**
  57510. * Gets the output component
  57511. */
  57512. readonly output: NodeMaterialConnectionPoint;
  57513. protected _buildBlock(state: NodeMaterialBuildState): this;
  57514. }
  57515. }
  57516. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57517. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57518. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57519. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57520. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57521. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57522. }
  57523. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57526. import { Mesh } from "babylonjs/Meshes/mesh";
  57527. import { Effect } from "babylonjs/Materials/effect";
  57528. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57530. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57531. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57532. /**
  57533. * Block used to add support for scene fog
  57534. */
  57535. export class FogBlock extends NodeMaterialBlock {
  57536. private _fogDistanceName;
  57537. private _fogParameters;
  57538. /**
  57539. * Create a new FogBlock
  57540. * @param name defines the block name
  57541. */
  57542. constructor(name: string);
  57543. /**
  57544. * Gets the current class name
  57545. * @returns the class name
  57546. */
  57547. getClassName(): string;
  57548. /**
  57549. * Gets the world position input component
  57550. */
  57551. readonly worldPosition: NodeMaterialConnectionPoint;
  57552. /**
  57553. * Gets the view input component
  57554. */
  57555. readonly view: NodeMaterialConnectionPoint;
  57556. /**
  57557. * Gets the color input component
  57558. */
  57559. readonly input: NodeMaterialConnectionPoint;
  57560. /**
  57561. * Gets the fog color input component
  57562. */
  57563. readonly fogColor: NodeMaterialConnectionPoint;
  57564. /**
  57565. * Gets the output component
  57566. */
  57567. readonly output: NodeMaterialConnectionPoint;
  57568. autoConfigure(material: NodeMaterial): void;
  57569. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57570. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57571. protected _buildBlock(state: NodeMaterialBuildState): this;
  57572. }
  57573. }
  57574. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57579. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57580. import { Effect } from "babylonjs/Materials/effect";
  57581. import { Mesh } from "babylonjs/Meshes/mesh";
  57582. import { Light } from "babylonjs/Lights/light";
  57583. import { Nullable } from "babylonjs/types";
  57584. import { Scene } from "babylonjs/scene";
  57585. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57586. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57587. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57588. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57589. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57590. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57591. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57592. /**
  57593. * Block used to add light in the fragment shader
  57594. */
  57595. export class LightBlock extends NodeMaterialBlock {
  57596. private _lightId;
  57597. /**
  57598. * Gets or sets the light associated with this block
  57599. */
  57600. light: Nullable<Light>;
  57601. /**
  57602. * Create a new LightBlock
  57603. * @param name defines the block name
  57604. */
  57605. constructor(name: string);
  57606. /**
  57607. * Gets the current class name
  57608. * @returns the class name
  57609. */
  57610. getClassName(): string;
  57611. /**
  57612. * Gets the world position input component
  57613. */
  57614. readonly worldPosition: NodeMaterialConnectionPoint;
  57615. /**
  57616. * Gets the world normal input component
  57617. */
  57618. readonly worldNormal: NodeMaterialConnectionPoint;
  57619. /**
  57620. * Gets the camera (or eye) position component
  57621. */
  57622. readonly cameraPosition: NodeMaterialConnectionPoint;
  57623. /**
  57624. * Gets the glossiness component
  57625. */
  57626. readonly glossiness: NodeMaterialConnectionPoint;
  57627. /**
  57628. * Gets the glossinness power component
  57629. */
  57630. readonly glossPower: NodeMaterialConnectionPoint;
  57631. /**
  57632. * Gets the diffuse color component
  57633. */
  57634. readonly diffuseColor: NodeMaterialConnectionPoint;
  57635. /**
  57636. * Gets the specular color component
  57637. */
  57638. readonly specularColor: NodeMaterialConnectionPoint;
  57639. /**
  57640. * Gets the diffuse output component
  57641. */
  57642. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57643. /**
  57644. * Gets the specular output component
  57645. */
  57646. readonly specularOutput: NodeMaterialConnectionPoint;
  57647. autoConfigure(material: NodeMaterial): void;
  57648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57649. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57650. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57651. private _injectVertexCode;
  57652. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57653. serialize(): any;
  57654. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57655. }
  57656. }
  57657. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57658. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57659. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57660. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57661. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57662. }
  57663. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57664. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57665. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57666. }
  57667. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57671. /**
  57672. * Block used to multiply 2 values
  57673. */
  57674. export class MultiplyBlock extends NodeMaterialBlock {
  57675. /**
  57676. * Creates a new MultiplyBlock
  57677. * @param name defines the block name
  57678. */
  57679. constructor(name: string);
  57680. /**
  57681. * Gets the current class name
  57682. * @returns the class name
  57683. */
  57684. getClassName(): string;
  57685. /**
  57686. * Gets the left operand input component
  57687. */
  57688. readonly left: NodeMaterialConnectionPoint;
  57689. /**
  57690. * Gets the right operand input component
  57691. */
  57692. readonly right: NodeMaterialConnectionPoint;
  57693. /**
  57694. * Gets the output component
  57695. */
  57696. readonly output: NodeMaterialConnectionPoint;
  57697. protected _buildBlock(state: NodeMaterialBuildState): this;
  57698. }
  57699. }
  57700. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57704. /**
  57705. * Block used to add 2 vectors
  57706. */
  57707. export class AddBlock extends NodeMaterialBlock {
  57708. /**
  57709. * Creates a new AddBlock
  57710. * @param name defines the block name
  57711. */
  57712. constructor(name: string);
  57713. /**
  57714. * Gets the current class name
  57715. * @returns the class name
  57716. */
  57717. getClassName(): string;
  57718. /**
  57719. * Gets the left operand input component
  57720. */
  57721. readonly left: NodeMaterialConnectionPoint;
  57722. /**
  57723. * Gets the right operand input component
  57724. */
  57725. readonly right: NodeMaterialConnectionPoint;
  57726. /**
  57727. * Gets the output component
  57728. */
  57729. readonly output: NodeMaterialConnectionPoint;
  57730. protected _buildBlock(state: NodeMaterialBuildState): this;
  57731. }
  57732. }
  57733. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57737. /**
  57738. * Block used to scale a vector by a float
  57739. */
  57740. export class ScaleBlock extends NodeMaterialBlock {
  57741. /**
  57742. * Creates a new ScaleBlock
  57743. * @param name defines the block name
  57744. */
  57745. constructor(name: string);
  57746. /**
  57747. * Gets the current class name
  57748. * @returns the class name
  57749. */
  57750. getClassName(): string;
  57751. /**
  57752. * Gets the input component
  57753. */
  57754. readonly input: NodeMaterialConnectionPoint;
  57755. /**
  57756. * Gets the factor input component
  57757. */
  57758. readonly factor: NodeMaterialConnectionPoint;
  57759. /**
  57760. * Gets the output component
  57761. */
  57762. readonly output: NodeMaterialConnectionPoint;
  57763. protected _buildBlock(state: NodeMaterialBuildState): this;
  57764. }
  57765. }
  57766. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57770. import { Scene } from "babylonjs/scene";
  57771. /**
  57772. * Block used to clamp a float
  57773. */
  57774. export class ClampBlock extends NodeMaterialBlock {
  57775. /** Gets or sets the minimum range */
  57776. minimum: number;
  57777. /** Gets or sets the maximum range */
  57778. maximum: number;
  57779. /**
  57780. * Creates a new ClampBlock
  57781. * @param name defines the block name
  57782. */
  57783. constructor(name: string);
  57784. /**
  57785. * Gets the current class name
  57786. * @returns the class name
  57787. */
  57788. getClassName(): string;
  57789. /**
  57790. * Gets the value input component
  57791. */
  57792. readonly value: NodeMaterialConnectionPoint;
  57793. /**
  57794. * Gets the output component
  57795. */
  57796. readonly output: NodeMaterialConnectionPoint;
  57797. protected _buildBlock(state: NodeMaterialBuildState): this;
  57798. protected _dumpPropertiesCode(): string;
  57799. serialize(): any;
  57800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57801. }
  57802. }
  57803. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57807. /**
  57808. * Block used to apply a cross product between 2 vectors
  57809. */
  57810. export class CrossBlock extends NodeMaterialBlock {
  57811. /**
  57812. * Creates a new CrossBlock
  57813. * @param name defines the block name
  57814. */
  57815. constructor(name: string);
  57816. /**
  57817. * Gets the current class name
  57818. * @returns the class name
  57819. */
  57820. getClassName(): string;
  57821. /**
  57822. * Gets the left operand input component
  57823. */
  57824. readonly left: NodeMaterialConnectionPoint;
  57825. /**
  57826. * Gets the right operand input component
  57827. */
  57828. readonly right: NodeMaterialConnectionPoint;
  57829. /**
  57830. * Gets the output component
  57831. */
  57832. readonly output: NodeMaterialConnectionPoint;
  57833. protected _buildBlock(state: NodeMaterialBuildState): this;
  57834. }
  57835. }
  57836. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57840. /**
  57841. * Block used to apply a dot product between 2 vectors
  57842. */
  57843. export class DotBlock extends NodeMaterialBlock {
  57844. /**
  57845. * Creates a new DotBlock
  57846. * @param name defines the block name
  57847. */
  57848. constructor(name: string);
  57849. /**
  57850. * Gets the current class name
  57851. * @returns the class name
  57852. */
  57853. getClassName(): string;
  57854. /**
  57855. * Gets the left operand input component
  57856. */
  57857. readonly left: NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the right operand input component
  57860. */
  57861. readonly right: NodeMaterialConnectionPoint;
  57862. /**
  57863. * Gets the output component
  57864. */
  57865. readonly output: NodeMaterialConnectionPoint;
  57866. protected _buildBlock(state: NodeMaterialBuildState): this;
  57867. }
  57868. }
  57869. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57873. import { Vector2 } from "babylonjs/Maths/math.vector";
  57874. import { Scene } from "babylonjs/scene";
  57875. /**
  57876. * Block used to remap a float from a range to a new one
  57877. */
  57878. export class RemapBlock extends NodeMaterialBlock {
  57879. /**
  57880. * Gets or sets the source range
  57881. */
  57882. sourceRange: Vector2;
  57883. /**
  57884. * Gets or sets the target range
  57885. */
  57886. targetRange: Vector2;
  57887. /**
  57888. * Creates a new RemapBlock
  57889. * @param name defines the block name
  57890. */
  57891. constructor(name: string);
  57892. /**
  57893. * Gets the current class name
  57894. * @returns the class name
  57895. */
  57896. getClassName(): string;
  57897. /**
  57898. * Gets the input component
  57899. */
  57900. readonly input: NodeMaterialConnectionPoint;
  57901. /**
  57902. * Gets the source min input component
  57903. */
  57904. readonly sourceMin: NodeMaterialConnectionPoint;
  57905. /**
  57906. * Gets the source max input component
  57907. */
  57908. readonly sourceMax: NodeMaterialConnectionPoint;
  57909. /**
  57910. * Gets the target min input component
  57911. */
  57912. readonly targetMin: NodeMaterialConnectionPoint;
  57913. /**
  57914. * Gets the target max input component
  57915. */
  57916. readonly targetMax: NodeMaterialConnectionPoint;
  57917. /**
  57918. * Gets the output component
  57919. */
  57920. readonly output: NodeMaterialConnectionPoint;
  57921. protected _buildBlock(state: NodeMaterialBuildState): this;
  57922. protected _dumpPropertiesCode(): string;
  57923. serialize(): any;
  57924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57925. }
  57926. }
  57927. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57931. /**
  57932. * Block used to normalize a vector
  57933. */
  57934. export class NormalizeBlock extends NodeMaterialBlock {
  57935. /**
  57936. * Creates a new NormalizeBlock
  57937. * @param name defines the block name
  57938. */
  57939. constructor(name: string);
  57940. /**
  57941. * Gets the current class name
  57942. * @returns the class name
  57943. */
  57944. getClassName(): string;
  57945. /**
  57946. * Gets the input component
  57947. */
  57948. readonly input: NodeMaterialConnectionPoint;
  57949. /**
  57950. * Gets the output component
  57951. */
  57952. readonly output: NodeMaterialConnectionPoint;
  57953. protected _buildBlock(state: NodeMaterialBuildState): this;
  57954. }
  57955. }
  57956. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57960. import { Scene } from "babylonjs/scene";
  57961. /**
  57962. * Operations supported by the Trigonometry block
  57963. */
  57964. export enum TrigonometryBlockOperations {
  57965. /** Cos */
  57966. Cos = 0,
  57967. /** Sin */
  57968. Sin = 1,
  57969. /** Abs */
  57970. Abs = 2,
  57971. /** Exp */
  57972. Exp = 3,
  57973. /** Exp2 */
  57974. Exp2 = 4,
  57975. /** Round */
  57976. Round = 5,
  57977. /** Floor */
  57978. Floor = 6,
  57979. /** Ceiling */
  57980. Ceiling = 7,
  57981. /** Square root */
  57982. Sqrt = 8,
  57983. /** Log */
  57984. Log = 9,
  57985. /** Tangent */
  57986. Tan = 10,
  57987. /** Arc tangent */
  57988. ArcTan = 11,
  57989. /** Arc cosinus */
  57990. ArcCos = 12,
  57991. /** Arc sinus */
  57992. ArcSin = 13,
  57993. /** Fraction */
  57994. Fract = 14,
  57995. /** Sign */
  57996. Sign = 15,
  57997. /** To radians (from degrees) */
  57998. Radians = 16,
  57999. /** To degrees (from radians) */
  58000. Degrees = 17
  58001. }
  58002. /**
  58003. * Block used to apply trigonometry operation to floats
  58004. */
  58005. export class TrigonometryBlock extends NodeMaterialBlock {
  58006. /**
  58007. * Gets or sets the operation applied by the block
  58008. */
  58009. operation: TrigonometryBlockOperations;
  58010. /**
  58011. * Creates a new TrigonometryBlock
  58012. * @param name defines the block name
  58013. */
  58014. constructor(name: string);
  58015. /**
  58016. * Gets the current class name
  58017. * @returns the class name
  58018. */
  58019. getClassName(): string;
  58020. /**
  58021. * Gets the input component
  58022. */
  58023. readonly input: NodeMaterialConnectionPoint;
  58024. /**
  58025. * Gets the output component
  58026. */
  58027. readonly output: NodeMaterialConnectionPoint;
  58028. protected _buildBlock(state: NodeMaterialBuildState): this;
  58029. serialize(): any;
  58030. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58031. }
  58032. }
  58033. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58037. /**
  58038. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58039. */
  58040. export class ColorMergerBlock extends NodeMaterialBlock {
  58041. /**
  58042. * Create a new ColorMergerBlock
  58043. * @param name defines the block name
  58044. */
  58045. constructor(name: string);
  58046. /**
  58047. * Gets the current class name
  58048. * @returns the class name
  58049. */
  58050. getClassName(): string;
  58051. /**
  58052. * Gets the r component (input)
  58053. */
  58054. readonly r: NodeMaterialConnectionPoint;
  58055. /**
  58056. * Gets the g component (input)
  58057. */
  58058. readonly g: NodeMaterialConnectionPoint;
  58059. /**
  58060. * Gets the b component (input)
  58061. */
  58062. readonly b: NodeMaterialConnectionPoint;
  58063. /**
  58064. * Gets the a component (input)
  58065. */
  58066. readonly a: NodeMaterialConnectionPoint;
  58067. /**
  58068. * Gets the rgba component (output)
  58069. */
  58070. readonly rgba: NodeMaterialConnectionPoint;
  58071. /**
  58072. * Gets the rgb component (output)
  58073. */
  58074. readonly rgb: NodeMaterialConnectionPoint;
  58075. protected _buildBlock(state: NodeMaterialBuildState): this;
  58076. }
  58077. }
  58078. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58080. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58081. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58082. /**
  58083. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58084. */
  58085. export class VectorMergerBlock extends NodeMaterialBlock {
  58086. /**
  58087. * Create a new VectorMergerBlock
  58088. * @param name defines the block name
  58089. */
  58090. constructor(name: string);
  58091. /**
  58092. * Gets the current class name
  58093. * @returns the class name
  58094. */
  58095. getClassName(): string;
  58096. /**
  58097. * Gets the x component (input)
  58098. */
  58099. readonly x: NodeMaterialConnectionPoint;
  58100. /**
  58101. * Gets the y component (input)
  58102. */
  58103. readonly y: NodeMaterialConnectionPoint;
  58104. /**
  58105. * Gets the z component (input)
  58106. */
  58107. readonly z: NodeMaterialConnectionPoint;
  58108. /**
  58109. * Gets the w component (input)
  58110. */
  58111. readonly w: NodeMaterialConnectionPoint;
  58112. /**
  58113. * Gets the xyzw component (output)
  58114. */
  58115. readonly xyzw: NodeMaterialConnectionPoint;
  58116. /**
  58117. * Gets the xyz component (output)
  58118. */
  58119. readonly xyz: NodeMaterialConnectionPoint;
  58120. /**
  58121. * Gets the xy component (output)
  58122. */
  58123. readonly xy: NodeMaterialConnectionPoint;
  58124. protected _buildBlock(state: NodeMaterialBuildState): this;
  58125. }
  58126. }
  58127. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58131. /**
  58132. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58133. */
  58134. export class ColorSplitterBlock extends NodeMaterialBlock {
  58135. /**
  58136. * Create a new ColorSplitterBlock
  58137. * @param name defines the block name
  58138. */
  58139. constructor(name: string);
  58140. /**
  58141. * Gets the current class name
  58142. * @returns the class name
  58143. */
  58144. getClassName(): string;
  58145. /**
  58146. * Gets the rgba component (input)
  58147. */
  58148. readonly rgba: NodeMaterialConnectionPoint;
  58149. /**
  58150. * Gets the rgb component (input)
  58151. */
  58152. readonly rgbIn: NodeMaterialConnectionPoint;
  58153. /**
  58154. * Gets the rgb component (output)
  58155. */
  58156. readonly rgbOut: NodeMaterialConnectionPoint;
  58157. /**
  58158. * Gets the r component (output)
  58159. */
  58160. readonly r: NodeMaterialConnectionPoint;
  58161. /**
  58162. * Gets the g component (output)
  58163. */
  58164. readonly g: NodeMaterialConnectionPoint;
  58165. /**
  58166. * Gets the b component (output)
  58167. */
  58168. readonly b: NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the a component (output)
  58171. */
  58172. readonly a: NodeMaterialConnectionPoint;
  58173. protected _inputRename(name: string): string;
  58174. protected _outputRename(name: string): string;
  58175. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58176. }
  58177. }
  58178. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58182. /**
  58183. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58184. */
  58185. export class VectorSplitterBlock extends NodeMaterialBlock {
  58186. /**
  58187. * Create a new VectorSplitterBlock
  58188. * @param name defines the block name
  58189. */
  58190. constructor(name: string);
  58191. /**
  58192. * Gets the current class name
  58193. * @returns the class name
  58194. */
  58195. getClassName(): string;
  58196. /**
  58197. * Gets the xyzw component (input)
  58198. */
  58199. readonly xyzw: NodeMaterialConnectionPoint;
  58200. /**
  58201. * Gets the xyz component (input)
  58202. */
  58203. readonly xyzIn: NodeMaterialConnectionPoint;
  58204. /**
  58205. * Gets the xy component (input)
  58206. */
  58207. readonly xyIn: NodeMaterialConnectionPoint;
  58208. /**
  58209. * Gets the xyz component (output)
  58210. */
  58211. readonly xyzOut: NodeMaterialConnectionPoint;
  58212. /**
  58213. * Gets the xy component (output)
  58214. */
  58215. readonly xyOut: NodeMaterialConnectionPoint;
  58216. /**
  58217. * Gets the x component (output)
  58218. */
  58219. readonly x: NodeMaterialConnectionPoint;
  58220. /**
  58221. * Gets the y component (output)
  58222. */
  58223. readonly y: NodeMaterialConnectionPoint;
  58224. /**
  58225. * Gets the z component (output)
  58226. */
  58227. readonly z: NodeMaterialConnectionPoint;
  58228. /**
  58229. * Gets the w component (output)
  58230. */
  58231. readonly w: NodeMaterialConnectionPoint;
  58232. protected _inputRename(name: string): string;
  58233. protected _outputRename(name: string): string;
  58234. protected _buildBlock(state: NodeMaterialBuildState): this;
  58235. }
  58236. }
  58237. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58238. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58239. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58240. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58241. /**
  58242. * Block used to lerp between 2 values
  58243. */
  58244. export class LerpBlock extends NodeMaterialBlock {
  58245. /**
  58246. * Creates a new LerpBlock
  58247. * @param name defines the block name
  58248. */
  58249. constructor(name: string);
  58250. /**
  58251. * Gets the current class name
  58252. * @returns the class name
  58253. */
  58254. getClassName(): string;
  58255. /**
  58256. * Gets the left operand input component
  58257. */
  58258. readonly left: NodeMaterialConnectionPoint;
  58259. /**
  58260. * Gets the right operand input component
  58261. */
  58262. readonly right: NodeMaterialConnectionPoint;
  58263. /**
  58264. * Gets the gradient operand input component
  58265. */
  58266. readonly gradient: NodeMaterialConnectionPoint;
  58267. /**
  58268. * Gets the output component
  58269. */
  58270. readonly output: NodeMaterialConnectionPoint;
  58271. protected _buildBlock(state: NodeMaterialBuildState): this;
  58272. }
  58273. }
  58274. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58278. /**
  58279. * Block used to divide 2 vectors
  58280. */
  58281. export class DivideBlock extends NodeMaterialBlock {
  58282. /**
  58283. * Creates a new DivideBlock
  58284. * @param name defines the block name
  58285. */
  58286. constructor(name: string);
  58287. /**
  58288. * Gets the current class name
  58289. * @returns the class name
  58290. */
  58291. getClassName(): string;
  58292. /**
  58293. * Gets the left operand input component
  58294. */
  58295. readonly left: NodeMaterialConnectionPoint;
  58296. /**
  58297. * Gets the right operand input component
  58298. */
  58299. readonly right: NodeMaterialConnectionPoint;
  58300. /**
  58301. * Gets the output component
  58302. */
  58303. readonly output: NodeMaterialConnectionPoint;
  58304. protected _buildBlock(state: NodeMaterialBuildState): this;
  58305. }
  58306. }
  58307. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58311. /**
  58312. * Block used to subtract 2 vectors
  58313. */
  58314. export class SubtractBlock extends NodeMaterialBlock {
  58315. /**
  58316. * Creates a new SubtractBlock
  58317. * @param name defines the block name
  58318. */
  58319. constructor(name: string);
  58320. /**
  58321. * Gets the current class name
  58322. * @returns the class name
  58323. */
  58324. getClassName(): string;
  58325. /**
  58326. * Gets the left operand input component
  58327. */
  58328. readonly left: NodeMaterialConnectionPoint;
  58329. /**
  58330. * Gets the right operand input component
  58331. */
  58332. readonly right: NodeMaterialConnectionPoint;
  58333. /**
  58334. * Gets the output component
  58335. */
  58336. readonly output: NodeMaterialConnectionPoint;
  58337. protected _buildBlock(state: NodeMaterialBuildState): this;
  58338. }
  58339. }
  58340. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58344. /**
  58345. * Block used to step a value
  58346. */
  58347. export class StepBlock extends NodeMaterialBlock {
  58348. /**
  58349. * Creates a new StepBlock
  58350. * @param name defines the block name
  58351. */
  58352. constructor(name: string);
  58353. /**
  58354. * Gets the current class name
  58355. * @returns the class name
  58356. */
  58357. getClassName(): string;
  58358. /**
  58359. * Gets the value operand input component
  58360. */
  58361. readonly value: NodeMaterialConnectionPoint;
  58362. /**
  58363. * Gets the edge operand input component
  58364. */
  58365. readonly edge: NodeMaterialConnectionPoint;
  58366. /**
  58367. * Gets the output component
  58368. */
  58369. readonly output: NodeMaterialConnectionPoint;
  58370. protected _buildBlock(state: NodeMaterialBuildState): this;
  58371. }
  58372. }
  58373. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58377. /**
  58378. * Block used to get the opposite (1 - x) of a value
  58379. */
  58380. export class OneMinusBlock extends NodeMaterialBlock {
  58381. /**
  58382. * Creates a new OneMinusBlock
  58383. * @param name defines the block name
  58384. */
  58385. constructor(name: string);
  58386. /**
  58387. * Gets the current class name
  58388. * @returns the class name
  58389. */
  58390. getClassName(): string;
  58391. /**
  58392. * Gets the input component
  58393. */
  58394. readonly input: NodeMaterialConnectionPoint;
  58395. /**
  58396. * Gets the output component
  58397. */
  58398. readonly output: NodeMaterialConnectionPoint;
  58399. protected _buildBlock(state: NodeMaterialBuildState): this;
  58400. }
  58401. }
  58402. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58403. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58405. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58406. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58407. /**
  58408. * Block used to get the view direction
  58409. */
  58410. export class ViewDirectionBlock extends NodeMaterialBlock {
  58411. /**
  58412. * Creates a new ViewDirectionBlock
  58413. * @param name defines the block name
  58414. */
  58415. constructor(name: string);
  58416. /**
  58417. * Gets the current class name
  58418. * @returns the class name
  58419. */
  58420. getClassName(): string;
  58421. /**
  58422. * Gets the world position component
  58423. */
  58424. readonly worldPosition: NodeMaterialConnectionPoint;
  58425. /**
  58426. * Gets the camera position component
  58427. */
  58428. readonly cameraPosition: NodeMaterialConnectionPoint;
  58429. /**
  58430. * Gets the output component
  58431. */
  58432. readonly output: NodeMaterialConnectionPoint;
  58433. autoConfigure(material: NodeMaterial): void;
  58434. protected _buildBlock(state: NodeMaterialBuildState): this;
  58435. }
  58436. }
  58437. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58441. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58442. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58443. /**
  58444. * Block used to compute fresnel value
  58445. */
  58446. export class FresnelBlock extends NodeMaterialBlock {
  58447. /**
  58448. * Create a new FresnelBlock
  58449. * @param name defines the block name
  58450. */
  58451. constructor(name: string);
  58452. /**
  58453. * Gets the current class name
  58454. * @returns the class name
  58455. */
  58456. getClassName(): string;
  58457. /**
  58458. * Gets the world normal input component
  58459. */
  58460. readonly worldNormal: NodeMaterialConnectionPoint;
  58461. /**
  58462. * Gets the view direction input component
  58463. */
  58464. readonly viewDirection: NodeMaterialConnectionPoint;
  58465. /**
  58466. * Gets the bias input component
  58467. */
  58468. readonly bias: NodeMaterialConnectionPoint;
  58469. /**
  58470. * Gets the camera (or eye) position component
  58471. */
  58472. readonly power: NodeMaterialConnectionPoint;
  58473. /**
  58474. * Gets the fresnel output component
  58475. */
  58476. readonly fresnel: NodeMaterialConnectionPoint;
  58477. autoConfigure(material: NodeMaterial): void;
  58478. protected _buildBlock(state: NodeMaterialBuildState): this;
  58479. }
  58480. }
  58481. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58485. /**
  58486. * Block used to get the max of 2 values
  58487. */
  58488. export class MaxBlock extends NodeMaterialBlock {
  58489. /**
  58490. * Creates a new MaxBlock
  58491. * @param name defines the block name
  58492. */
  58493. constructor(name: string);
  58494. /**
  58495. * Gets the current class name
  58496. * @returns the class name
  58497. */
  58498. getClassName(): string;
  58499. /**
  58500. * Gets the left operand input component
  58501. */
  58502. readonly left: NodeMaterialConnectionPoint;
  58503. /**
  58504. * Gets the right operand input component
  58505. */
  58506. readonly right: NodeMaterialConnectionPoint;
  58507. /**
  58508. * Gets the output component
  58509. */
  58510. readonly output: NodeMaterialConnectionPoint;
  58511. protected _buildBlock(state: NodeMaterialBuildState): this;
  58512. }
  58513. }
  58514. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58518. /**
  58519. * Block used to get the min of 2 values
  58520. */
  58521. export class MinBlock extends NodeMaterialBlock {
  58522. /**
  58523. * Creates a new MinBlock
  58524. * @param name defines the block name
  58525. */
  58526. constructor(name: string);
  58527. /**
  58528. * Gets the current class name
  58529. * @returns the class name
  58530. */
  58531. getClassName(): string;
  58532. /**
  58533. * Gets the left operand input component
  58534. */
  58535. readonly left: NodeMaterialConnectionPoint;
  58536. /**
  58537. * Gets the right operand input component
  58538. */
  58539. readonly right: NodeMaterialConnectionPoint;
  58540. /**
  58541. * Gets the output component
  58542. */
  58543. readonly output: NodeMaterialConnectionPoint;
  58544. protected _buildBlock(state: NodeMaterialBuildState): this;
  58545. }
  58546. }
  58547. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58551. /**
  58552. * Block used to get the distance between 2 values
  58553. */
  58554. export class DistanceBlock extends NodeMaterialBlock {
  58555. /**
  58556. * Creates a new DistanceBlock
  58557. * @param name defines the block name
  58558. */
  58559. constructor(name: string);
  58560. /**
  58561. * Gets the current class name
  58562. * @returns the class name
  58563. */
  58564. getClassName(): string;
  58565. /**
  58566. * Gets the left operand input component
  58567. */
  58568. readonly left: NodeMaterialConnectionPoint;
  58569. /**
  58570. * Gets the right operand input component
  58571. */
  58572. readonly right: NodeMaterialConnectionPoint;
  58573. /**
  58574. * Gets the output component
  58575. */
  58576. readonly output: NodeMaterialConnectionPoint;
  58577. protected _buildBlock(state: NodeMaterialBuildState): this;
  58578. }
  58579. }
  58580. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58584. /**
  58585. * Block used to get the length of a vector
  58586. */
  58587. export class LengthBlock extends NodeMaterialBlock {
  58588. /**
  58589. * Creates a new LengthBlock
  58590. * @param name defines the block name
  58591. */
  58592. constructor(name: string);
  58593. /**
  58594. * Gets the current class name
  58595. * @returns the class name
  58596. */
  58597. getClassName(): string;
  58598. /**
  58599. * Gets the value input component
  58600. */
  58601. readonly value: NodeMaterialConnectionPoint;
  58602. /**
  58603. * Gets the output component
  58604. */
  58605. readonly output: NodeMaterialConnectionPoint;
  58606. protected _buildBlock(state: NodeMaterialBuildState): this;
  58607. }
  58608. }
  58609. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58613. /**
  58614. * Block used to get negative version of a value (i.e. x * -1)
  58615. */
  58616. export class NegateBlock extends NodeMaterialBlock {
  58617. /**
  58618. * Creates a new NegateBlock
  58619. * @param name defines the block name
  58620. */
  58621. constructor(name: string);
  58622. /**
  58623. * Gets the current class name
  58624. * @returns the class name
  58625. */
  58626. getClassName(): string;
  58627. /**
  58628. * Gets the value input component
  58629. */
  58630. readonly value: NodeMaterialConnectionPoint;
  58631. /**
  58632. * Gets the output component
  58633. */
  58634. readonly output: NodeMaterialConnectionPoint;
  58635. protected _buildBlock(state: NodeMaterialBuildState): this;
  58636. }
  58637. }
  58638. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58642. /**
  58643. * Block used to get the value of the first parameter raised to the power of the second
  58644. */
  58645. export class PowBlock extends NodeMaterialBlock {
  58646. /**
  58647. * Creates a new PowBlock
  58648. * @param name defines the block name
  58649. */
  58650. constructor(name: string);
  58651. /**
  58652. * Gets the current class name
  58653. * @returns the class name
  58654. */
  58655. getClassName(): string;
  58656. /**
  58657. * Gets the value operand input component
  58658. */
  58659. readonly value: NodeMaterialConnectionPoint;
  58660. /**
  58661. * Gets the power operand input component
  58662. */
  58663. readonly power: NodeMaterialConnectionPoint;
  58664. /**
  58665. * Gets the output component
  58666. */
  58667. readonly output: NodeMaterialConnectionPoint;
  58668. protected _buildBlock(state: NodeMaterialBuildState): this;
  58669. }
  58670. }
  58671. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58672. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58673. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58674. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58675. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58676. /**
  58677. * Block used to get a random number
  58678. */
  58679. export class RandomNumberBlock extends NodeMaterialBlock {
  58680. /**
  58681. * Creates a new RandomNumberBlock
  58682. * @param name defines the block name
  58683. */
  58684. constructor(name: string);
  58685. /**
  58686. * Gets the current class name
  58687. * @returns the class name
  58688. */
  58689. getClassName(): string;
  58690. /**
  58691. * Gets the seed input component
  58692. */
  58693. readonly seed: NodeMaterialConnectionPoint;
  58694. /**
  58695. * Gets the output component
  58696. */
  58697. readonly output: NodeMaterialConnectionPoint;
  58698. protected _buildBlock(state: NodeMaterialBuildState): this;
  58699. }
  58700. }
  58701. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58705. /**
  58706. * Block used to compute arc tangent of 2 values
  58707. */
  58708. export class ArcTan2Block extends NodeMaterialBlock {
  58709. /**
  58710. * Creates a new ArcTan2Block
  58711. * @param name defines the block name
  58712. */
  58713. constructor(name: string);
  58714. /**
  58715. * Gets the current class name
  58716. * @returns the class name
  58717. */
  58718. getClassName(): string;
  58719. /**
  58720. * Gets the x operand input component
  58721. */
  58722. readonly x: NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the y operand input component
  58725. */
  58726. readonly y: NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the output component
  58729. */
  58730. readonly output: NodeMaterialConnectionPoint;
  58731. protected _buildBlock(state: NodeMaterialBuildState): this;
  58732. }
  58733. }
  58734. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58738. /**
  58739. * Block used to smooth step a value
  58740. */
  58741. export class SmoothStepBlock extends NodeMaterialBlock {
  58742. /**
  58743. * Creates a new SmoothStepBlock
  58744. * @param name defines the block name
  58745. */
  58746. constructor(name: string);
  58747. /**
  58748. * Gets the current class name
  58749. * @returns the class name
  58750. */
  58751. getClassName(): string;
  58752. /**
  58753. * Gets the value operand input component
  58754. */
  58755. readonly value: NodeMaterialConnectionPoint;
  58756. /**
  58757. * Gets the first edge operand input component
  58758. */
  58759. readonly edge0: NodeMaterialConnectionPoint;
  58760. /**
  58761. * Gets the second edge operand input component
  58762. */
  58763. readonly edge1: NodeMaterialConnectionPoint;
  58764. /**
  58765. * Gets the output component
  58766. */
  58767. readonly output: NodeMaterialConnectionPoint;
  58768. protected _buildBlock(state: NodeMaterialBuildState): this;
  58769. }
  58770. }
  58771. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58775. /**
  58776. * Block used to get the reciprocal (1 / x) of a value
  58777. */
  58778. export class ReciprocalBlock extends NodeMaterialBlock {
  58779. /**
  58780. * Creates a new ReciprocalBlock
  58781. * @param name defines the block name
  58782. */
  58783. constructor(name: string);
  58784. /**
  58785. * Gets the current class name
  58786. * @returns the class name
  58787. */
  58788. getClassName(): string;
  58789. /**
  58790. * Gets the input component
  58791. */
  58792. readonly input: NodeMaterialConnectionPoint;
  58793. /**
  58794. * Gets the output component
  58795. */
  58796. readonly output: NodeMaterialConnectionPoint;
  58797. protected _buildBlock(state: NodeMaterialBuildState): this;
  58798. }
  58799. }
  58800. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58804. /**
  58805. * Block used to replace a color by another one
  58806. */
  58807. export class ReplaceColorBlock extends NodeMaterialBlock {
  58808. /**
  58809. * Creates a new ReplaceColorBlock
  58810. * @param name defines the block name
  58811. */
  58812. constructor(name: string);
  58813. /**
  58814. * Gets the current class name
  58815. * @returns the class name
  58816. */
  58817. getClassName(): string;
  58818. /**
  58819. * Gets the value input component
  58820. */
  58821. readonly value: NodeMaterialConnectionPoint;
  58822. /**
  58823. * Gets the reference input component
  58824. */
  58825. readonly reference: NodeMaterialConnectionPoint;
  58826. /**
  58827. * Gets the distance input component
  58828. */
  58829. readonly distance: NodeMaterialConnectionPoint;
  58830. /**
  58831. * Gets the replacement input component
  58832. */
  58833. readonly replacement: NodeMaterialConnectionPoint;
  58834. /**
  58835. * Gets the output component
  58836. */
  58837. readonly output: NodeMaterialConnectionPoint;
  58838. protected _buildBlock(state: NodeMaterialBuildState): this;
  58839. }
  58840. }
  58841. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58845. /**
  58846. * Block used to posterize a value
  58847. * @see https://en.wikipedia.org/wiki/Posterization
  58848. */
  58849. export class PosterizeBlock extends NodeMaterialBlock {
  58850. /**
  58851. * Creates a new PosterizeBlock
  58852. * @param name defines the block name
  58853. */
  58854. constructor(name: string);
  58855. /**
  58856. * Gets the current class name
  58857. * @returns the class name
  58858. */
  58859. getClassName(): string;
  58860. /**
  58861. * Gets the value input component
  58862. */
  58863. readonly value: NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the steps input component
  58866. */
  58867. readonly steps: NodeMaterialConnectionPoint;
  58868. /**
  58869. * Gets the output component
  58870. */
  58871. readonly output: NodeMaterialConnectionPoint;
  58872. protected _buildBlock(state: NodeMaterialBuildState): this;
  58873. }
  58874. }
  58875. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58879. import { Scene } from "babylonjs/scene";
  58880. /**
  58881. * Operations supported by the Wave block
  58882. */
  58883. export enum WaveBlockKind {
  58884. /** SawTooth */
  58885. SawTooth = 0,
  58886. /** Square */
  58887. Square = 1,
  58888. /** Triangle */
  58889. Triangle = 2
  58890. }
  58891. /**
  58892. * Block used to apply wave operation to floats
  58893. */
  58894. export class WaveBlock extends NodeMaterialBlock {
  58895. /**
  58896. * Gets or sets the kibnd of wave to be applied by the block
  58897. */
  58898. kind: WaveBlockKind;
  58899. /**
  58900. * Creates a new WaveBlock
  58901. * @param name defines the block name
  58902. */
  58903. constructor(name: string);
  58904. /**
  58905. * Gets the current class name
  58906. * @returns the class name
  58907. */
  58908. getClassName(): string;
  58909. /**
  58910. * Gets the input component
  58911. */
  58912. readonly input: NodeMaterialConnectionPoint;
  58913. /**
  58914. * Gets the output component
  58915. */
  58916. readonly output: NodeMaterialConnectionPoint;
  58917. protected _buildBlock(state: NodeMaterialBuildState): this;
  58918. serialize(): any;
  58919. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58920. }
  58921. }
  58922. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58925. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58926. import { Color3 } from "babylonjs/Maths/math.color";
  58927. import { Scene } from "babylonjs/scene";
  58928. /**
  58929. * Class used to store a color step for the GradientBlock
  58930. */
  58931. export class GradientBlockColorStep {
  58932. /**
  58933. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58934. */
  58935. step: number;
  58936. /**
  58937. * Gets or sets the color associated with this step
  58938. */
  58939. color: Color3;
  58940. /**
  58941. * Creates a new GradientBlockColorStep
  58942. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58943. * @param color defines the color associated with this step
  58944. */
  58945. constructor(
  58946. /**
  58947. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58948. */
  58949. step: number,
  58950. /**
  58951. * Gets or sets the color associated with this step
  58952. */
  58953. color: Color3);
  58954. }
  58955. /**
  58956. * Block used to return a color from a gradient based on an input value between 0 and 1
  58957. */
  58958. export class GradientBlock extends NodeMaterialBlock {
  58959. /**
  58960. * Gets or sets the list of color steps
  58961. */
  58962. colorSteps: GradientBlockColorStep[];
  58963. /**
  58964. * Creates a new GradientBlock
  58965. * @param name defines the block name
  58966. */
  58967. constructor(name: string);
  58968. /**
  58969. * Gets the current class name
  58970. * @returns the class name
  58971. */
  58972. getClassName(): string;
  58973. /**
  58974. * Gets the gradient input component
  58975. */
  58976. readonly gradient: NodeMaterialConnectionPoint;
  58977. /**
  58978. * Gets the output component
  58979. */
  58980. readonly output: NodeMaterialConnectionPoint;
  58981. private _writeColorConstant;
  58982. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58983. serialize(): any;
  58984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58985. protected _dumpPropertiesCode(): string;
  58986. }
  58987. }
  58988. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58992. /**
  58993. * Block used to normalize lerp between 2 values
  58994. */
  58995. export class NLerpBlock extends NodeMaterialBlock {
  58996. /**
  58997. * Creates a new NLerpBlock
  58998. * @param name defines the block name
  58999. */
  59000. constructor(name: string);
  59001. /**
  59002. * Gets the current class name
  59003. * @returns the class name
  59004. */
  59005. getClassName(): string;
  59006. /**
  59007. * Gets the left operand input component
  59008. */
  59009. readonly left: NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the right operand input component
  59012. */
  59013. readonly right: NodeMaterialConnectionPoint;
  59014. /**
  59015. * Gets the gradient operand input component
  59016. */
  59017. readonly gradient: NodeMaterialConnectionPoint;
  59018. /**
  59019. * Gets the output component
  59020. */
  59021. readonly output: NodeMaterialConnectionPoint;
  59022. protected _buildBlock(state: NodeMaterialBuildState): this;
  59023. }
  59024. }
  59025. declare module "babylonjs/Materials/Node/Blocks/index" {
  59026. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59027. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59028. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59029. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59030. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59031. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59032. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59033. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59034. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59035. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59036. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59037. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59038. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59039. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59040. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59041. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59042. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59043. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59044. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59045. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59046. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59047. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59048. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59049. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59050. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59051. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59052. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59053. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59054. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59055. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59056. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59057. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59058. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59059. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59060. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59061. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59062. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59063. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59064. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59065. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59066. }
  59067. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59068. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59069. }
  59070. declare module "babylonjs/Materials/Node/index" {
  59071. export * from "babylonjs/Materials/Node/Enums/index";
  59072. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59073. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59074. export * from "babylonjs/Materials/Node/nodeMaterial";
  59075. export * from "babylonjs/Materials/Node/Blocks/index";
  59076. export * from "babylonjs/Materials/Node/Optimizers/index";
  59077. }
  59078. declare module "babylonjs/Materials/effectRenderer" {
  59079. import { Nullable } from "babylonjs/types";
  59080. import { Texture } from "babylonjs/Materials/Textures/texture";
  59081. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59082. import { Viewport } from "babylonjs/Maths/math.viewport";
  59083. import { Observable } from "babylonjs/Misc/observable";
  59084. import { Effect } from "babylonjs/Materials/effect";
  59085. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59086. import "babylonjs/Shaders/postprocess.vertex";
  59087. /**
  59088. * Effect Render Options
  59089. */
  59090. export interface IEffectRendererOptions {
  59091. /**
  59092. * Defines the vertices positions.
  59093. */
  59094. positions?: number[];
  59095. /**
  59096. * Defines the indices.
  59097. */
  59098. indices?: number[];
  59099. }
  59100. /**
  59101. * Helper class to render one or more effects
  59102. */
  59103. export class EffectRenderer {
  59104. private engine;
  59105. private static _DefaultOptions;
  59106. private _vertexBuffers;
  59107. private _indexBuffer;
  59108. private _ringBufferIndex;
  59109. private _ringScreenBuffer;
  59110. private _fullscreenViewport;
  59111. private _getNextFrameBuffer;
  59112. /**
  59113. * Creates an effect renderer
  59114. * @param engine the engine to use for rendering
  59115. * @param options defines the options of the effect renderer
  59116. */
  59117. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59118. /**
  59119. * Sets the current viewport in normalized coordinates 0-1
  59120. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59121. */
  59122. setViewport(viewport?: Viewport): void;
  59123. /**
  59124. * Binds the embedded attributes buffer to the effect.
  59125. * @param effect Defines the effect to bind the attributes for
  59126. */
  59127. bindBuffers(effect: Effect): void;
  59128. /**
  59129. * Sets the current effect wrapper to use during draw.
  59130. * The effect needs to be ready before calling this api.
  59131. * This also sets the default full screen position attribute.
  59132. * @param effectWrapper Defines the effect to draw with
  59133. */
  59134. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59135. /**
  59136. * Draws a full screen quad.
  59137. */
  59138. draw(): void;
  59139. /**
  59140. * renders one or more effects to a specified texture
  59141. * @param effectWrappers list of effects to renderer
  59142. * @param outputTexture texture to draw to, if null it will render to the screen
  59143. */
  59144. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59145. /**
  59146. * Disposes of the effect renderer
  59147. */
  59148. dispose(): void;
  59149. }
  59150. /**
  59151. * Options to create an EffectWrapper
  59152. */
  59153. interface EffectWrapperCreationOptions {
  59154. /**
  59155. * Engine to use to create the effect
  59156. */
  59157. engine: ThinEngine;
  59158. /**
  59159. * Fragment shader for the effect
  59160. */
  59161. fragmentShader: string;
  59162. /**
  59163. * Vertex shader for the effect
  59164. */
  59165. vertexShader?: string;
  59166. /**
  59167. * Attributes to use in the shader
  59168. */
  59169. attributeNames?: Array<string>;
  59170. /**
  59171. * Uniforms to use in the shader
  59172. */
  59173. uniformNames?: Array<string>;
  59174. /**
  59175. * Texture sampler names to use in the shader
  59176. */
  59177. samplerNames?: Array<string>;
  59178. /**
  59179. * The friendly name of the effect displayed in Spector.
  59180. */
  59181. name?: string;
  59182. }
  59183. /**
  59184. * Wraps an effect to be used for rendering
  59185. */
  59186. export class EffectWrapper {
  59187. /**
  59188. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59189. */
  59190. onApplyObservable: Observable<{}>;
  59191. /**
  59192. * The underlying effect
  59193. */
  59194. effect: Effect;
  59195. /**
  59196. * Creates an effect to be renderer
  59197. * @param creationOptions options to create the effect
  59198. */
  59199. constructor(creationOptions: EffectWrapperCreationOptions);
  59200. /**
  59201. * Disposes of the effect wrapper
  59202. */
  59203. dispose(): void;
  59204. }
  59205. }
  59206. declare module "babylonjs/Materials/index" {
  59207. export * from "babylonjs/Materials/Background/index";
  59208. export * from "babylonjs/Materials/colorCurves";
  59209. export * from "babylonjs/Materials/iEffectFallbacks";
  59210. export * from "babylonjs/Materials/effectFallbacks";
  59211. export * from "babylonjs/Materials/effect";
  59212. export * from "babylonjs/Materials/fresnelParameters";
  59213. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59214. export * from "babylonjs/Materials/material";
  59215. export * from "babylonjs/Materials/materialDefines";
  59216. export * from "babylonjs/Materials/materialHelper";
  59217. export * from "babylonjs/Materials/multiMaterial";
  59218. export * from "babylonjs/Materials/PBR/index";
  59219. export * from "babylonjs/Materials/pushMaterial";
  59220. export * from "babylonjs/Materials/shaderMaterial";
  59221. export * from "babylonjs/Materials/standardMaterial";
  59222. export * from "babylonjs/Materials/Textures/index";
  59223. export * from "babylonjs/Materials/uniformBuffer";
  59224. export * from "babylonjs/Materials/materialFlags";
  59225. export * from "babylonjs/Materials/Node/index";
  59226. export * from "babylonjs/Materials/effectRenderer";
  59227. }
  59228. declare module "babylonjs/Maths/index" {
  59229. export * from "babylonjs/Maths/math.scalar";
  59230. export * from "babylonjs/Maths/math";
  59231. export * from "babylonjs/Maths/sphericalPolynomial";
  59232. }
  59233. declare module "babylonjs/Misc/workerPool" {
  59234. import { IDisposable } from "babylonjs/scene";
  59235. /**
  59236. * Helper class to push actions to a pool of workers.
  59237. */
  59238. export class WorkerPool implements IDisposable {
  59239. private _workerInfos;
  59240. private _pendingActions;
  59241. /**
  59242. * Constructor
  59243. * @param workers Array of workers to use for actions
  59244. */
  59245. constructor(workers: Array<Worker>);
  59246. /**
  59247. * Terminates all workers and clears any pending actions.
  59248. */
  59249. dispose(): void;
  59250. /**
  59251. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59252. * pended until a worker has completed its action.
  59253. * @param action The action to perform. Call onComplete when the action is complete.
  59254. */
  59255. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59256. private _execute;
  59257. }
  59258. }
  59259. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59260. import { IDisposable } from "babylonjs/scene";
  59261. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59262. /**
  59263. * Configuration for Draco compression
  59264. */
  59265. export interface IDracoCompressionConfiguration {
  59266. /**
  59267. * Configuration for the decoder.
  59268. */
  59269. decoder: {
  59270. /**
  59271. * The url to the WebAssembly module.
  59272. */
  59273. wasmUrl?: string;
  59274. /**
  59275. * The url to the WebAssembly binary.
  59276. */
  59277. wasmBinaryUrl?: string;
  59278. /**
  59279. * The url to the fallback JavaScript module.
  59280. */
  59281. fallbackUrl?: string;
  59282. };
  59283. }
  59284. /**
  59285. * Draco compression (https://google.github.io/draco/)
  59286. *
  59287. * This class wraps the Draco module.
  59288. *
  59289. * **Encoder**
  59290. *
  59291. * The encoder is not currently implemented.
  59292. *
  59293. * **Decoder**
  59294. *
  59295. * 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.
  59296. *
  59297. * To update the configuration, use the following code:
  59298. * ```javascript
  59299. * DracoCompression.Configuration = {
  59300. * decoder: {
  59301. * wasmUrl: "<url to the WebAssembly library>",
  59302. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59303. * fallbackUrl: "<url to the fallback JavaScript library>",
  59304. * }
  59305. * };
  59306. * ```
  59307. *
  59308. * 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.
  59309. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59310. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59311. *
  59312. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59313. * ```javascript
  59314. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59315. * ```
  59316. *
  59317. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59318. */
  59319. export class DracoCompression implements IDisposable {
  59320. private _workerPoolPromise?;
  59321. private _decoderModulePromise?;
  59322. /**
  59323. * The configuration. Defaults to the following urls:
  59324. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59325. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59326. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59327. */
  59328. static Configuration: IDracoCompressionConfiguration;
  59329. /**
  59330. * Returns true if the decoder configuration is available.
  59331. */
  59332. static readonly DecoderAvailable: boolean;
  59333. /**
  59334. * Default number of workers to create when creating the draco compression object.
  59335. */
  59336. static DefaultNumWorkers: number;
  59337. private static GetDefaultNumWorkers;
  59338. private static _Default;
  59339. /**
  59340. * Default instance for the draco compression object.
  59341. */
  59342. static readonly Default: DracoCompression;
  59343. /**
  59344. * Constructor
  59345. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59346. */
  59347. constructor(numWorkers?: number);
  59348. /**
  59349. * Stop all async operations and release resources.
  59350. */
  59351. dispose(): void;
  59352. /**
  59353. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59354. * @returns a promise that resolves when ready
  59355. */
  59356. whenReadyAsync(): Promise<void>;
  59357. /**
  59358. * Decode Draco compressed mesh data to vertex data.
  59359. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59360. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59361. * @returns A promise that resolves with the decoded vertex data
  59362. */
  59363. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59364. [kind: string]: number;
  59365. }): Promise<VertexData>;
  59366. }
  59367. }
  59368. declare module "babylonjs/Meshes/Compression/index" {
  59369. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59370. }
  59371. declare module "babylonjs/Meshes/csg" {
  59372. import { Nullable } from "babylonjs/types";
  59373. import { Scene } from "babylonjs/scene";
  59374. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59375. import { Mesh } from "babylonjs/Meshes/mesh";
  59376. import { Material } from "babylonjs/Materials/material";
  59377. /**
  59378. * Class for building Constructive Solid Geometry
  59379. */
  59380. export class CSG {
  59381. private polygons;
  59382. /**
  59383. * The world matrix
  59384. */
  59385. matrix: Matrix;
  59386. /**
  59387. * Stores the position
  59388. */
  59389. position: Vector3;
  59390. /**
  59391. * Stores the rotation
  59392. */
  59393. rotation: Vector3;
  59394. /**
  59395. * Stores the rotation quaternion
  59396. */
  59397. rotationQuaternion: Nullable<Quaternion>;
  59398. /**
  59399. * Stores the scaling vector
  59400. */
  59401. scaling: Vector3;
  59402. /**
  59403. * Convert the Mesh to CSG
  59404. * @param mesh The Mesh to convert to CSG
  59405. * @returns A new CSG from the Mesh
  59406. */
  59407. static FromMesh(mesh: Mesh): CSG;
  59408. /**
  59409. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59410. * @param polygons Polygons used to construct a CSG solid
  59411. */
  59412. private static FromPolygons;
  59413. /**
  59414. * Clones, or makes a deep copy, of the CSG
  59415. * @returns A new CSG
  59416. */
  59417. clone(): CSG;
  59418. /**
  59419. * Unions this CSG with another CSG
  59420. * @param csg The CSG to union against this CSG
  59421. * @returns The unioned CSG
  59422. */
  59423. union(csg: CSG): CSG;
  59424. /**
  59425. * Unions this CSG with another CSG in place
  59426. * @param csg The CSG to union against this CSG
  59427. */
  59428. unionInPlace(csg: CSG): void;
  59429. /**
  59430. * Subtracts this CSG with another CSG
  59431. * @param csg The CSG to subtract against this CSG
  59432. * @returns A new CSG
  59433. */
  59434. subtract(csg: CSG): CSG;
  59435. /**
  59436. * Subtracts this CSG with another CSG in place
  59437. * @param csg The CSG to subtact against this CSG
  59438. */
  59439. subtractInPlace(csg: CSG): void;
  59440. /**
  59441. * Intersect this CSG with another CSG
  59442. * @param csg The CSG to intersect against this CSG
  59443. * @returns A new CSG
  59444. */
  59445. intersect(csg: CSG): CSG;
  59446. /**
  59447. * Intersects this CSG with another CSG in place
  59448. * @param csg The CSG to intersect against this CSG
  59449. */
  59450. intersectInPlace(csg: CSG): void;
  59451. /**
  59452. * Return a new CSG solid with solid and empty space switched. This solid is
  59453. * not modified.
  59454. * @returns A new CSG solid with solid and empty space switched
  59455. */
  59456. inverse(): CSG;
  59457. /**
  59458. * Inverses the CSG in place
  59459. */
  59460. inverseInPlace(): void;
  59461. /**
  59462. * This is used to keep meshes transformations so they can be restored
  59463. * when we build back a Babylon Mesh
  59464. * NB : All CSG operations are performed in world coordinates
  59465. * @param csg The CSG to copy the transform attributes from
  59466. * @returns This CSG
  59467. */
  59468. copyTransformAttributes(csg: CSG): CSG;
  59469. /**
  59470. * Build Raw mesh from CSG
  59471. * Coordinates here are in world space
  59472. * @param name The name of the mesh geometry
  59473. * @param scene The Scene
  59474. * @param keepSubMeshes Specifies if the submeshes should be kept
  59475. * @returns A new Mesh
  59476. */
  59477. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59478. /**
  59479. * Build Mesh from CSG taking material and transforms into account
  59480. * @param name The name of the Mesh
  59481. * @param material The material of the Mesh
  59482. * @param scene The Scene
  59483. * @param keepSubMeshes Specifies if submeshes should be kept
  59484. * @returns The new Mesh
  59485. */
  59486. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59487. }
  59488. }
  59489. declare module "babylonjs/Meshes/trailMesh" {
  59490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59491. import { Mesh } from "babylonjs/Meshes/mesh";
  59492. import { Scene } from "babylonjs/scene";
  59493. /**
  59494. * Class used to create a trail following a mesh
  59495. */
  59496. export class TrailMesh extends Mesh {
  59497. private _generator;
  59498. private _autoStart;
  59499. private _running;
  59500. private _diameter;
  59501. private _length;
  59502. private _sectionPolygonPointsCount;
  59503. private _sectionVectors;
  59504. private _sectionNormalVectors;
  59505. private _beforeRenderObserver;
  59506. /**
  59507. * @constructor
  59508. * @param name The value used by scene.getMeshByName() to do a lookup.
  59509. * @param generator The mesh to generate a trail.
  59510. * @param scene The scene to add this mesh to.
  59511. * @param diameter Diameter of trailing mesh. Default is 1.
  59512. * @param length Length of trailing mesh. Default is 60.
  59513. * @param autoStart Automatically start trailing mesh. Default true.
  59514. */
  59515. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59516. /**
  59517. * "TrailMesh"
  59518. * @returns "TrailMesh"
  59519. */
  59520. getClassName(): string;
  59521. private _createMesh;
  59522. /**
  59523. * Start trailing mesh.
  59524. */
  59525. start(): void;
  59526. /**
  59527. * Stop trailing mesh.
  59528. */
  59529. stop(): void;
  59530. /**
  59531. * Update trailing mesh geometry.
  59532. */
  59533. update(): void;
  59534. /**
  59535. * Returns a new TrailMesh object.
  59536. * @param name is a string, the name given to the new mesh
  59537. * @param newGenerator use new generator object for cloned trail mesh
  59538. * @returns a new mesh
  59539. */
  59540. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59541. /**
  59542. * Serializes this trail mesh
  59543. * @param serializationObject object to write serialization to
  59544. */
  59545. serialize(serializationObject: any): void;
  59546. /**
  59547. * Parses a serialized trail mesh
  59548. * @param parsedMesh the serialized mesh
  59549. * @param scene the scene to create the trail mesh in
  59550. * @returns the created trail mesh
  59551. */
  59552. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59553. }
  59554. }
  59555. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59556. import { Nullable } from "babylonjs/types";
  59557. import { Scene } from "babylonjs/scene";
  59558. import { Vector4 } from "babylonjs/Maths/math.vector";
  59559. import { Color4 } from "babylonjs/Maths/math.color";
  59560. import { Mesh } from "babylonjs/Meshes/mesh";
  59561. /**
  59562. * Class containing static functions to help procedurally build meshes
  59563. */
  59564. export class TiledBoxBuilder {
  59565. /**
  59566. * Creates a box mesh
  59567. * 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)
  59568. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59572. * @param name defines the name of the mesh
  59573. * @param options defines the options used to create the mesh
  59574. * @param scene defines the hosting scene
  59575. * @returns the box mesh
  59576. */
  59577. static CreateTiledBox(name: string, options: {
  59578. pattern?: number;
  59579. width?: number;
  59580. height?: number;
  59581. depth?: number;
  59582. tileSize?: number;
  59583. tileWidth?: number;
  59584. tileHeight?: number;
  59585. alignHorizontal?: number;
  59586. alignVertical?: number;
  59587. faceUV?: Vector4[];
  59588. faceColors?: Color4[];
  59589. sideOrientation?: number;
  59590. updatable?: boolean;
  59591. }, scene?: Nullable<Scene>): Mesh;
  59592. }
  59593. }
  59594. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59595. import { Vector4 } from "babylonjs/Maths/math.vector";
  59596. import { Mesh } from "babylonjs/Meshes/mesh";
  59597. /**
  59598. * Class containing static functions to help procedurally build meshes
  59599. */
  59600. export class TorusKnotBuilder {
  59601. /**
  59602. * Creates a torus knot mesh
  59603. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59604. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59605. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59606. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59610. * @param name defines the name of the mesh
  59611. * @param options defines the options used to create the mesh
  59612. * @param scene defines the hosting scene
  59613. * @returns the torus knot mesh
  59614. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59615. */
  59616. static CreateTorusKnot(name: string, options: {
  59617. radius?: number;
  59618. tube?: number;
  59619. radialSegments?: number;
  59620. tubularSegments?: number;
  59621. p?: number;
  59622. q?: number;
  59623. updatable?: boolean;
  59624. sideOrientation?: number;
  59625. frontUVs?: Vector4;
  59626. backUVs?: Vector4;
  59627. }, scene: any): Mesh;
  59628. }
  59629. }
  59630. declare module "babylonjs/Meshes/polygonMesh" {
  59631. import { Scene } from "babylonjs/scene";
  59632. import { Vector2 } from "babylonjs/Maths/math.vector";
  59633. import { Mesh } from "babylonjs/Meshes/mesh";
  59634. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59635. import { Path2 } from "babylonjs/Maths/math.path";
  59636. /**
  59637. * Polygon
  59638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59639. */
  59640. export class Polygon {
  59641. /**
  59642. * Creates a rectangle
  59643. * @param xmin bottom X coord
  59644. * @param ymin bottom Y coord
  59645. * @param xmax top X coord
  59646. * @param ymax top Y coord
  59647. * @returns points that make the resulting rectation
  59648. */
  59649. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59650. /**
  59651. * Creates a circle
  59652. * @param radius radius of circle
  59653. * @param cx scale in x
  59654. * @param cy scale in y
  59655. * @param numberOfSides number of sides that make up the circle
  59656. * @returns points that make the resulting circle
  59657. */
  59658. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59659. /**
  59660. * Creates a polygon from input string
  59661. * @param input Input polygon data
  59662. * @returns the parsed points
  59663. */
  59664. static Parse(input: string): Vector2[];
  59665. /**
  59666. * Starts building a polygon from x and y coordinates
  59667. * @param x x coordinate
  59668. * @param y y coordinate
  59669. * @returns the started path2
  59670. */
  59671. static StartingAt(x: number, y: number): Path2;
  59672. }
  59673. /**
  59674. * Builds a polygon
  59675. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59676. */
  59677. export class PolygonMeshBuilder {
  59678. private _points;
  59679. private _outlinepoints;
  59680. private _holes;
  59681. private _name;
  59682. private _scene;
  59683. private _epoints;
  59684. private _eholes;
  59685. private _addToepoint;
  59686. /**
  59687. * Babylon reference to the earcut plugin.
  59688. */
  59689. bjsEarcut: any;
  59690. /**
  59691. * Creates a PolygonMeshBuilder
  59692. * @param name name of the builder
  59693. * @param contours Path of the polygon
  59694. * @param scene scene to add to when creating the mesh
  59695. * @param earcutInjection can be used to inject your own earcut reference
  59696. */
  59697. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59698. /**
  59699. * Adds a whole within the polygon
  59700. * @param hole Array of points defining the hole
  59701. * @returns this
  59702. */
  59703. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59704. /**
  59705. * Creates the polygon
  59706. * @param updatable If the mesh should be updatable
  59707. * @param depth The depth of the mesh created
  59708. * @returns the created mesh
  59709. */
  59710. build(updatable?: boolean, depth?: number): Mesh;
  59711. /**
  59712. * Creates the polygon
  59713. * @param depth The depth of the mesh created
  59714. * @returns the created VertexData
  59715. */
  59716. buildVertexData(depth?: number): VertexData;
  59717. /**
  59718. * Adds a side to the polygon
  59719. * @param positions points that make the polygon
  59720. * @param normals normals of the polygon
  59721. * @param uvs uvs of the polygon
  59722. * @param indices indices of the polygon
  59723. * @param bounds bounds of the polygon
  59724. * @param points points of the polygon
  59725. * @param depth depth of the polygon
  59726. * @param flip flip of the polygon
  59727. */
  59728. private addSide;
  59729. }
  59730. }
  59731. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59732. import { Scene } from "babylonjs/scene";
  59733. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59734. import { Color4 } from "babylonjs/Maths/math.color";
  59735. import { Mesh } from "babylonjs/Meshes/mesh";
  59736. import { Nullable } from "babylonjs/types";
  59737. /**
  59738. * Class containing static functions to help procedurally build meshes
  59739. */
  59740. export class PolygonBuilder {
  59741. /**
  59742. * Creates a polygon mesh
  59743. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59744. * * 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
  59745. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59748. * * Remember you can only change the shape positions, not their number when updating a polygon
  59749. * @param name defines the name of the mesh
  59750. * @param options defines the options used to create the mesh
  59751. * @param scene defines the hosting scene
  59752. * @param earcutInjection can be used to inject your own earcut reference
  59753. * @returns the polygon mesh
  59754. */
  59755. static CreatePolygon(name: string, options: {
  59756. shape: Vector3[];
  59757. holes?: Vector3[][];
  59758. depth?: number;
  59759. faceUV?: Vector4[];
  59760. faceColors?: Color4[];
  59761. updatable?: boolean;
  59762. sideOrientation?: number;
  59763. frontUVs?: Vector4;
  59764. backUVs?: Vector4;
  59765. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59766. /**
  59767. * Creates an extruded polygon mesh, with depth in the Y direction.
  59768. * * 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)
  59769. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59770. * @param name defines the name of the mesh
  59771. * @param options defines the options used to create the mesh
  59772. * @param scene defines the hosting scene
  59773. * @param earcutInjection can be used to inject your own earcut reference
  59774. * @returns the polygon mesh
  59775. */
  59776. static ExtrudePolygon(name: string, options: {
  59777. shape: Vector3[];
  59778. holes?: Vector3[][];
  59779. depth?: number;
  59780. faceUV?: Vector4[];
  59781. faceColors?: Color4[];
  59782. updatable?: boolean;
  59783. sideOrientation?: number;
  59784. frontUVs?: Vector4;
  59785. backUVs?: Vector4;
  59786. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59787. }
  59788. }
  59789. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59790. import { Scene } from "babylonjs/scene";
  59791. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59792. import { Mesh } from "babylonjs/Meshes/mesh";
  59793. import { Nullable } from "babylonjs/types";
  59794. /**
  59795. * Class containing static functions to help procedurally build meshes
  59796. */
  59797. export class LatheBuilder {
  59798. /**
  59799. * Creates lathe mesh.
  59800. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59801. * * 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
  59802. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59803. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59804. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59805. * * 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
  59806. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59807. * * 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
  59808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59810. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59812. * @param name defines the name of the mesh
  59813. * @param options defines the options used to create the mesh
  59814. * @param scene defines the hosting scene
  59815. * @returns the lathe mesh
  59816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59817. */
  59818. static CreateLathe(name: string, options: {
  59819. shape: Vector3[];
  59820. radius?: number;
  59821. tessellation?: number;
  59822. clip?: number;
  59823. arc?: number;
  59824. closed?: boolean;
  59825. updatable?: boolean;
  59826. sideOrientation?: number;
  59827. frontUVs?: Vector4;
  59828. backUVs?: Vector4;
  59829. cap?: number;
  59830. invertUV?: boolean;
  59831. }, scene?: Nullable<Scene>): Mesh;
  59832. }
  59833. }
  59834. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59835. import { Nullable } from "babylonjs/types";
  59836. import { Scene } from "babylonjs/scene";
  59837. import { Vector4 } from "babylonjs/Maths/math.vector";
  59838. import { Mesh } from "babylonjs/Meshes/mesh";
  59839. /**
  59840. * Class containing static functions to help procedurally build meshes
  59841. */
  59842. export class TiledPlaneBuilder {
  59843. /**
  59844. * Creates a tiled plane mesh
  59845. * * The parameter `pattern` will, depending on value, do nothing or
  59846. * * * flip (reflect about central vertical) alternate tiles across and up
  59847. * * * flip every tile on alternate rows
  59848. * * * rotate (180 degs) alternate tiles across and up
  59849. * * * rotate every tile on alternate rows
  59850. * * * flip and rotate alternate tiles across and up
  59851. * * * flip and rotate every tile on alternate rows
  59852. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59853. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59855. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59856. * * 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)
  59857. * * 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)
  59858. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59859. * @param name defines the name of the mesh
  59860. * @param options defines the options used to create the mesh
  59861. * @param scene defines the hosting scene
  59862. * @returns the box mesh
  59863. */
  59864. static CreateTiledPlane(name: string, options: {
  59865. pattern?: number;
  59866. tileSize?: number;
  59867. tileWidth?: number;
  59868. tileHeight?: number;
  59869. size?: number;
  59870. width?: number;
  59871. height?: number;
  59872. alignHorizontal?: number;
  59873. alignVertical?: number;
  59874. sideOrientation?: number;
  59875. frontUVs?: Vector4;
  59876. backUVs?: Vector4;
  59877. updatable?: boolean;
  59878. }, scene?: Nullable<Scene>): Mesh;
  59879. }
  59880. }
  59881. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59882. import { Nullable } from "babylonjs/types";
  59883. import { Scene } from "babylonjs/scene";
  59884. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59885. import { Mesh } from "babylonjs/Meshes/mesh";
  59886. /**
  59887. * Class containing static functions to help procedurally build meshes
  59888. */
  59889. export class TubeBuilder {
  59890. /**
  59891. * Creates a tube mesh.
  59892. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59893. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59894. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59895. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59896. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59897. * * 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)
  59898. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59899. * * 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
  59900. * * 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
  59901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59903. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59905. * @param name defines the name of the mesh
  59906. * @param options defines the options used to create the mesh
  59907. * @param scene defines the hosting scene
  59908. * @returns the tube mesh
  59909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59910. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59911. */
  59912. static CreateTube(name: string, options: {
  59913. path: Vector3[];
  59914. radius?: number;
  59915. tessellation?: number;
  59916. radiusFunction?: {
  59917. (i: number, distance: number): number;
  59918. };
  59919. cap?: number;
  59920. arc?: number;
  59921. updatable?: boolean;
  59922. sideOrientation?: number;
  59923. frontUVs?: Vector4;
  59924. backUVs?: Vector4;
  59925. instance?: Mesh;
  59926. invertUV?: boolean;
  59927. }, scene?: Nullable<Scene>): Mesh;
  59928. }
  59929. }
  59930. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59931. import { Scene } from "babylonjs/scene";
  59932. import { Vector4 } from "babylonjs/Maths/math.vector";
  59933. import { Mesh } from "babylonjs/Meshes/mesh";
  59934. import { Nullable } from "babylonjs/types";
  59935. /**
  59936. * Class containing static functions to help procedurally build meshes
  59937. */
  59938. export class IcoSphereBuilder {
  59939. /**
  59940. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59941. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59942. * * 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`)
  59943. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59944. * * 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
  59945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59948. * @param name defines the name of the mesh
  59949. * @param options defines the options used to create the mesh
  59950. * @param scene defines the hosting scene
  59951. * @returns the icosahedron mesh
  59952. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59953. */
  59954. static CreateIcoSphere(name: string, options: {
  59955. radius?: number;
  59956. radiusX?: number;
  59957. radiusY?: number;
  59958. radiusZ?: number;
  59959. flat?: boolean;
  59960. subdivisions?: number;
  59961. sideOrientation?: number;
  59962. frontUVs?: Vector4;
  59963. backUVs?: Vector4;
  59964. updatable?: boolean;
  59965. }, scene?: Nullable<Scene>): Mesh;
  59966. }
  59967. }
  59968. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59969. import { Vector3 } from "babylonjs/Maths/math.vector";
  59970. import { Mesh } from "babylonjs/Meshes/mesh";
  59971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59972. /**
  59973. * Class containing static functions to help procedurally build meshes
  59974. */
  59975. export class DecalBuilder {
  59976. /**
  59977. * Creates a decal mesh.
  59978. * 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
  59979. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59980. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59981. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59982. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59983. * @param name defines the name of the mesh
  59984. * @param sourceMesh defines the mesh where the decal must be applied
  59985. * @param options defines the options used to create the mesh
  59986. * @param scene defines the hosting scene
  59987. * @returns the decal mesh
  59988. * @see https://doc.babylonjs.com/how_to/decals
  59989. */
  59990. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59991. position?: Vector3;
  59992. normal?: Vector3;
  59993. size?: Vector3;
  59994. angle?: number;
  59995. }): Mesh;
  59996. }
  59997. }
  59998. declare module "babylonjs/Meshes/meshBuilder" {
  59999. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60000. import { Nullable } from "babylonjs/types";
  60001. import { Scene } from "babylonjs/scene";
  60002. import { Mesh } from "babylonjs/Meshes/mesh";
  60003. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60004. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60006. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60007. import { Plane } from "babylonjs/Maths/math.plane";
  60008. /**
  60009. * Class containing static functions to help procedurally build meshes
  60010. */
  60011. export class MeshBuilder {
  60012. /**
  60013. * Creates a box mesh
  60014. * * The parameter `size` sets the size (float) of each box side (default 1)
  60015. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60016. * * 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)
  60017. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60021. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60022. * @param name defines the name of the mesh
  60023. * @param options defines the options used to create the mesh
  60024. * @param scene defines the hosting scene
  60025. * @returns the box mesh
  60026. */
  60027. static CreateBox(name: string, options: {
  60028. size?: number;
  60029. width?: number;
  60030. height?: number;
  60031. depth?: number;
  60032. faceUV?: Vector4[];
  60033. faceColors?: Color4[];
  60034. sideOrientation?: number;
  60035. frontUVs?: Vector4;
  60036. backUVs?: Vector4;
  60037. updatable?: boolean;
  60038. }, scene?: Nullable<Scene>): Mesh;
  60039. /**
  60040. * Creates a tiled box mesh
  60041. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60043. * @param name defines the name of the mesh
  60044. * @param options defines the options used to create the mesh
  60045. * @param scene defines the hosting scene
  60046. * @returns the tiled box mesh
  60047. */
  60048. static CreateTiledBox(name: string, options: {
  60049. pattern?: number;
  60050. size?: number;
  60051. width?: number;
  60052. height?: number;
  60053. depth: number;
  60054. tileSize?: number;
  60055. tileWidth?: number;
  60056. tileHeight?: number;
  60057. faceUV?: Vector4[];
  60058. faceColors?: Color4[];
  60059. alignHorizontal?: number;
  60060. alignVertical?: number;
  60061. sideOrientation?: number;
  60062. updatable?: boolean;
  60063. }, scene?: Nullable<Scene>): Mesh;
  60064. /**
  60065. * Creates a sphere mesh
  60066. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60067. * * 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`)
  60068. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60069. * * 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
  60070. * * 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)
  60071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60074. * @param name defines the name of the mesh
  60075. * @param options defines the options used to create the mesh
  60076. * @param scene defines the hosting scene
  60077. * @returns the sphere mesh
  60078. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60079. */
  60080. static CreateSphere(name: string, options: {
  60081. segments?: number;
  60082. diameter?: number;
  60083. diameterX?: number;
  60084. diameterY?: number;
  60085. diameterZ?: number;
  60086. arc?: number;
  60087. slice?: number;
  60088. sideOrientation?: number;
  60089. frontUVs?: Vector4;
  60090. backUVs?: Vector4;
  60091. updatable?: boolean;
  60092. }, scene?: Nullable<Scene>): Mesh;
  60093. /**
  60094. * Creates a plane polygonal mesh. By default, this is a disc
  60095. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60096. * * 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
  60097. * * 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
  60098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60101. * @param name defines the name of the mesh
  60102. * @param options defines the options used to create the mesh
  60103. * @param scene defines the hosting scene
  60104. * @returns the plane polygonal mesh
  60105. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60106. */
  60107. static CreateDisc(name: string, options: {
  60108. radius?: number;
  60109. tessellation?: number;
  60110. arc?: number;
  60111. updatable?: boolean;
  60112. sideOrientation?: number;
  60113. frontUVs?: Vector4;
  60114. backUVs?: Vector4;
  60115. }, scene?: Nullable<Scene>): Mesh;
  60116. /**
  60117. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60118. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60119. * * 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`)
  60120. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60121. * * 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
  60122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60125. * @param name defines the name of the mesh
  60126. * @param options defines the options used to create the mesh
  60127. * @param scene defines the hosting scene
  60128. * @returns the icosahedron mesh
  60129. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60130. */
  60131. static CreateIcoSphere(name: string, options: {
  60132. radius?: number;
  60133. radiusX?: number;
  60134. radiusY?: number;
  60135. radiusZ?: number;
  60136. flat?: boolean;
  60137. subdivisions?: number;
  60138. sideOrientation?: number;
  60139. frontUVs?: Vector4;
  60140. backUVs?: Vector4;
  60141. updatable?: boolean;
  60142. }, scene?: Nullable<Scene>): Mesh;
  60143. /**
  60144. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60145. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60146. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60147. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60148. * * 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
  60149. * * 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
  60150. * * 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
  60151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60154. * * 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
  60155. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60156. * * 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
  60157. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60159. * @param name defines the name of the mesh
  60160. * @param options defines the options used to create the mesh
  60161. * @param scene defines the hosting scene
  60162. * @returns the ribbon mesh
  60163. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60164. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60165. */
  60166. static CreateRibbon(name: string, options: {
  60167. pathArray: Vector3[][];
  60168. closeArray?: boolean;
  60169. closePath?: boolean;
  60170. offset?: number;
  60171. updatable?: boolean;
  60172. sideOrientation?: number;
  60173. frontUVs?: Vector4;
  60174. backUVs?: Vector4;
  60175. instance?: Mesh;
  60176. invertUV?: boolean;
  60177. uvs?: Vector2[];
  60178. colors?: Color4[];
  60179. }, scene?: Nullable<Scene>): Mesh;
  60180. /**
  60181. * Creates a cylinder or a cone mesh
  60182. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60183. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60184. * * 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.
  60185. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60186. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60187. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60188. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60189. * * 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).
  60190. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60191. * * 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).
  60192. * * 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
  60193. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60194. * * 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
  60195. * * 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.
  60196. * * If `enclose` is false, a ring surface is one element.
  60197. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60198. * * 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
  60199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60202. * @param name defines the name of the mesh
  60203. * @param options defines the options used to create the mesh
  60204. * @param scene defines the hosting scene
  60205. * @returns the cylinder mesh
  60206. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60207. */
  60208. static CreateCylinder(name: string, options: {
  60209. height?: number;
  60210. diameterTop?: number;
  60211. diameterBottom?: number;
  60212. diameter?: number;
  60213. tessellation?: number;
  60214. subdivisions?: number;
  60215. arc?: number;
  60216. faceColors?: Color4[];
  60217. faceUV?: Vector4[];
  60218. updatable?: boolean;
  60219. hasRings?: boolean;
  60220. enclose?: boolean;
  60221. cap?: number;
  60222. sideOrientation?: number;
  60223. frontUVs?: Vector4;
  60224. backUVs?: Vector4;
  60225. }, scene?: Nullable<Scene>): Mesh;
  60226. /**
  60227. * Creates a torus mesh
  60228. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60229. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60230. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60234. * @param name defines the name of the mesh
  60235. * @param options defines the options used to create the mesh
  60236. * @param scene defines the hosting scene
  60237. * @returns the torus mesh
  60238. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60239. */
  60240. static CreateTorus(name: string, options: {
  60241. diameter?: number;
  60242. thickness?: number;
  60243. tessellation?: number;
  60244. updatable?: boolean;
  60245. sideOrientation?: number;
  60246. frontUVs?: Vector4;
  60247. backUVs?: Vector4;
  60248. }, scene?: Nullable<Scene>): Mesh;
  60249. /**
  60250. * Creates a torus knot mesh
  60251. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60252. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60253. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60254. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60258. * @param name defines the name of the mesh
  60259. * @param options defines the options used to create the mesh
  60260. * @param scene defines the hosting scene
  60261. * @returns the torus knot mesh
  60262. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60263. */
  60264. static CreateTorusKnot(name: string, options: {
  60265. radius?: number;
  60266. tube?: number;
  60267. radialSegments?: number;
  60268. tubularSegments?: number;
  60269. p?: number;
  60270. q?: number;
  60271. updatable?: boolean;
  60272. sideOrientation?: number;
  60273. frontUVs?: Vector4;
  60274. backUVs?: Vector4;
  60275. }, scene?: Nullable<Scene>): Mesh;
  60276. /**
  60277. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60278. * * 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
  60279. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60280. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60281. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60282. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60283. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60284. * * 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
  60285. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60288. * @param name defines the name of the new line system
  60289. * @param options defines the options used to create the line system
  60290. * @param scene defines the hosting scene
  60291. * @returns a new line system mesh
  60292. */
  60293. static CreateLineSystem(name: string, options: {
  60294. lines: Vector3[][];
  60295. updatable?: boolean;
  60296. instance?: Nullable<LinesMesh>;
  60297. colors?: Nullable<Color4[][]>;
  60298. useVertexAlpha?: boolean;
  60299. }, scene: Nullable<Scene>): LinesMesh;
  60300. /**
  60301. * Creates a line mesh
  60302. * 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
  60303. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60304. * * The parameter `points` is an array successive Vector3
  60305. * * 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
  60306. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60307. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60308. * * When updating an instance, remember that only point positions can change, not the number of points
  60309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60310. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60311. * @param name defines the name of the new line system
  60312. * @param options defines the options used to create the line system
  60313. * @param scene defines the hosting scene
  60314. * @returns a new line mesh
  60315. */
  60316. static CreateLines(name: string, options: {
  60317. points: Vector3[];
  60318. updatable?: boolean;
  60319. instance?: Nullable<LinesMesh>;
  60320. colors?: Color4[];
  60321. useVertexAlpha?: boolean;
  60322. }, scene?: Nullable<Scene>): LinesMesh;
  60323. /**
  60324. * Creates a dashed line mesh
  60325. * * 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
  60326. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60327. * * The parameter `points` is an array successive Vector3
  60328. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60329. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60330. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60331. * * 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
  60332. * * When updating an instance, remember that only point positions can change, not the number of points
  60333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60334. * @param name defines the name of the mesh
  60335. * @param options defines the options used to create the mesh
  60336. * @param scene defines the hosting scene
  60337. * @returns the dashed line mesh
  60338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60339. */
  60340. static CreateDashedLines(name: string, options: {
  60341. points: Vector3[];
  60342. dashSize?: number;
  60343. gapSize?: number;
  60344. dashNb?: number;
  60345. updatable?: boolean;
  60346. instance?: LinesMesh;
  60347. }, scene?: Nullable<Scene>): LinesMesh;
  60348. /**
  60349. * 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.
  60350. * * 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.
  60351. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60352. * * 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.
  60353. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60354. * * 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
  60355. * * 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
  60356. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60361. * @param name defines the name of the mesh
  60362. * @param options defines the options used to create the mesh
  60363. * @param scene defines the hosting scene
  60364. * @returns the extruded shape mesh
  60365. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60367. */
  60368. static ExtrudeShape(name: string, options: {
  60369. shape: Vector3[];
  60370. path: Vector3[];
  60371. scale?: number;
  60372. rotation?: number;
  60373. cap?: number;
  60374. updatable?: boolean;
  60375. sideOrientation?: number;
  60376. frontUVs?: Vector4;
  60377. backUVs?: Vector4;
  60378. instance?: Mesh;
  60379. invertUV?: boolean;
  60380. }, scene?: Nullable<Scene>): Mesh;
  60381. /**
  60382. * Creates an custom extruded shape mesh.
  60383. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60384. * * 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.
  60385. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60386. * * 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
  60387. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60388. * * 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
  60389. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60390. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60391. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60392. * * 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
  60393. * * 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
  60394. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60399. * @param name defines the name of the mesh
  60400. * @param options defines the options used to create the mesh
  60401. * @param scene defines the hosting scene
  60402. * @returns the custom extruded shape mesh
  60403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60404. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60406. */
  60407. static ExtrudeShapeCustom(name: string, options: {
  60408. shape: Vector3[];
  60409. path: Vector3[];
  60410. scaleFunction?: any;
  60411. rotationFunction?: any;
  60412. ribbonCloseArray?: boolean;
  60413. ribbonClosePath?: boolean;
  60414. cap?: number;
  60415. updatable?: boolean;
  60416. sideOrientation?: number;
  60417. frontUVs?: Vector4;
  60418. backUVs?: Vector4;
  60419. instance?: Mesh;
  60420. invertUV?: boolean;
  60421. }, scene?: Nullable<Scene>): Mesh;
  60422. /**
  60423. * Creates lathe mesh.
  60424. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60425. * * 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
  60426. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60427. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60428. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60429. * * 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
  60430. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60431. * * 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
  60432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60434. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60436. * @param name defines the name of the mesh
  60437. * @param options defines the options used to create the mesh
  60438. * @param scene defines the hosting scene
  60439. * @returns the lathe mesh
  60440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60441. */
  60442. static CreateLathe(name: string, options: {
  60443. shape: Vector3[];
  60444. radius?: number;
  60445. tessellation?: number;
  60446. clip?: number;
  60447. arc?: number;
  60448. closed?: boolean;
  60449. updatable?: boolean;
  60450. sideOrientation?: number;
  60451. frontUVs?: Vector4;
  60452. backUVs?: Vector4;
  60453. cap?: number;
  60454. invertUV?: boolean;
  60455. }, scene?: Nullable<Scene>): Mesh;
  60456. /**
  60457. * Creates a tiled plane mesh
  60458. * * You can set a limited pattern arrangement with the tiles
  60459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60462. * @param name defines the name of the mesh
  60463. * @param options defines the options used to create the mesh
  60464. * @param scene defines the hosting scene
  60465. * @returns the plane mesh
  60466. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60467. */
  60468. static CreateTiledPlane(name: string, options: {
  60469. pattern?: number;
  60470. tileSize?: number;
  60471. tileWidth?: number;
  60472. tileHeight?: number;
  60473. size?: number;
  60474. width?: number;
  60475. height?: number;
  60476. alignHorizontal?: number;
  60477. alignVertical?: number;
  60478. sideOrientation?: number;
  60479. frontUVs?: Vector4;
  60480. backUVs?: Vector4;
  60481. updatable?: boolean;
  60482. }, scene?: Nullable<Scene>): Mesh;
  60483. /**
  60484. * Creates a plane mesh
  60485. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60486. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60487. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60491. * @param name defines the name of the mesh
  60492. * @param options defines the options used to create the mesh
  60493. * @param scene defines the hosting scene
  60494. * @returns the plane mesh
  60495. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60496. */
  60497. static CreatePlane(name: string, options: {
  60498. size?: number;
  60499. width?: number;
  60500. height?: number;
  60501. sideOrientation?: number;
  60502. frontUVs?: Vector4;
  60503. backUVs?: Vector4;
  60504. updatable?: boolean;
  60505. sourcePlane?: Plane;
  60506. }, scene?: Nullable<Scene>): Mesh;
  60507. /**
  60508. * Creates a ground mesh
  60509. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60510. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60512. * @param name defines the name of the mesh
  60513. * @param options defines the options used to create the mesh
  60514. * @param scene defines the hosting scene
  60515. * @returns the ground mesh
  60516. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60517. */
  60518. static CreateGround(name: string, options: {
  60519. width?: number;
  60520. height?: number;
  60521. subdivisions?: number;
  60522. subdivisionsX?: number;
  60523. subdivisionsY?: number;
  60524. updatable?: boolean;
  60525. }, scene?: Nullable<Scene>): Mesh;
  60526. /**
  60527. * Creates a tiled ground mesh
  60528. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60529. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60530. * * 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
  60531. * * 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
  60532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60533. * @param name defines the name of the mesh
  60534. * @param options defines the options used to create the mesh
  60535. * @param scene defines the hosting scene
  60536. * @returns the tiled ground mesh
  60537. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60538. */
  60539. static CreateTiledGround(name: string, options: {
  60540. xmin: number;
  60541. zmin: number;
  60542. xmax: number;
  60543. zmax: number;
  60544. subdivisions?: {
  60545. w: number;
  60546. h: number;
  60547. };
  60548. precision?: {
  60549. w: number;
  60550. h: number;
  60551. };
  60552. updatable?: boolean;
  60553. }, scene?: Nullable<Scene>): Mesh;
  60554. /**
  60555. * Creates a ground mesh from a height map
  60556. * * The parameter `url` sets the URL of the height map image resource.
  60557. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60558. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60559. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60560. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60561. * * 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.
  60562. * * 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).
  60563. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60565. * @param name defines the name of the mesh
  60566. * @param url defines the url to the height map
  60567. * @param options defines the options used to create the mesh
  60568. * @param scene defines the hosting scene
  60569. * @returns the ground mesh
  60570. * @see https://doc.babylonjs.com/babylon101/height_map
  60571. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60572. */
  60573. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60574. width?: number;
  60575. height?: number;
  60576. subdivisions?: number;
  60577. minHeight?: number;
  60578. maxHeight?: number;
  60579. colorFilter?: Color3;
  60580. alphaFilter?: number;
  60581. updatable?: boolean;
  60582. onReady?: (mesh: GroundMesh) => void;
  60583. }, scene?: Nullable<Scene>): GroundMesh;
  60584. /**
  60585. * Creates a polygon mesh
  60586. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60587. * * 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
  60588. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60591. * * Remember you can only change the shape positions, not their number when updating a polygon
  60592. * @param name defines the name of the mesh
  60593. * @param options defines the options used to create the mesh
  60594. * @param scene defines the hosting scene
  60595. * @param earcutInjection can be used to inject your own earcut reference
  60596. * @returns the polygon mesh
  60597. */
  60598. static CreatePolygon(name: string, options: {
  60599. shape: Vector3[];
  60600. holes?: Vector3[][];
  60601. depth?: number;
  60602. faceUV?: Vector4[];
  60603. faceColors?: Color4[];
  60604. updatable?: boolean;
  60605. sideOrientation?: number;
  60606. frontUVs?: Vector4;
  60607. backUVs?: Vector4;
  60608. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60609. /**
  60610. * Creates an extruded polygon mesh, with depth in the Y direction.
  60611. * * 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)
  60612. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60613. * @param name defines the name of the mesh
  60614. * @param options defines the options used to create the mesh
  60615. * @param scene defines the hosting scene
  60616. * @param earcutInjection can be used to inject your own earcut reference
  60617. * @returns the polygon mesh
  60618. */
  60619. static ExtrudePolygon(name: string, options: {
  60620. shape: Vector3[];
  60621. holes?: Vector3[][];
  60622. depth?: number;
  60623. faceUV?: Vector4[];
  60624. faceColors?: Color4[];
  60625. updatable?: boolean;
  60626. sideOrientation?: number;
  60627. frontUVs?: Vector4;
  60628. backUVs?: Vector4;
  60629. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60630. /**
  60631. * Creates a tube mesh.
  60632. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60633. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60634. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60635. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60636. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60637. * * 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)
  60638. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60639. * * 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
  60640. * * 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
  60641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60643. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60645. * @param name defines the name of the mesh
  60646. * @param options defines the options used to create the mesh
  60647. * @param scene defines the hosting scene
  60648. * @returns the tube mesh
  60649. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60650. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60651. */
  60652. static CreateTube(name: string, options: {
  60653. path: Vector3[];
  60654. radius?: number;
  60655. tessellation?: number;
  60656. radiusFunction?: {
  60657. (i: number, distance: number): number;
  60658. };
  60659. cap?: number;
  60660. arc?: number;
  60661. updatable?: boolean;
  60662. sideOrientation?: number;
  60663. frontUVs?: Vector4;
  60664. backUVs?: Vector4;
  60665. instance?: Mesh;
  60666. invertUV?: boolean;
  60667. }, scene?: Nullable<Scene>): Mesh;
  60668. /**
  60669. * Creates a polyhedron mesh
  60670. * * 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
  60671. * * The parameter `size` (positive float, default 1) sets the polygon size
  60672. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60673. * * 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`
  60674. * * 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
  60675. * * 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)`)
  60676. * * 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
  60677. * * 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
  60678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60681. * @param name defines the name of the mesh
  60682. * @param options defines the options used to create the mesh
  60683. * @param scene defines the hosting scene
  60684. * @returns the polyhedron mesh
  60685. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60686. */
  60687. static CreatePolyhedron(name: string, options: {
  60688. type?: number;
  60689. size?: number;
  60690. sizeX?: number;
  60691. sizeY?: number;
  60692. sizeZ?: number;
  60693. custom?: any;
  60694. faceUV?: Vector4[];
  60695. faceColors?: Color4[];
  60696. flat?: boolean;
  60697. updatable?: boolean;
  60698. sideOrientation?: number;
  60699. frontUVs?: Vector4;
  60700. backUVs?: Vector4;
  60701. }, scene?: Nullable<Scene>): Mesh;
  60702. /**
  60703. * Creates a decal mesh.
  60704. * 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
  60705. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60706. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60707. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60708. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60709. * @param name defines the name of the mesh
  60710. * @param sourceMesh defines the mesh where the decal must be applied
  60711. * @param options defines the options used to create the mesh
  60712. * @param scene defines the hosting scene
  60713. * @returns the decal mesh
  60714. * @see https://doc.babylonjs.com/how_to/decals
  60715. */
  60716. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60717. position?: Vector3;
  60718. normal?: Vector3;
  60719. size?: Vector3;
  60720. angle?: number;
  60721. }): Mesh;
  60722. }
  60723. }
  60724. declare module "babylonjs/Meshes/meshSimplification" {
  60725. import { Mesh } from "babylonjs/Meshes/mesh";
  60726. /**
  60727. * A simplifier interface for future simplification implementations
  60728. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60729. */
  60730. export interface ISimplifier {
  60731. /**
  60732. * Simplification of a given mesh according to the given settings.
  60733. * Since this requires computation, it is assumed that the function runs async.
  60734. * @param settings The settings of the simplification, including quality and distance
  60735. * @param successCallback A callback that will be called after the mesh was simplified.
  60736. * @param errorCallback in case of an error, this callback will be called. optional.
  60737. */
  60738. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60739. }
  60740. /**
  60741. * Expected simplification settings.
  60742. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60743. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60744. */
  60745. export interface ISimplificationSettings {
  60746. /**
  60747. * Gets or sets the expected quality
  60748. */
  60749. quality: number;
  60750. /**
  60751. * Gets or sets the distance when this optimized version should be used
  60752. */
  60753. distance: number;
  60754. /**
  60755. * Gets an already optimized mesh
  60756. */
  60757. optimizeMesh?: boolean;
  60758. }
  60759. /**
  60760. * Class used to specify simplification options
  60761. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60762. */
  60763. export class SimplificationSettings implements ISimplificationSettings {
  60764. /** expected quality */
  60765. quality: number;
  60766. /** distance when this optimized version should be used */
  60767. distance: number;
  60768. /** already optimized mesh */
  60769. optimizeMesh?: boolean | undefined;
  60770. /**
  60771. * Creates a SimplificationSettings
  60772. * @param quality expected quality
  60773. * @param distance distance when this optimized version should be used
  60774. * @param optimizeMesh already optimized mesh
  60775. */
  60776. constructor(
  60777. /** expected quality */
  60778. quality: number,
  60779. /** distance when this optimized version should be used */
  60780. distance: number,
  60781. /** already optimized mesh */
  60782. optimizeMesh?: boolean | undefined);
  60783. }
  60784. /**
  60785. * Interface used to define a simplification task
  60786. */
  60787. export interface ISimplificationTask {
  60788. /**
  60789. * Array of settings
  60790. */
  60791. settings: Array<ISimplificationSettings>;
  60792. /**
  60793. * Simplification type
  60794. */
  60795. simplificationType: SimplificationType;
  60796. /**
  60797. * Mesh to simplify
  60798. */
  60799. mesh: Mesh;
  60800. /**
  60801. * Callback called on success
  60802. */
  60803. successCallback?: () => void;
  60804. /**
  60805. * Defines if parallel processing can be used
  60806. */
  60807. parallelProcessing: boolean;
  60808. }
  60809. /**
  60810. * Queue used to order the simplification tasks
  60811. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60812. */
  60813. export class SimplificationQueue {
  60814. private _simplificationArray;
  60815. /**
  60816. * Gets a boolean indicating that the process is still running
  60817. */
  60818. running: boolean;
  60819. /**
  60820. * Creates a new queue
  60821. */
  60822. constructor();
  60823. /**
  60824. * Adds a new simplification task
  60825. * @param task defines a task to add
  60826. */
  60827. addTask(task: ISimplificationTask): void;
  60828. /**
  60829. * Execute next task
  60830. */
  60831. executeNext(): void;
  60832. /**
  60833. * Execute a simplification task
  60834. * @param task defines the task to run
  60835. */
  60836. runSimplification(task: ISimplificationTask): void;
  60837. private getSimplifier;
  60838. }
  60839. /**
  60840. * The implemented types of simplification
  60841. * At the moment only Quadratic Error Decimation is implemented
  60842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60843. */
  60844. export enum SimplificationType {
  60845. /** Quadratic error decimation */
  60846. QUADRATIC = 0
  60847. }
  60848. }
  60849. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60850. import { Scene } from "babylonjs/scene";
  60851. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60852. import { ISceneComponent } from "babylonjs/sceneComponent";
  60853. module "babylonjs/scene" {
  60854. interface Scene {
  60855. /** @hidden (Backing field) */
  60856. _simplificationQueue: SimplificationQueue;
  60857. /**
  60858. * Gets or sets the simplification queue attached to the scene
  60859. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60860. */
  60861. simplificationQueue: SimplificationQueue;
  60862. }
  60863. }
  60864. module "babylonjs/Meshes/mesh" {
  60865. interface Mesh {
  60866. /**
  60867. * Simplify the mesh according to the given array of settings.
  60868. * Function will return immediately and will simplify async
  60869. * @param settings a collection of simplification settings
  60870. * @param parallelProcessing should all levels calculate parallel or one after the other
  60871. * @param simplificationType the type of simplification to run
  60872. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60873. * @returns the current mesh
  60874. */
  60875. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60876. }
  60877. }
  60878. /**
  60879. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60880. * created in a scene
  60881. */
  60882. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60883. /**
  60884. * The component name helpfull to identify the component in the list of scene components.
  60885. */
  60886. readonly name: string;
  60887. /**
  60888. * The scene the component belongs to.
  60889. */
  60890. scene: Scene;
  60891. /**
  60892. * Creates a new instance of the component for the given scene
  60893. * @param scene Defines the scene to register the component in
  60894. */
  60895. constructor(scene: Scene);
  60896. /**
  60897. * Registers the component in a given scene
  60898. */
  60899. register(): void;
  60900. /**
  60901. * Rebuilds the elements related to this component in case of
  60902. * context lost for instance.
  60903. */
  60904. rebuild(): void;
  60905. /**
  60906. * Disposes the component and the associated ressources
  60907. */
  60908. dispose(): void;
  60909. private _beforeCameraUpdate;
  60910. }
  60911. }
  60912. declare module "babylonjs/Meshes/Builders/index" {
  60913. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60914. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60915. export * from "babylonjs/Meshes/Builders/discBuilder";
  60916. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60917. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60918. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60919. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60920. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60921. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60922. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60923. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60924. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60925. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60926. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60927. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60928. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60929. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60930. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60931. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60932. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60933. }
  60934. declare module "babylonjs/Meshes/index" {
  60935. export * from "babylonjs/Meshes/abstractMesh";
  60936. export * from "babylonjs/Meshes/buffer";
  60937. export * from "babylonjs/Meshes/Compression/index";
  60938. export * from "babylonjs/Meshes/csg";
  60939. export * from "babylonjs/Meshes/geometry";
  60940. export * from "babylonjs/Meshes/groundMesh";
  60941. export * from "babylonjs/Meshes/trailMesh";
  60942. export * from "babylonjs/Meshes/instancedMesh";
  60943. export * from "babylonjs/Meshes/linesMesh";
  60944. export * from "babylonjs/Meshes/mesh";
  60945. export * from "babylonjs/Meshes/mesh.vertexData";
  60946. export * from "babylonjs/Meshes/meshBuilder";
  60947. export * from "babylonjs/Meshes/meshSimplification";
  60948. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60949. export * from "babylonjs/Meshes/polygonMesh";
  60950. export * from "babylonjs/Meshes/subMesh";
  60951. export * from "babylonjs/Meshes/meshLODLevel";
  60952. export * from "babylonjs/Meshes/transformNode";
  60953. export * from "babylonjs/Meshes/Builders/index";
  60954. export * from "babylonjs/Meshes/dataBuffer";
  60955. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60956. }
  60957. declare module "babylonjs/Morph/index" {
  60958. export * from "babylonjs/Morph/morphTarget";
  60959. export * from "babylonjs/Morph/morphTargetManager";
  60960. }
  60961. declare module "babylonjs/Navigation/INavigationEngine" {
  60962. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60963. import { Vector3 } from "babylonjs/Maths/math";
  60964. import { Mesh } from "babylonjs/Meshes/mesh";
  60965. import { Scene } from "babylonjs/scene";
  60966. /**
  60967. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60968. */
  60969. export interface INavigationEnginePlugin {
  60970. /**
  60971. * plugin name
  60972. */
  60973. name: string;
  60974. /**
  60975. * Creates a navigation mesh
  60976. * @param meshes array of all the geometry used to compute the navigatio mesh
  60977. * @param parameters bunch of parameters used to filter geometry
  60978. */
  60979. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60980. /**
  60981. * Create a navigation mesh debug mesh
  60982. * @param scene is where the mesh will be added
  60983. * @returns debug display mesh
  60984. */
  60985. createDebugNavMesh(scene: Scene): Mesh;
  60986. /**
  60987. * Get a navigation mesh constrained position, closest to the parameter position
  60988. * @param position world position
  60989. * @returns the closest point to position constrained by the navigation mesh
  60990. */
  60991. getClosestPoint(position: Vector3): Vector3;
  60992. /**
  60993. * Get a navigation mesh constrained position, within a particular radius
  60994. * @param position world position
  60995. * @param maxRadius the maximum distance to the constrained world position
  60996. * @returns the closest point to position constrained by the navigation mesh
  60997. */
  60998. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60999. /**
  61000. * Compute the final position from a segment made of destination-position
  61001. * @param position world position
  61002. * @param destination world position
  61003. * @returns the resulting point along the navmesh
  61004. */
  61005. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61006. /**
  61007. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61008. * @param start world position
  61009. * @param end world position
  61010. * @returns array containing world position composing the path
  61011. */
  61012. computePath(start: Vector3, end: Vector3): Vector3[];
  61013. /**
  61014. * If this plugin is supported
  61015. * @returns true if plugin is supported
  61016. */
  61017. isSupported(): boolean;
  61018. /**
  61019. * Create a new Crowd so you can add agents
  61020. * @param maxAgents the maximum agent count in the crowd
  61021. * @param maxAgentRadius the maximum radius an agent can have
  61022. * @param scene to attach the crowd to
  61023. * @returns the crowd you can add agents to
  61024. */
  61025. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61026. /**
  61027. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61028. * The queries will try to find a solution within those bounds
  61029. * default is (1,1,1)
  61030. * @param extent x,y,z value that define the extent around the queries point of reference
  61031. */
  61032. setDefaultQueryExtent(extent: Vector3): void;
  61033. /**
  61034. * Get the Bounding box extent specified by setDefaultQueryExtent
  61035. * @returns the box extent values
  61036. */
  61037. getDefaultQueryExtent(): Vector3;
  61038. /**
  61039. * Release all resources
  61040. */
  61041. dispose(): void;
  61042. }
  61043. /**
  61044. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61045. */
  61046. export interface ICrowd {
  61047. /**
  61048. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61049. * You can attach anything to that node. The node position is updated in the scene update tick.
  61050. * @param pos world position that will be constrained by the navigation mesh
  61051. * @param parameters agent parameters
  61052. * @param transform hooked to the agent that will be update by the scene
  61053. * @returns agent index
  61054. */
  61055. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61056. /**
  61057. * Returns the agent position in world space
  61058. * @param index agent index returned by addAgent
  61059. * @returns world space position
  61060. */
  61061. getAgentPosition(index: number): Vector3;
  61062. /**
  61063. * Gets the agent velocity in world space
  61064. * @param index agent index returned by addAgent
  61065. * @returns world space velocity
  61066. */
  61067. getAgentVelocity(index: number): Vector3;
  61068. /**
  61069. * remove a particular agent previously created
  61070. * @param index agent index returned by addAgent
  61071. */
  61072. removeAgent(index: number): void;
  61073. /**
  61074. * get the list of all agents attached to this crowd
  61075. * @returns list of agent indices
  61076. */
  61077. getAgents(): number[];
  61078. /**
  61079. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61080. * @param deltaTime in seconds
  61081. */
  61082. update(deltaTime: number): void;
  61083. /**
  61084. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61085. * @param index agent index returned by addAgent
  61086. * @param destination targeted world position
  61087. */
  61088. agentGoto(index: number, destination: Vector3): void;
  61089. /**
  61090. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61091. * The queries will try to find a solution within those bounds
  61092. * default is (1,1,1)
  61093. * @param extent x,y,z value that define the extent around the queries point of reference
  61094. */
  61095. setDefaultQueryExtent(extent: Vector3): void;
  61096. /**
  61097. * Get the Bounding box extent specified by setDefaultQueryExtent
  61098. * @returns the box extent values
  61099. */
  61100. getDefaultQueryExtent(): Vector3;
  61101. /**
  61102. * Release all resources
  61103. */
  61104. dispose(): void;
  61105. }
  61106. /**
  61107. * Configures an agent
  61108. */
  61109. export interface IAgentParameters {
  61110. /**
  61111. * Agent radius. [Limit: >= 0]
  61112. */
  61113. radius: number;
  61114. /**
  61115. * Agent height. [Limit: > 0]
  61116. */
  61117. height: number;
  61118. /**
  61119. * Maximum allowed acceleration. [Limit: >= 0]
  61120. */
  61121. maxAcceleration: number;
  61122. /**
  61123. * Maximum allowed speed. [Limit: >= 0]
  61124. */
  61125. maxSpeed: number;
  61126. /**
  61127. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61128. */
  61129. collisionQueryRange: number;
  61130. /**
  61131. * The path visibility optimization range. [Limit: > 0]
  61132. */
  61133. pathOptimizationRange: number;
  61134. /**
  61135. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61136. */
  61137. separationWeight: number;
  61138. }
  61139. /**
  61140. * Configures the navigation mesh creation
  61141. */
  61142. export interface INavMeshParameters {
  61143. /**
  61144. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61145. */
  61146. cs: number;
  61147. /**
  61148. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61149. */
  61150. ch: number;
  61151. /**
  61152. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61153. */
  61154. walkableSlopeAngle: number;
  61155. /**
  61156. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61157. * be considered walkable. [Limit: >= 3] [Units: vx]
  61158. */
  61159. walkableHeight: number;
  61160. /**
  61161. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61162. */
  61163. walkableClimb: number;
  61164. /**
  61165. * The distance to erode/shrink the walkable area of the heightfield away from
  61166. * obstructions. [Limit: >=0] [Units: vx]
  61167. */
  61168. walkableRadius: number;
  61169. /**
  61170. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61171. */
  61172. maxEdgeLen: number;
  61173. /**
  61174. * The maximum distance a simplfied contour's border edges should deviate
  61175. * the original raw contour. [Limit: >=0] [Units: vx]
  61176. */
  61177. maxSimplificationError: number;
  61178. /**
  61179. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61180. */
  61181. minRegionArea: number;
  61182. /**
  61183. * Any regions with a span count smaller than this value will, if possible,
  61184. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61185. */
  61186. mergeRegionArea: number;
  61187. /**
  61188. * The maximum number of vertices allowed for polygons generated during the
  61189. * contour to polygon conversion process. [Limit: >= 3]
  61190. */
  61191. maxVertsPerPoly: number;
  61192. /**
  61193. * Sets the sampling distance to use when generating the detail mesh.
  61194. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61195. */
  61196. detailSampleDist: number;
  61197. /**
  61198. * The maximum distance the detail mesh surface should deviate from heightfield
  61199. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61200. */
  61201. detailSampleMaxError: number;
  61202. }
  61203. }
  61204. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61205. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61206. import { Mesh } from "babylonjs/Meshes/mesh";
  61207. import { Scene } from "babylonjs/scene";
  61208. import { Vector3 } from "babylonjs/Maths/math";
  61209. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61210. /**
  61211. * RecastJS navigation plugin
  61212. */
  61213. export class RecastJSPlugin implements INavigationEnginePlugin {
  61214. /**
  61215. * Reference to the Recast library
  61216. */
  61217. bjsRECAST: any;
  61218. /**
  61219. * plugin name
  61220. */
  61221. name: string;
  61222. /**
  61223. * the first navmesh created. We might extend this to support multiple navmeshes
  61224. */
  61225. navMesh: any;
  61226. /**
  61227. * Initializes the recastJS plugin
  61228. * @param recastInjection can be used to inject your own recast reference
  61229. */
  61230. constructor(recastInjection?: any);
  61231. /**
  61232. * Creates a navigation mesh
  61233. * @param meshes array of all the geometry used to compute the navigatio mesh
  61234. * @param parameters bunch of parameters used to filter geometry
  61235. */
  61236. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61237. /**
  61238. * Create a navigation mesh debug mesh
  61239. * @param scene is where the mesh will be added
  61240. * @returns debug display mesh
  61241. */
  61242. createDebugNavMesh(scene: Scene): Mesh;
  61243. /**
  61244. * Get a navigation mesh constrained position, closest to the parameter position
  61245. * @param position world position
  61246. * @returns the closest point to position constrained by the navigation mesh
  61247. */
  61248. getClosestPoint(position: Vector3): Vector3;
  61249. /**
  61250. * Get a navigation mesh constrained position, within a particular radius
  61251. * @param position world position
  61252. * @param maxRadius the maximum distance to the constrained world position
  61253. * @returns the closest point to position constrained by the navigation mesh
  61254. */
  61255. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61256. /**
  61257. * Compute the final position from a segment made of destination-position
  61258. * @param position world position
  61259. * @param destination world position
  61260. * @returns the resulting point along the navmesh
  61261. */
  61262. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61263. /**
  61264. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61265. * @param start world position
  61266. * @param end world position
  61267. * @returns array containing world position composing the path
  61268. */
  61269. computePath(start: Vector3, end: Vector3): Vector3[];
  61270. /**
  61271. * Create a new Crowd so you can add agents
  61272. * @param maxAgents the maximum agent count in the crowd
  61273. * @param maxAgentRadius the maximum radius an agent can have
  61274. * @param scene to attach the crowd to
  61275. * @returns the crowd you can add agents to
  61276. */
  61277. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61278. /**
  61279. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61280. * The queries will try to find a solution within those bounds
  61281. * default is (1,1,1)
  61282. * @param extent x,y,z value that define the extent around the queries point of reference
  61283. */
  61284. setDefaultQueryExtent(extent: Vector3): void;
  61285. /**
  61286. * Get the Bounding box extent specified by setDefaultQueryExtent
  61287. * @returns the box extent values
  61288. */
  61289. getDefaultQueryExtent(): Vector3;
  61290. /**
  61291. * Disposes
  61292. */
  61293. dispose(): void;
  61294. /**
  61295. * If this plugin is supported
  61296. * @returns true if plugin is supported
  61297. */
  61298. isSupported(): boolean;
  61299. }
  61300. /**
  61301. * Recast detour crowd implementation
  61302. */
  61303. export class RecastJSCrowd implements ICrowd {
  61304. /**
  61305. * Recast/detour plugin
  61306. */
  61307. bjsRECASTPlugin: RecastJSPlugin;
  61308. /**
  61309. * Link to the detour crowd
  61310. */
  61311. recastCrowd: any;
  61312. /**
  61313. * One transform per agent
  61314. */
  61315. transforms: TransformNode[];
  61316. /**
  61317. * All agents created
  61318. */
  61319. agents: number[];
  61320. /**
  61321. * Link to the scene is kept to unregister the crowd from the scene
  61322. */
  61323. private _scene;
  61324. /**
  61325. * Observer for crowd updates
  61326. */
  61327. private _onBeforeAnimationsObserver;
  61328. /**
  61329. * Constructor
  61330. * @param plugin recastJS plugin
  61331. * @param maxAgents the maximum agent count in the crowd
  61332. * @param maxAgentRadius the maximum radius an agent can have
  61333. * @param scene to attach the crowd to
  61334. * @returns the crowd you can add agents to
  61335. */
  61336. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61337. /**
  61338. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61339. * You can attach anything to that node. The node position is updated in the scene update tick.
  61340. * @param pos world position that will be constrained by the navigation mesh
  61341. * @param parameters agent parameters
  61342. * @param transform hooked to the agent that will be update by the scene
  61343. * @returns agent index
  61344. */
  61345. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61346. /**
  61347. * Returns the agent position in world space
  61348. * @param index agent index returned by addAgent
  61349. * @returns world space position
  61350. */
  61351. getAgentPosition(index: number): Vector3;
  61352. /**
  61353. * Returns the agent velocity in world space
  61354. * @param index agent index returned by addAgent
  61355. * @returns world space velocity
  61356. */
  61357. getAgentVelocity(index: number): Vector3;
  61358. /**
  61359. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61360. * @param index agent index returned by addAgent
  61361. * @param destination targeted world position
  61362. */
  61363. agentGoto(index: number, destination: Vector3): void;
  61364. /**
  61365. * remove a particular agent previously created
  61366. * @param index agent index returned by addAgent
  61367. */
  61368. removeAgent(index: number): void;
  61369. /**
  61370. * get the list of all agents attached to this crowd
  61371. * @returns list of agent indices
  61372. */
  61373. getAgents(): number[];
  61374. /**
  61375. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61376. * @param deltaTime in seconds
  61377. */
  61378. update(deltaTime: number): void;
  61379. /**
  61380. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61381. * The queries will try to find a solution within those bounds
  61382. * default is (1,1,1)
  61383. * @param extent x,y,z value that define the extent around the queries point of reference
  61384. */
  61385. setDefaultQueryExtent(extent: Vector3): void;
  61386. /**
  61387. * Get the Bounding box extent specified by setDefaultQueryExtent
  61388. * @returns the box extent values
  61389. */
  61390. getDefaultQueryExtent(): Vector3;
  61391. /**
  61392. * Release all resources
  61393. */
  61394. dispose(): void;
  61395. }
  61396. }
  61397. declare module "babylonjs/Navigation/Plugins/index" {
  61398. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61399. }
  61400. declare module "babylonjs/Navigation/index" {
  61401. export * from "babylonjs/Navigation/INavigationEngine";
  61402. export * from "babylonjs/Navigation/Plugins/index";
  61403. }
  61404. declare module "babylonjs/Offline/database" {
  61405. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61406. /**
  61407. * Class used to enable access to IndexedDB
  61408. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61409. */
  61410. export class Database implements IOfflineProvider {
  61411. private _callbackManifestChecked;
  61412. private _currentSceneUrl;
  61413. private _db;
  61414. private _enableSceneOffline;
  61415. private _enableTexturesOffline;
  61416. private _manifestVersionFound;
  61417. private _mustUpdateRessources;
  61418. private _hasReachedQuota;
  61419. private _isSupported;
  61420. private _idbFactory;
  61421. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61422. private static IsUASupportingBlobStorage;
  61423. /**
  61424. * Gets a boolean indicating if Database storate is enabled (off by default)
  61425. */
  61426. static IDBStorageEnabled: boolean;
  61427. /**
  61428. * Gets a boolean indicating if scene must be saved in the database
  61429. */
  61430. readonly enableSceneOffline: boolean;
  61431. /**
  61432. * Gets a boolean indicating if textures must be saved in the database
  61433. */
  61434. readonly enableTexturesOffline: boolean;
  61435. /**
  61436. * Creates a new Database
  61437. * @param urlToScene defines the url to load the scene
  61438. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61439. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61440. */
  61441. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61442. private static _ParseURL;
  61443. private static _ReturnFullUrlLocation;
  61444. private _checkManifestFile;
  61445. /**
  61446. * Open the database and make it available
  61447. * @param successCallback defines the callback to call on success
  61448. * @param errorCallback defines the callback to call on error
  61449. */
  61450. open(successCallback: () => void, errorCallback: () => void): void;
  61451. /**
  61452. * Loads an image from the database
  61453. * @param url defines the url to load from
  61454. * @param image defines the target DOM image
  61455. */
  61456. loadImage(url: string, image: HTMLImageElement): void;
  61457. private _loadImageFromDBAsync;
  61458. private _saveImageIntoDBAsync;
  61459. private _checkVersionFromDB;
  61460. private _loadVersionFromDBAsync;
  61461. private _saveVersionIntoDBAsync;
  61462. /**
  61463. * Loads a file from database
  61464. * @param url defines the URL to load from
  61465. * @param sceneLoaded defines a callback to call on success
  61466. * @param progressCallBack defines a callback to call when progress changed
  61467. * @param errorCallback defines a callback to call on error
  61468. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61469. */
  61470. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61471. private _loadFileAsync;
  61472. private _saveFileAsync;
  61473. /**
  61474. * Validates if xhr data is correct
  61475. * @param xhr defines the request to validate
  61476. * @param dataType defines the expected data type
  61477. * @returns true if data is correct
  61478. */
  61479. private static _ValidateXHRData;
  61480. }
  61481. }
  61482. declare module "babylonjs/Offline/index" {
  61483. export * from "babylonjs/Offline/database";
  61484. export * from "babylonjs/Offline/IOfflineProvider";
  61485. }
  61486. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61487. /** @hidden */
  61488. export var gpuUpdateParticlesPixelShader: {
  61489. name: string;
  61490. shader: string;
  61491. };
  61492. }
  61493. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61494. /** @hidden */
  61495. export var gpuUpdateParticlesVertexShader: {
  61496. name: string;
  61497. shader: string;
  61498. };
  61499. }
  61500. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61501. /** @hidden */
  61502. export var clipPlaneFragmentDeclaration2: {
  61503. name: string;
  61504. shader: string;
  61505. };
  61506. }
  61507. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61508. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61509. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61510. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61511. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61512. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61513. /** @hidden */
  61514. export var gpuRenderParticlesPixelShader: {
  61515. name: string;
  61516. shader: string;
  61517. };
  61518. }
  61519. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61520. /** @hidden */
  61521. export var clipPlaneVertexDeclaration2: {
  61522. name: string;
  61523. shader: string;
  61524. };
  61525. }
  61526. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61527. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61528. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61529. /** @hidden */
  61530. export var gpuRenderParticlesVertexShader: {
  61531. name: string;
  61532. shader: string;
  61533. };
  61534. }
  61535. declare module "babylonjs/Particles/gpuParticleSystem" {
  61536. import { Nullable } from "babylonjs/types";
  61537. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61538. import { Observable } from "babylonjs/Misc/observable";
  61539. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61541. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61542. import { Scene, IDisposable } from "babylonjs/scene";
  61543. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61544. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61545. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61546. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61547. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61548. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61549. /**
  61550. * This represents a GPU particle system in Babylon
  61551. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61552. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61553. */
  61554. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61555. /**
  61556. * The layer mask we are rendering the particles through.
  61557. */
  61558. layerMask: number;
  61559. private _capacity;
  61560. private _activeCount;
  61561. private _currentActiveCount;
  61562. private _accumulatedCount;
  61563. private _renderEffect;
  61564. private _updateEffect;
  61565. private _buffer0;
  61566. private _buffer1;
  61567. private _spriteBuffer;
  61568. private _updateVAO;
  61569. private _renderVAO;
  61570. private _targetIndex;
  61571. private _sourceBuffer;
  61572. private _targetBuffer;
  61573. private _engine;
  61574. private _currentRenderId;
  61575. private _started;
  61576. private _stopped;
  61577. private _timeDelta;
  61578. private _randomTexture;
  61579. private _randomTexture2;
  61580. private _attributesStrideSize;
  61581. private _updateEffectOptions;
  61582. private _randomTextureSize;
  61583. private _actualFrame;
  61584. private readonly _rawTextureWidth;
  61585. /**
  61586. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61587. */
  61588. static readonly IsSupported: boolean;
  61589. /**
  61590. * An event triggered when the system is disposed.
  61591. */
  61592. onDisposeObservable: Observable<GPUParticleSystem>;
  61593. /**
  61594. * Gets the maximum number of particles active at the same time.
  61595. * @returns The max number of active particles.
  61596. */
  61597. getCapacity(): number;
  61598. /**
  61599. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61600. * to override the particles.
  61601. */
  61602. forceDepthWrite: boolean;
  61603. /**
  61604. * Gets or set the number of active particles
  61605. */
  61606. activeParticleCount: number;
  61607. private _preWarmDone;
  61608. /**
  61609. * Is this system ready to be used/rendered
  61610. * @return true if the system is ready
  61611. */
  61612. isReady(): boolean;
  61613. /**
  61614. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61615. * @returns True if it has been started, otherwise false.
  61616. */
  61617. isStarted(): boolean;
  61618. /**
  61619. * Starts the particle system and begins to emit
  61620. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61621. */
  61622. start(delay?: number): void;
  61623. /**
  61624. * Stops the particle system.
  61625. */
  61626. stop(): void;
  61627. /**
  61628. * Remove all active particles
  61629. */
  61630. reset(): void;
  61631. /**
  61632. * Returns the string "GPUParticleSystem"
  61633. * @returns a string containing the class name
  61634. */
  61635. getClassName(): string;
  61636. private _colorGradientsTexture;
  61637. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61638. /**
  61639. * Adds a new color gradient
  61640. * @param gradient defines the gradient to use (between 0 and 1)
  61641. * @param color1 defines the color to affect to the specified gradient
  61642. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61643. * @returns the current particle system
  61644. */
  61645. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61646. /**
  61647. * Remove a specific color gradient
  61648. * @param gradient defines the gradient to remove
  61649. * @returns the current particle system
  61650. */
  61651. removeColorGradient(gradient: number): GPUParticleSystem;
  61652. private _angularSpeedGradientsTexture;
  61653. private _sizeGradientsTexture;
  61654. private _velocityGradientsTexture;
  61655. private _limitVelocityGradientsTexture;
  61656. private _dragGradientsTexture;
  61657. private _addFactorGradient;
  61658. /**
  61659. * Adds a new size gradient
  61660. * @param gradient defines the gradient to use (between 0 and 1)
  61661. * @param factor defines the size factor to affect to the specified gradient
  61662. * @returns the current particle system
  61663. */
  61664. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61665. /**
  61666. * Remove a specific size gradient
  61667. * @param gradient defines the gradient to remove
  61668. * @returns the current particle system
  61669. */
  61670. removeSizeGradient(gradient: number): GPUParticleSystem;
  61671. /**
  61672. * Adds a new angular speed gradient
  61673. * @param gradient defines the gradient to use (between 0 and 1)
  61674. * @param factor defines the angular speed to affect to the specified gradient
  61675. * @returns the current particle system
  61676. */
  61677. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61678. /**
  61679. * Remove a specific angular speed gradient
  61680. * @param gradient defines the gradient to remove
  61681. * @returns the current particle system
  61682. */
  61683. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61684. /**
  61685. * Adds a new velocity gradient
  61686. * @param gradient defines the gradient to use (between 0 and 1)
  61687. * @param factor defines the velocity to affect to the specified gradient
  61688. * @returns the current particle system
  61689. */
  61690. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61691. /**
  61692. * Remove a specific velocity gradient
  61693. * @param gradient defines the gradient to remove
  61694. * @returns the current particle system
  61695. */
  61696. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61697. /**
  61698. * Adds a new limit velocity gradient
  61699. * @param gradient defines the gradient to use (between 0 and 1)
  61700. * @param factor defines the limit velocity value to affect to the specified gradient
  61701. * @returns the current particle system
  61702. */
  61703. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61704. /**
  61705. * Remove a specific limit velocity gradient
  61706. * @param gradient defines the gradient to remove
  61707. * @returns the current particle system
  61708. */
  61709. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61710. /**
  61711. * Adds a new drag gradient
  61712. * @param gradient defines the gradient to use (between 0 and 1)
  61713. * @param factor defines the drag value to affect to the specified gradient
  61714. * @returns the current particle system
  61715. */
  61716. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61717. /**
  61718. * Remove a specific drag gradient
  61719. * @param gradient defines the gradient to remove
  61720. * @returns the current particle system
  61721. */
  61722. removeDragGradient(gradient: number): GPUParticleSystem;
  61723. /**
  61724. * Not supported by GPUParticleSystem
  61725. * @param gradient defines the gradient to use (between 0 and 1)
  61726. * @param factor defines the emit rate value to affect to the specified gradient
  61727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61728. * @returns the current particle system
  61729. */
  61730. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61731. /**
  61732. * Not supported by GPUParticleSystem
  61733. * @param gradient defines the gradient to remove
  61734. * @returns the current particle system
  61735. */
  61736. removeEmitRateGradient(gradient: number): IParticleSystem;
  61737. /**
  61738. * Not supported by GPUParticleSystem
  61739. * @param gradient defines the gradient to use (between 0 and 1)
  61740. * @param factor defines the start size value to affect to the specified gradient
  61741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61742. * @returns the current particle system
  61743. */
  61744. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61745. /**
  61746. * Not supported by GPUParticleSystem
  61747. * @param gradient defines the gradient to remove
  61748. * @returns the current particle system
  61749. */
  61750. removeStartSizeGradient(gradient: number): IParticleSystem;
  61751. /**
  61752. * Not supported by GPUParticleSystem
  61753. * @param gradient defines the gradient to use (between 0 and 1)
  61754. * @param min defines the color remap minimal range
  61755. * @param max defines the color remap maximal range
  61756. * @returns the current particle system
  61757. */
  61758. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61759. /**
  61760. * Not supported by GPUParticleSystem
  61761. * @param gradient defines the gradient to remove
  61762. * @returns the current particle system
  61763. */
  61764. removeColorRemapGradient(): IParticleSystem;
  61765. /**
  61766. * Not supported by GPUParticleSystem
  61767. * @param gradient defines the gradient to use (between 0 and 1)
  61768. * @param min defines the alpha remap minimal range
  61769. * @param max defines the alpha remap maximal range
  61770. * @returns the current particle system
  61771. */
  61772. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61773. /**
  61774. * Not supported by GPUParticleSystem
  61775. * @param gradient defines the gradient to remove
  61776. * @returns the current particle system
  61777. */
  61778. removeAlphaRemapGradient(): IParticleSystem;
  61779. /**
  61780. * Not supported by GPUParticleSystem
  61781. * @param gradient defines the gradient to use (between 0 and 1)
  61782. * @param color defines the color to affect to the specified gradient
  61783. * @returns the current particle system
  61784. */
  61785. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61786. /**
  61787. * Not supported by GPUParticleSystem
  61788. * @param gradient defines the gradient to remove
  61789. * @returns the current particle system
  61790. */
  61791. removeRampGradient(): IParticleSystem;
  61792. /**
  61793. * Not supported by GPUParticleSystem
  61794. * @returns the list of ramp gradients
  61795. */
  61796. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61797. /**
  61798. * Not supported by GPUParticleSystem
  61799. * Gets or sets a boolean indicating that ramp gradients must be used
  61800. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61801. */
  61802. useRampGradients: boolean;
  61803. /**
  61804. * Not supported by GPUParticleSystem
  61805. * @param gradient defines the gradient to use (between 0 and 1)
  61806. * @param factor defines the life time factor to affect to the specified gradient
  61807. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61808. * @returns the current particle system
  61809. */
  61810. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61811. /**
  61812. * Not supported by GPUParticleSystem
  61813. * @param gradient defines the gradient to remove
  61814. * @returns the current particle system
  61815. */
  61816. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61817. /**
  61818. * Instantiates a GPU particle system.
  61819. * 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.
  61820. * @param name The name of the particle system
  61821. * @param options The options used to create the system
  61822. * @param scene The scene the particle system belongs to
  61823. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61824. */
  61825. constructor(name: string, options: Partial<{
  61826. capacity: number;
  61827. randomTextureSize: number;
  61828. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61829. protected _reset(): void;
  61830. private _createUpdateVAO;
  61831. private _createRenderVAO;
  61832. private _initialize;
  61833. /** @hidden */
  61834. _recreateUpdateEffect(): void;
  61835. /** @hidden */
  61836. _recreateRenderEffect(): void;
  61837. /**
  61838. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61839. * @param preWarm defines if we are in the pre-warmimg phase
  61840. */
  61841. animate(preWarm?: boolean): void;
  61842. private _createFactorGradientTexture;
  61843. private _createSizeGradientTexture;
  61844. private _createAngularSpeedGradientTexture;
  61845. private _createVelocityGradientTexture;
  61846. private _createLimitVelocityGradientTexture;
  61847. private _createDragGradientTexture;
  61848. private _createColorGradientTexture;
  61849. /**
  61850. * Renders the particle system in its current state
  61851. * @param preWarm defines if the system should only update the particles but not render them
  61852. * @returns the current number of particles
  61853. */
  61854. render(preWarm?: boolean): number;
  61855. /**
  61856. * Rebuilds the particle system
  61857. */
  61858. rebuild(): void;
  61859. private _releaseBuffers;
  61860. private _releaseVAOs;
  61861. /**
  61862. * Disposes the particle system and free the associated resources
  61863. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61864. */
  61865. dispose(disposeTexture?: boolean): void;
  61866. /**
  61867. * Clones the particle system.
  61868. * @param name The name of the cloned object
  61869. * @param newEmitter The new emitter to use
  61870. * @returns the cloned particle system
  61871. */
  61872. clone(name: string, newEmitter: any): GPUParticleSystem;
  61873. /**
  61874. * Serializes the particle system to a JSON object.
  61875. * @returns the JSON object
  61876. */
  61877. serialize(): any;
  61878. /**
  61879. * Parses a JSON object to create a GPU particle system.
  61880. * @param parsedParticleSystem The JSON object to parse
  61881. * @param scene The scene to create the particle system in
  61882. * @param rootUrl The root url to use to load external dependencies like texture
  61883. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61884. * @returns the parsed GPU particle system
  61885. */
  61886. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61887. }
  61888. }
  61889. declare module "babylonjs/Particles/particleSystemSet" {
  61890. import { Nullable } from "babylonjs/types";
  61891. import { Color3 } from "babylonjs/Maths/math.color";
  61892. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61894. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61895. import { Scene, IDisposable } from "babylonjs/scene";
  61896. /**
  61897. * Represents a set of particle systems working together to create a specific effect
  61898. */
  61899. export class ParticleSystemSet implements IDisposable {
  61900. /**
  61901. * Gets or sets base Assets URL
  61902. */
  61903. static BaseAssetsUrl: string;
  61904. private _emitterCreationOptions;
  61905. private _emitterNode;
  61906. /**
  61907. * Gets the particle system list
  61908. */
  61909. systems: IParticleSystem[];
  61910. /**
  61911. * Gets the emitter node used with this set
  61912. */
  61913. readonly emitterNode: Nullable<TransformNode>;
  61914. /**
  61915. * Creates a new emitter mesh as a sphere
  61916. * @param options defines the options used to create the sphere
  61917. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61918. * @param scene defines the hosting scene
  61919. */
  61920. setEmitterAsSphere(options: {
  61921. diameter: number;
  61922. segments: number;
  61923. color: Color3;
  61924. }, renderingGroupId: number, scene: Scene): void;
  61925. /**
  61926. * Starts all particle systems of the set
  61927. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61928. */
  61929. start(emitter?: AbstractMesh): void;
  61930. /**
  61931. * Release all associated resources
  61932. */
  61933. dispose(): void;
  61934. /**
  61935. * Serialize the set into a JSON compatible object
  61936. * @returns a JSON compatible representation of the set
  61937. */
  61938. serialize(): any;
  61939. /**
  61940. * Parse a new ParticleSystemSet from a serialized source
  61941. * @param data defines a JSON compatible representation of the set
  61942. * @param scene defines the hosting scene
  61943. * @param gpu defines if we want GPU particles or CPU particles
  61944. * @returns a new ParticleSystemSet
  61945. */
  61946. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61947. }
  61948. }
  61949. declare module "babylonjs/Particles/particleHelper" {
  61950. import { Nullable } from "babylonjs/types";
  61951. import { Scene } from "babylonjs/scene";
  61952. import { Vector3 } from "babylonjs/Maths/math.vector";
  61953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61954. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61955. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61956. /**
  61957. * This class is made for on one-liner static method to help creating particle system set.
  61958. */
  61959. export class ParticleHelper {
  61960. /**
  61961. * Gets or sets base Assets URL
  61962. */
  61963. static BaseAssetsUrl: string;
  61964. /**
  61965. * Create a default particle system that you can tweak
  61966. * @param emitter defines the emitter to use
  61967. * @param capacity defines the system capacity (default is 500 particles)
  61968. * @param scene defines the hosting scene
  61969. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61970. * @returns the new Particle system
  61971. */
  61972. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61973. /**
  61974. * This is the main static method (one-liner) of this helper to create different particle systems
  61975. * @param type This string represents the type to the particle system to create
  61976. * @param scene The scene where the particle system should live
  61977. * @param gpu If the system will use gpu
  61978. * @returns the ParticleSystemSet created
  61979. */
  61980. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61981. /**
  61982. * Static function used to export a particle system to a ParticleSystemSet variable.
  61983. * Please note that the emitter shape is not exported
  61984. * @param systems defines the particle systems to export
  61985. * @returns the created particle system set
  61986. */
  61987. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61988. }
  61989. }
  61990. declare module "babylonjs/Particles/particleSystemComponent" {
  61991. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61992. import { Effect } from "babylonjs/Materials/effect";
  61993. import "babylonjs/Shaders/particles.vertex";
  61994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61995. module "babylonjs/Engines/engine" {
  61996. interface Engine {
  61997. /**
  61998. * Create an effect to use with particle systems.
  61999. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62000. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62001. * @param uniformsNames defines a list of attribute names
  62002. * @param samplers defines an array of string used to represent textures
  62003. * @param defines defines the string containing the defines to use to compile the shaders
  62004. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62005. * @param onCompiled defines a function to call when the effect creation is successful
  62006. * @param onError defines a function to call when the effect creation has failed
  62007. * @returns the new Effect
  62008. */
  62009. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62010. }
  62011. }
  62012. module "babylonjs/Meshes/mesh" {
  62013. interface Mesh {
  62014. /**
  62015. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62016. * @returns an array of IParticleSystem
  62017. */
  62018. getEmittedParticleSystems(): IParticleSystem[];
  62019. /**
  62020. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62021. * @returns an array of IParticleSystem
  62022. */
  62023. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62024. }
  62025. }
  62026. /**
  62027. * @hidden
  62028. */
  62029. export var _IDoNeedToBeInTheBuild: number;
  62030. }
  62031. declare module "babylonjs/Particles/pointsCloudSystem" {
  62032. import { Color4 } from "babylonjs/Maths/math";
  62033. import { Mesh } from "babylonjs/Meshes/mesh";
  62034. import { Scene, IDisposable } from "babylonjs/scene";
  62035. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62036. /** Defines the 4 color options */
  62037. export enum PointColor {
  62038. /** color value */
  62039. Color = 2,
  62040. /** uv value */
  62041. UV = 1,
  62042. /** random value */
  62043. Random = 0,
  62044. /** stated value */
  62045. Stated = 3
  62046. }
  62047. /**
  62048. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62049. * 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.
  62050. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62051. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62052. *
  62053. * Full documentation here : TO BE ENTERED
  62054. */
  62055. export class PointsCloudSystem implements IDisposable {
  62056. /**
  62057. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62058. * Example : var p = SPS.particles[i];
  62059. */
  62060. particles: CloudPoint[];
  62061. /**
  62062. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62063. */
  62064. nbParticles: number;
  62065. /**
  62066. * This a counter for your own usage. It's not set by any SPS functions.
  62067. */
  62068. counter: number;
  62069. /**
  62070. * The PCS name. This name is also given to the underlying mesh.
  62071. */
  62072. name: string;
  62073. /**
  62074. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62075. */
  62076. mesh: Mesh;
  62077. /**
  62078. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62079. * Please read :
  62080. */
  62081. vars: any;
  62082. /**
  62083. * @hidden
  62084. */
  62085. _size: number;
  62086. private _scene;
  62087. private _promises;
  62088. private _positions;
  62089. private _indices;
  62090. private _normals;
  62091. private _colors;
  62092. private _uvs;
  62093. private _indices32;
  62094. private _positions32;
  62095. private _colors32;
  62096. private _uvs32;
  62097. private _updatable;
  62098. private _isVisibilityBoxLocked;
  62099. private _alwaysVisible;
  62100. private _groups;
  62101. private _groupCounter;
  62102. private _computeParticleColor;
  62103. private _computeParticleTexture;
  62104. private _computeParticleRotation;
  62105. private _computeBoundingBox;
  62106. private _isReady;
  62107. /**
  62108. * Creates a PCS (Points Cloud System) object
  62109. * @param name (String) is the PCS name, this will be the underlying mesh name
  62110. * @param pointSize (number) is the size for each point
  62111. * @param scene (Scene) is the scene in which the PCS is added
  62112. * @param options defines the options of the PCS e.g.
  62113. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62114. */
  62115. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62116. updatable?: boolean;
  62117. });
  62118. /**
  62119. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62120. * If no points were added to the PCS, the returned mesh is just a single point.
  62121. * @returns a promise for the created mesh
  62122. */
  62123. buildMeshAsync(): Promise<Mesh>;
  62124. /**
  62125. * @hidden
  62126. */
  62127. private _buildMesh;
  62128. private _addParticle;
  62129. private _randomUnitVector;
  62130. private _getColorIndicesForCoord;
  62131. private _setPointsColorOrUV;
  62132. private _colorFromTexture;
  62133. private _calculateDensity;
  62134. /**
  62135. * Adds points to the PCS in random positions within a unit sphere
  62136. * @param nb (positive integer) the number of particles to be created from this model
  62137. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62138. * @returns the number of groups in the system
  62139. */
  62140. addPoints(nb: number, pointFunction?: any): number;
  62141. /**
  62142. * Adds points to the PCS from the surface of the model shape
  62143. * @param mesh is any Mesh object that will be used as a surface model for the points
  62144. * @param nb (positive integer) the number of particles to be created from this model
  62145. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62146. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62147. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62148. * @returns the number of groups in the system
  62149. */
  62150. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62151. /**
  62152. * Adds points to the PCS inside the model shape
  62153. * @param mesh is any Mesh object that will be used as a surface model for the points
  62154. * @param nb (positive integer) the number of particles to be created from this model
  62155. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62156. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62157. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62158. * @returns the number of groups in the system
  62159. */
  62160. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62161. /**
  62162. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62163. * This method calls `updateParticle()` for each particle of the SPS.
  62164. * For an animated SPS, it is usually called within the render loop.
  62165. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62166. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62167. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62168. * @returns the PCS.
  62169. */
  62170. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62171. /**
  62172. * Disposes the PCS.
  62173. */
  62174. dispose(): void;
  62175. /**
  62176. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62177. * doc :
  62178. * @returns the PCS.
  62179. */
  62180. refreshVisibleSize(): PointsCloudSystem;
  62181. /**
  62182. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62183. * @param size the size (float) of the visibility box
  62184. * note : this doesn't lock the PCS mesh bounding box.
  62185. * doc :
  62186. */
  62187. setVisibilityBox(size: number): void;
  62188. /**
  62189. * Gets whether the PCS is always visible or not
  62190. * doc :
  62191. */
  62192. /**
  62193. * Sets the PCS as always visible or not
  62194. * doc :
  62195. */
  62196. isAlwaysVisible: boolean;
  62197. /**
  62198. * Tells to `setParticles()` to compute the particle rotations or not
  62199. * Default value : false. The PCS is faster when it's set to false
  62200. * Note : particle rotations are only applied to parent particles
  62201. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62202. */
  62203. computeParticleRotation: boolean;
  62204. /**
  62205. * Tells to `setParticles()` to compute the particle colors or not.
  62206. * Default value : true. The PCS is faster when it's set to false.
  62207. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62208. */
  62209. /**
  62210. * Gets if `setParticles()` computes the particle colors or not.
  62211. * Default value : false. The PCS is faster when it's set to false.
  62212. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62213. */
  62214. computeParticleColor: boolean;
  62215. /**
  62216. * Gets if `setParticles()` computes the particle textures or not.
  62217. * Default value : false. The PCS is faster when it's set to false.
  62218. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62219. */
  62220. computeParticleTexture: boolean;
  62221. /**
  62222. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62223. */
  62224. /**
  62225. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62226. */
  62227. computeBoundingBox: boolean;
  62228. /**
  62229. * This function does nothing. It may be overwritten to set all the particle first values.
  62230. * The PCS doesn't call this function, you may have to call it by your own.
  62231. * doc :
  62232. */
  62233. initParticles(): void;
  62234. /**
  62235. * This function does nothing. It may be overwritten to recycle a particle
  62236. * The PCS doesn't call this function, you can to call it
  62237. * doc :
  62238. * @param particle The particle to recycle
  62239. * @returns the recycled particle
  62240. */
  62241. recycleParticle(particle: CloudPoint): CloudPoint;
  62242. /**
  62243. * Updates a particle : this function should be overwritten by the user.
  62244. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62245. * doc :
  62246. * @example : just set a particle position or velocity and recycle conditions
  62247. * @param particle The particle to update
  62248. * @returns the updated particle
  62249. */
  62250. updateParticle(particle: CloudPoint): CloudPoint;
  62251. /**
  62252. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62253. * This does nothing and may be overwritten by the user.
  62254. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62255. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62256. * @param update the boolean update value actually passed to setParticles()
  62257. */
  62258. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62259. /**
  62260. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62261. * This will be passed three parameters.
  62262. * This does nothing and may be overwritten by the user.
  62263. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62264. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62265. * @param update the boolean update value actually passed to setParticles()
  62266. */
  62267. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62268. }
  62269. }
  62270. declare module "babylonjs/Particles/cloudPoint" {
  62271. import { Nullable } from "babylonjs/types";
  62272. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62273. import { Mesh } from "babylonjs/Meshes/mesh";
  62274. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62275. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62276. /**
  62277. * Represents one particle of a points cloud system.
  62278. */
  62279. export class CloudPoint {
  62280. /**
  62281. * particle global index
  62282. */
  62283. idx: number;
  62284. /**
  62285. * The color of the particle
  62286. */
  62287. color: Nullable<Color4>;
  62288. /**
  62289. * The world space position of the particle.
  62290. */
  62291. position: Vector3;
  62292. /**
  62293. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62294. */
  62295. rotation: Vector3;
  62296. /**
  62297. * The world space rotation quaternion of the particle.
  62298. */
  62299. rotationQuaternion: Nullable<Quaternion>;
  62300. /**
  62301. * The uv of the particle.
  62302. */
  62303. uv: Nullable<Vector2>;
  62304. /**
  62305. * The current speed of the particle.
  62306. */
  62307. velocity: Vector3;
  62308. /**
  62309. * The pivot point in the particle local space.
  62310. */
  62311. pivot: Vector3;
  62312. /**
  62313. * Must the particle be translated from its pivot point in its local space ?
  62314. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62315. * Default : false
  62316. */
  62317. translateFromPivot: boolean;
  62318. /**
  62319. * Index of this particle in the global "positions" array (Internal use)
  62320. * @hidden
  62321. */
  62322. _pos: number;
  62323. /**
  62324. * @hidden Index of this particle in the global "indices" array (Internal use)
  62325. */
  62326. _ind: number;
  62327. /**
  62328. * Group this particle belongs to
  62329. */
  62330. _group: PointsGroup;
  62331. /**
  62332. * Group id of this particle
  62333. */
  62334. groupId: number;
  62335. /**
  62336. * Index of the particle in its group id (Internal use)
  62337. */
  62338. idxInGroup: number;
  62339. /**
  62340. * @hidden Particle BoundingInfo object (Internal use)
  62341. */
  62342. _boundingInfo: BoundingInfo;
  62343. /**
  62344. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62345. */
  62346. _pcs: PointsCloudSystem;
  62347. /**
  62348. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62349. */
  62350. _stillInvisible: boolean;
  62351. /**
  62352. * @hidden Last computed particle rotation matrix
  62353. */
  62354. _rotationMatrix: number[];
  62355. /**
  62356. * Parent particle Id, if any.
  62357. * Default null.
  62358. */
  62359. parentId: Nullable<number>;
  62360. /**
  62361. * @hidden Internal global position in the PCS.
  62362. */
  62363. _globalPosition: Vector3;
  62364. /**
  62365. * Creates a Point Cloud object.
  62366. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62367. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62368. * @param group (PointsGroup) is the group the particle belongs to
  62369. * @param groupId (integer) is the group identifier in the PCS.
  62370. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62371. * @param pcs defines the PCS it is associated to
  62372. */
  62373. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62374. /**
  62375. * get point size
  62376. */
  62377. /**
  62378. * Set point size
  62379. */
  62380. size: Vector3;
  62381. /**
  62382. * Legacy support, changed quaternion to rotationQuaternion
  62383. */
  62384. /**
  62385. * Legacy support, changed quaternion to rotationQuaternion
  62386. */
  62387. quaternion: Nullable<Quaternion>;
  62388. /**
  62389. * Returns a boolean. True if the particle intersects a mesh, else false
  62390. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62391. * @param target is the object (point or mesh) what the intersection is computed against
  62392. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62393. * @returns true if it intersects
  62394. */
  62395. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62396. /**
  62397. * get the rotation matrix of the particle
  62398. * @hidden
  62399. */
  62400. getRotationMatrix(m: Matrix): void;
  62401. }
  62402. /**
  62403. * Represents a group of points in a points cloud system
  62404. * * PCS internal tool, don't use it manually.
  62405. */
  62406. export class PointsGroup {
  62407. /**
  62408. * The group id
  62409. * @hidden
  62410. */
  62411. groupID: number;
  62412. /**
  62413. * image data for group (internal use)
  62414. * @hidden
  62415. */
  62416. _groupImageData: Nullable<ArrayBufferView>;
  62417. /**
  62418. * Image Width (internal use)
  62419. * @hidden
  62420. */
  62421. _groupImgWidth: number;
  62422. /**
  62423. * Image Height (internal use)
  62424. * @hidden
  62425. */
  62426. _groupImgHeight: number;
  62427. /**
  62428. * Custom position function (internal use)
  62429. * @hidden
  62430. */
  62431. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62432. /**
  62433. * density per facet for surface points
  62434. * @hidden
  62435. */
  62436. _groupDensity: number[];
  62437. /**
  62438. * Only when points are colored by texture carries pointer to texture list array
  62439. * @hidden
  62440. */
  62441. _textureNb: number;
  62442. /**
  62443. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62444. * PCS internal tool, don't use it manually.
  62445. * @hidden
  62446. */
  62447. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62448. }
  62449. }
  62450. declare module "babylonjs/Particles/index" {
  62451. export * from "babylonjs/Particles/baseParticleSystem";
  62452. export * from "babylonjs/Particles/EmitterTypes/index";
  62453. export * from "babylonjs/Particles/gpuParticleSystem";
  62454. export * from "babylonjs/Particles/IParticleSystem";
  62455. export * from "babylonjs/Particles/particle";
  62456. export * from "babylonjs/Particles/particleHelper";
  62457. export * from "babylonjs/Particles/particleSystem";
  62458. export * from "babylonjs/Particles/particleSystemComponent";
  62459. export * from "babylonjs/Particles/particleSystemSet";
  62460. export * from "babylonjs/Particles/solidParticle";
  62461. export * from "babylonjs/Particles/solidParticleSystem";
  62462. export * from "babylonjs/Particles/cloudPoint";
  62463. export * from "babylonjs/Particles/pointsCloudSystem";
  62464. export * from "babylonjs/Particles/subEmitter";
  62465. }
  62466. declare module "babylonjs/Physics/physicsEngineComponent" {
  62467. import { Nullable } from "babylonjs/types";
  62468. import { Observable, Observer } from "babylonjs/Misc/observable";
  62469. import { Vector3 } from "babylonjs/Maths/math.vector";
  62470. import { Mesh } from "babylonjs/Meshes/mesh";
  62471. import { ISceneComponent } from "babylonjs/sceneComponent";
  62472. import { Scene } from "babylonjs/scene";
  62473. import { Node } from "babylonjs/node";
  62474. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62475. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62476. module "babylonjs/scene" {
  62477. interface Scene {
  62478. /** @hidden (Backing field) */
  62479. _physicsEngine: Nullable<IPhysicsEngine>;
  62480. /**
  62481. * Gets the current physics engine
  62482. * @returns a IPhysicsEngine or null if none attached
  62483. */
  62484. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62485. /**
  62486. * Enables physics to the current scene
  62487. * @param gravity defines the scene's gravity for the physics engine
  62488. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62489. * @return a boolean indicating if the physics engine was initialized
  62490. */
  62491. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62492. /**
  62493. * Disables and disposes the physics engine associated with the scene
  62494. */
  62495. disablePhysicsEngine(): void;
  62496. /**
  62497. * Gets a boolean indicating if there is an active physics engine
  62498. * @returns a boolean indicating if there is an active physics engine
  62499. */
  62500. isPhysicsEnabled(): boolean;
  62501. /**
  62502. * Deletes a physics compound impostor
  62503. * @param compound defines the compound to delete
  62504. */
  62505. deleteCompoundImpostor(compound: any): void;
  62506. /**
  62507. * An event triggered when physic simulation is about to be run
  62508. */
  62509. onBeforePhysicsObservable: Observable<Scene>;
  62510. /**
  62511. * An event triggered when physic simulation has been done
  62512. */
  62513. onAfterPhysicsObservable: Observable<Scene>;
  62514. }
  62515. }
  62516. module "babylonjs/Meshes/abstractMesh" {
  62517. interface AbstractMesh {
  62518. /** @hidden */
  62519. _physicsImpostor: Nullable<PhysicsImpostor>;
  62520. /**
  62521. * Gets or sets impostor used for physic simulation
  62522. * @see http://doc.babylonjs.com/features/physics_engine
  62523. */
  62524. physicsImpostor: Nullable<PhysicsImpostor>;
  62525. /**
  62526. * Gets the current physics impostor
  62527. * @see http://doc.babylonjs.com/features/physics_engine
  62528. * @returns a physics impostor or null
  62529. */
  62530. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62531. /** Apply a physic impulse to the mesh
  62532. * @param force defines the force to apply
  62533. * @param contactPoint defines where to apply the force
  62534. * @returns the current mesh
  62535. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62536. */
  62537. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62538. /**
  62539. * Creates a physic joint between two meshes
  62540. * @param otherMesh defines the other mesh to use
  62541. * @param pivot1 defines the pivot to use on this mesh
  62542. * @param pivot2 defines the pivot to use on the other mesh
  62543. * @param options defines additional options (can be plugin dependent)
  62544. * @returns the current mesh
  62545. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62546. */
  62547. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62548. /** @hidden */
  62549. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62550. }
  62551. }
  62552. /**
  62553. * Defines the physics engine scene component responsible to manage a physics engine
  62554. */
  62555. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62556. /**
  62557. * The component name helpful to identify the component in the list of scene components.
  62558. */
  62559. readonly name: string;
  62560. /**
  62561. * The scene the component belongs to.
  62562. */
  62563. scene: Scene;
  62564. /**
  62565. * Creates a new instance of the component for the given scene
  62566. * @param scene Defines the scene to register the component in
  62567. */
  62568. constructor(scene: Scene);
  62569. /**
  62570. * Registers the component in a given scene
  62571. */
  62572. register(): void;
  62573. /**
  62574. * Rebuilds the elements related to this component in case of
  62575. * context lost for instance.
  62576. */
  62577. rebuild(): void;
  62578. /**
  62579. * Disposes the component and the associated ressources
  62580. */
  62581. dispose(): void;
  62582. }
  62583. }
  62584. declare module "babylonjs/Physics/physicsHelper" {
  62585. import { Nullable } from "babylonjs/types";
  62586. import { Vector3 } from "babylonjs/Maths/math.vector";
  62587. import { Mesh } from "babylonjs/Meshes/mesh";
  62588. import { Scene } from "babylonjs/scene";
  62589. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62590. /**
  62591. * A helper for physics simulations
  62592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62593. */
  62594. export class PhysicsHelper {
  62595. private _scene;
  62596. private _physicsEngine;
  62597. /**
  62598. * Initializes the Physics helper
  62599. * @param scene Babylon.js scene
  62600. */
  62601. constructor(scene: Scene);
  62602. /**
  62603. * Applies a radial explosion impulse
  62604. * @param origin the origin of the explosion
  62605. * @param radiusOrEventOptions the radius or the options of radial explosion
  62606. * @param strength the explosion strength
  62607. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62608. * @returns A physics radial explosion event, or null
  62609. */
  62610. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62611. /**
  62612. * Applies a radial explosion force
  62613. * @param origin the origin of the explosion
  62614. * @param radiusOrEventOptions the radius or the options of radial explosion
  62615. * @param strength the explosion strength
  62616. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62617. * @returns A physics radial explosion event, or null
  62618. */
  62619. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62620. /**
  62621. * Creates a gravitational field
  62622. * @param origin the origin of the explosion
  62623. * @param radiusOrEventOptions the radius or the options of radial explosion
  62624. * @param strength the explosion strength
  62625. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62626. * @returns A physics gravitational field event, or null
  62627. */
  62628. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62629. /**
  62630. * Creates a physics updraft event
  62631. * @param origin the origin of the updraft
  62632. * @param radiusOrEventOptions the radius or the options of the updraft
  62633. * @param strength the strength of the updraft
  62634. * @param height the height of the updraft
  62635. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62636. * @returns A physics updraft event, or null
  62637. */
  62638. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62639. /**
  62640. * Creates a physics vortex event
  62641. * @param origin the of the vortex
  62642. * @param radiusOrEventOptions the radius or the options of the vortex
  62643. * @param strength the strength of the vortex
  62644. * @param height the height of the vortex
  62645. * @returns a Physics vortex event, or null
  62646. * A physics vortex event or null
  62647. */
  62648. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62649. }
  62650. /**
  62651. * Represents a physics radial explosion event
  62652. */
  62653. class PhysicsRadialExplosionEvent {
  62654. private _scene;
  62655. private _options;
  62656. private _sphere;
  62657. private _dataFetched;
  62658. /**
  62659. * Initializes a radial explosioin event
  62660. * @param _scene BabylonJS scene
  62661. * @param _options The options for the vortex event
  62662. */
  62663. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62664. /**
  62665. * Returns the data related to the radial explosion event (sphere).
  62666. * @returns The radial explosion event data
  62667. */
  62668. getData(): PhysicsRadialExplosionEventData;
  62669. /**
  62670. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62671. * @param impostor A physics imposter
  62672. * @param origin the origin of the explosion
  62673. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62674. */
  62675. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62676. /**
  62677. * Triggers affecterd impostors callbacks
  62678. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62679. */
  62680. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62681. /**
  62682. * Disposes the sphere.
  62683. * @param force Specifies if the sphere should be disposed by force
  62684. */
  62685. dispose(force?: boolean): void;
  62686. /*** Helpers ***/
  62687. private _prepareSphere;
  62688. private _intersectsWithSphere;
  62689. }
  62690. /**
  62691. * Represents a gravitational field event
  62692. */
  62693. class PhysicsGravitationalFieldEvent {
  62694. private _physicsHelper;
  62695. private _scene;
  62696. private _origin;
  62697. private _options;
  62698. private _tickCallback;
  62699. private _sphere;
  62700. private _dataFetched;
  62701. /**
  62702. * Initializes the physics gravitational field event
  62703. * @param _physicsHelper A physics helper
  62704. * @param _scene BabylonJS scene
  62705. * @param _origin The origin position of the gravitational field event
  62706. * @param _options The options for the vortex event
  62707. */
  62708. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62709. /**
  62710. * Returns the data related to the gravitational field event (sphere).
  62711. * @returns A gravitational field event
  62712. */
  62713. getData(): PhysicsGravitationalFieldEventData;
  62714. /**
  62715. * Enables the gravitational field.
  62716. */
  62717. enable(): void;
  62718. /**
  62719. * Disables the gravitational field.
  62720. */
  62721. disable(): void;
  62722. /**
  62723. * Disposes the sphere.
  62724. * @param force The force to dispose from the gravitational field event
  62725. */
  62726. dispose(force?: boolean): void;
  62727. private _tick;
  62728. }
  62729. /**
  62730. * Represents a physics updraft event
  62731. */
  62732. class PhysicsUpdraftEvent {
  62733. private _scene;
  62734. private _origin;
  62735. private _options;
  62736. private _physicsEngine;
  62737. private _originTop;
  62738. private _originDirection;
  62739. private _tickCallback;
  62740. private _cylinder;
  62741. private _cylinderPosition;
  62742. private _dataFetched;
  62743. /**
  62744. * Initializes the physics updraft event
  62745. * @param _scene BabylonJS scene
  62746. * @param _origin The origin position of the updraft
  62747. * @param _options The options for the updraft event
  62748. */
  62749. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62750. /**
  62751. * Returns the data related to the updraft event (cylinder).
  62752. * @returns A physics updraft event
  62753. */
  62754. getData(): PhysicsUpdraftEventData;
  62755. /**
  62756. * Enables the updraft.
  62757. */
  62758. enable(): void;
  62759. /**
  62760. * Disables the updraft.
  62761. */
  62762. disable(): void;
  62763. /**
  62764. * Disposes the cylinder.
  62765. * @param force Specifies if the updraft should be disposed by force
  62766. */
  62767. dispose(force?: boolean): void;
  62768. private getImpostorHitData;
  62769. private _tick;
  62770. /*** Helpers ***/
  62771. private _prepareCylinder;
  62772. private _intersectsWithCylinder;
  62773. }
  62774. /**
  62775. * Represents a physics vortex event
  62776. */
  62777. class PhysicsVortexEvent {
  62778. private _scene;
  62779. private _origin;
  62780. private _options;
  62781. private _physicsEngine;
  62782. private _originTop;
  62783. private _tickCallback;
  62784. private _cylinder;
  62785. private _cylinderPosition;
  62786. private _dataFetched;
  62787. /**
  62788. * Initializes the physics vortex event
  62789. * @param _scene The BabylonJS scene
  62790. * @param _origin The origin position of the vortex
  62791. * @param _options The options for the vortex event
  62792. */
  62793. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62794. /**
  62795. * Returns the data related to the vortex event (cylinder).
  62796. * @returns The physics vortex event data
  62797. */
  62798. getData(): PhysicsVortexEventData;
  62799. /**
  62800. * Enables the vortex.
  62801. */
  62802. enable(): void;
  62803. /**
  62804. * Disables the cortex.
  62805. */
  62806. disable(): void;
  62807. /**
  62808. * Disposes the sphere.
  62809. * @param force
  62810. */
  62811. dispose(force?: boolean): void;
  62812. private getImpostorHitData;
  62813. private _tick;
  62814. /*** Helpers ***/
  62815. private _prepareCylinder;
  62816. private _intersectsWithCylinder;
  62817. }
  62818. /**
  62819. * Options fot the radial explosion event
  62820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62821. */
  62822. export class PhysicsRadialExplosionEventOptions {
  62823. /**
  62824. * The radius of the sphere for the radial explosion.
  62825. */
  62826. radius: number;
  62827. /**
  62828. * The strenth of the explosion.
  62829. */
  62830. strength: number;
  62831. /**
  62832. * The strenght of the force in correspondence to the distance of the affected object
  62833. */
  62834. falloff: PhysicsRadialImpulseFalloff;
  62835. /**
  62836. * Sphere options for the radial explosion.
  62837. */
  62838. sphere: {
  62839. segments: number;
  62840. diameter: number;
  62841. };
  62842. /**
  62843. * Sphere options for the radial explosion.
  62844. */
  62845. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62846. }
  62847. /**
  62848. * Options fot the updraft event
  62849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62850. */
  62851. export class PhysicsUpdraftEventOptions {
  62852. /**
  62853. * The radius of the cylinder for the vortex
  62854. */
  62855. radius: number;
  62856. /**
  62857. * The strenth of the updraft.
  62858. */
  62859. strength: number;
  62860. /**
  62861. * The height of the cylinder for the updraft.
  62862. */
  62863. height: number;
  62864. /**
  62865. * The mode for the the updraft.
  62866. */
  62867. updraftMode: PhysicsUpdraftMode;
  62868. }
  62869. /**
  62870. * Options fot the vortex event
  62871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62872. */
  62873. export class PhysicsVortexEventOptions {
  62874. /**
  62875. * The radius of the cylinder for the vortex
  62876. */
  62877. radius: number;
  62878. /**
  62879. * The strenth of the vortex.
  62880. */
  62881. strength: number;
  62882. /**
  62883. * The height of the cylinder for the vortex.
  62884. */
  62885. height: number;
  62886. /**
  62887. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62888. */
  62889. centripetalForceThreshold: number;
  62890. /**
  62891. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62892. */
  62893. centripetalForceMultiplier: number;
  62894. /**
  62895. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62896. */
  62897. centrifugalForceMultiplier: number;
  62898. /**
  62899. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62900. */
  62901. updraftForceMultiplier: number;
  62902. }
  62903. /**
  62904. * The strenght of the force in correspondence to the distance of the affected object
  62905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62906. */
  62907. export enum PhysicsRadialImpulseFalloff {
  62908. /** Defines that impulse is constant in strength across it's whole radius */
  62909. Constant = 0,
  62910. /** Defines that impulse gets weaker if it's further from the origin */
  62911. Linear = 1
  62912. }
  62913. /**
  62914. * The strength of the force in correspondence to the distance of the affected object
  62915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62916. */
  62917. export enum PhysicsUpdraftMode {
  62918. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62919. Center = 0,
  62920. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62921. Perpendicular = 1
  62922. }
  62923. /**
  62924. * Interface for a physics hit data
  62925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62926. */
  62927. export interface PhysicsHitData {
  62928. /**
  62929. * The force applied at the contact point
  62930. */
  62931. force: Vector3;
  62932. /**
  62933. * The contact point
  62934. */
  62935. contactPoint: Vector3;
  62936. /**
  62937. * The distance from the origin to the contact point
  62938. */
  62939. distanceFromOrigin: number;
  62940. }
  62941. /**
  62942. * Interface for radial explosion event data
  62943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62944. */
  62945. export interface PhysicsRadialExplosionEventData {
  62946. /**
  62947. * A sphere used for the radial explosion event
  62948. */
  62949. sphere: Mesh;
  62950. }
  62951. /**
  62952. * Interface for gravitational field event data
  62953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62954. */
  62955. export interface PhysicsGravitationalFieldEventData {
  62956. /**
  62957. * A sphere mesh used for the gravitational field event
  62958. */
  62959. sphere: Mesh;
  62960. }
  62961. /**
  62962. * Interface for updraft event data
  62963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62964. */
  62965. export interface PhysicsUpdraftEventData {
  62966. /**
  62967. * A cylinder used for the updraft event
  62968. */
  62969. cylinder: Mesh;
  62970. }
  62971. /**
  62972. * Interface for vortex event data
  62973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62974. */
  62975. export interface PhysicsVortexEventData {
  62976. /**
  62977. * A cylinder used for the vortex event
  62978. */
  62979. cylinder: Mesh;
  62980. }
  62981. /**
  62982. * Interface for an affected physics impostor
  62983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62984. */
  62985. export interface PhysicsAffectedImpostorWithData {
  62986. /**
  62987. * The impostor affected by the effect
  62988. */
  62989. impostor: PhysicsImpostor;
  62990. /**
  62991. * The data about the hit/horce from the explosion
  62992. */
  62993. hitData: PhysicsHitData;
  62994. }
  62995. }
  62996. declare module "babylonjs/Physics/Plugins/index" {
  62997. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62998. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62999. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63000. }
  63001. declare module "babylonjs/Physics/index" {
  63002. export * from "babylonjs/Physics/IPhysicsEngine";
  63003. export * from "babylonjs/Physics/physicsEngine";
  63004. export * from "babylonjs/Physics/physicsEngineComponent";
  63005. export * from "babylonjs/Physics/physicsHelper";
  63006. export * from "babylonjs/Physics/physicsImpostor";
  63007. export * from "babylonjs/Physics/physicsJoint";
  63008. export * from "babylonjs/Physics/Plugins/index";
  63009. }
  63010. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63011. /** @hidden */
  63012. export var blackAndWhitePixelShader: {
  63013. name: string;
  63014. shader: string;
  63015. };
  63016. }
  63017. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63018. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63019. import { Camera } from "babylonjs/Cameras/camera";
  63020. import { Engine } from "babylonjs/Engines/engine";
  63021. import "babylonjs/Shaders/blackAndWhite.fragment";
  63022. /**
  63023. * Post process used to render in black and white
  63024. */
  63025. export class BlackAndWhitePostProcess extends PostProcess {
  63026. /**
  63027. * Linear about to convert he result to black and white (default: 1)
  63028. */
  63029. degree: number;
  63030. /**
  63031. * Creates a black and white post process
  63032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63033. * @param name The name of the effect.
  63034. * @param options The required width/height ratio to downsize to before computing the render pass.
  63035. * @param camera The camera to apply the render pass to.
  63036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63037. * @param engine The engine which the post process will be applied. (default: current engine)
  63038. * @param reusable If the post process can be reused on the same frame. (default: false)
  63039. */
  63040. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63041. }
  63042. }
  63043. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63044. import { Nullable } from "babylonjs/types";
  63045. import { Camera } from "babylonjs/Cameras/camera";
  63046. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63047. import { Engine } from "babylonjs/Engines/engine";
  63048. /**
  63049. * This represents a set of one or more post processes in Babylon.
  63050. * A post process can be used to apply a shader to a texture after it is rendered.
  63051. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63052. */
  63053. export class PostProcessRenderEffect {
  63054. private _postProcesses;
  63055. private _getPostProcesses;
  63056. private _singleInstance;
  63057. private _cameras;
  63058. private _indicesForCamera;
  63059. /**
  63060. * Name of the effect
  63061. * @hidden
  63062. */
  63063. _name: string;
  63064. /**
  63065. * Instantiates a post process render effect.
  63066. * A post process can be used to apply a shader to a texture after it is rendered.
  63067. * @param engine The engine the effect is tied to
  63068. * @param name The name of the effect
  63069. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63070. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63071. */
  63072. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63073. /**
  63074. * Checks if all the post processes in the effect are supported.
  63075. */
  63076. readonly isSupported: boolean;
  63077. /**
  63078. * Updates the current state of the effect
  63079. * @hidden
  63080. */
  63081. _update(): void;
  63082. /**
  63083. * Attaches the effect on cameras
  63084. * @param cameras The camera to attach to.
  63085. * @hidden
  63086. */
  63087. _attachCameras(cameras: Camera): void;
  63088. /**
  63089. * Attaches the effect on cameras
  63090. * @param cameras The camera to attach to.
  63091. * @hidden
  63092. */
  63093. _attachCameras(cameras: Camera[]): void;
  63094. /**
  63095. * Detaches the effect on cameras
  63096. * @param cameras The camera to detatch from.
  63097. * @hidden
  63098. */
  63099. _detachCameras(cameras: Camera): void;
  63100. /**
  63101. * Detatches the effect on cameras
  63102. * @param cameras The camera to detatch from.
  63103. * @hidden
  63104. */
  63105. _detachCameras(cameras: Camera[]): void;
  63106. /**
  63107. * Enables the effect on given cameras
  63108. * @param cameras The camera to enable.
  63109. * @hidden
  63110. */
  63111. _enable(cameras: Camera): void;
  63112. /**
  63113. * Enables the effect on given cameras
  63114. * @param cameras The camera to enable.
  63115. * @hidden
  63116. */
  63117. _enable(cameras: Nullable<Camera[]>): void;
  63118. /**
  63119. * Disables the effect on the given cameras
  63120. * @param cameras The camera to disable.
  63121. * @hidden
  63122. */
  63123. _disable(cameras: Camera): void;
  63124. /**
  63125. * Disables the effect on the given cameras
  63126. * @param cameras The camera to disable.
  63127. * @hidden
  63128. */
  63129. _disable(cameras: Nullable<Camera[]>): void;
  63130. /**
  63131. * Gets a list of the post processes contained in the effect.
  63132. * @param camera The camera to get the post processes on.
  63133. * @returns The list of the post processes in the effect.
  63134. */
  63135. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63136. }
  63137. }
  63138. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63139. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63140. /** @hidden */
  63141. export var extractHighlightsPixelShader: {
  63142. name: string;
  63143. shader: string;
  63144. };
  63145. }
  63146. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63147. import { Nullable } from "babylonjs/types";
  63148. import { Camera } from "babylonjs/Cameras/camera";
  63149. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63150. import { Engine } from "babylonjs/Engines/engine";
  63151. import "babylonjs/Shaders/extractHighlights.fragment";
  63152. /**
  63153. * 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.
  63154. */
  63155. export class ExtractHighlightsPostProcess extends PostProcess {
  63156. /**
  63157. * The luminance threshold, pixels below this value will be set to black.
  63158. */
  63159. threshold: number;
  63160. /** @hidden */
  63161. _exposure: number;
  63162. /**
  63163. * Post process which has the input texture to be used when performing highlight extraction
  63164. * @hidden
  63165. */
  63166. _inputPostProcess: Nullable<PostProcess>;
  63167. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63168. }
  63169. }
  63170. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63171. /** @hidden */
  63172. export var bloomMergePixelShader: {
  63173. name: string;
  63174. shader: string;
  63175. };
  63176. }
  63177. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63178. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63179. import { Nullable } from "babylonjs/types";
  63180. import { Engine } from "babylonjs/Engines/engine";
  63181. import { Camera } from "babylonjs/Cameras/camera";
  63182. import "babylonjs/Shaders/bloomMerge.fragment";
  63183. /**
  63184. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63185. */
  63186. export class BloomMergePostProcess extends PostProcess {
  63187. /** Weight of the bloom to be added to the original input. */
  63188. weight: number;
  63189. /**
  63190. * Creates a new instance of @see BloomMergePostProcess
  63191. * @param name The name of the effect.
  63192. * @param originalFromInput Post process which's input will be used for the merge.
  63193. * @param blurred Blurred highlights post process which's output will be used.
  63194. * @param weight Weight of the bloom to be added to the original input.
  63195. * @param options The required width/height ratio to downsize to before computing the render pass.
  63196. * @param camera The camera to apply the render pass to.
  63197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63198. * @param engine The engine which the post process will be applied. (default: current engine)
  63199. * @param reusable If the post process can be reused on the same frame. (default: false)
  63200. * @param textureType Type of textures used when performing the post process. (default: 0)
  63201. * @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)
  63202. */
  63203. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63204. /** Weight of the bloom to be added to the original input. */
  63205. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63206. }
  63207. }
  63208. declare module "babylonjs/PostProcesses/bloomEffect" {
  63209. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63210. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63211. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63212. import { Camera } from "babylonjs/Cameras/camera";
  63213. import { Scene } from "babylonjs/scene";
  63214. /**
  63215. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63216. */
  63217. export class BloomEffect extends PostProcessRenderEffect {
  63218. private bloomScale;
  63219. /**
  63220. * @hidden Internal
  63221. */
  63222. _effects: Array<PostProcess>;
  63223. /**
  63224. * @hidden Internal
  63225. */
  63226. _downscale: ExtractHighlightsPostProcess;
  63227. private _blurX;
  63228. private _blurY;
  63229. private _merge;
  63230. /**
  63231. * The luminance threshold to find bright areas of the image to bloom.
  63232. */
  63233. threshold: number;
  63234. /**
  63235. * The strength of the bloom.
  63236. */
  63237. weight: number;
  63238. /**
  63239. * Specifies the size of the bloom blur kernel, relative to the final output size
  63240. */
  63241. kernel: number;
  63242. /**
  63243. * Creates a new instance of @see BloomEffect
  63244. * @param scene The scene the effect belongs to.
  63245. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63246. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63247. * @param bloomWeight The the strength of bloom.
  63248. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63249. * @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)
  63250. */
  63251. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63252. /**
  63253. * Disposes each of the internal effects for a given camera.
  63254. * @param camera The camera to dispose the effect on.
  63255. */
  63256. disposeEffects(camera: Camera): void;
  63257. /**
  63258. * @hidden Internal
  63259. */
  63260. _updateEffects(): void;
  63261. /**
  63262. * Internal
  63263. * @returns if all the contained post processes are ready.
  63264. * @hidden
  63265. */
  63266. _isReady(): boolean;
  63267. }
  63268. }
  63269. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63270. /** @hidden */
  63271. export var chromaticAberrationPixelShader: {
  63272. name: string;
  63273. shader: string;
  63274. };
  63275. }
  63276. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63277. import { Vector2 } from "babylonjs/Maths/math.vector";
  63278. import { Nullable } from "babylonjs/types";
  63279. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63280. import { Camera } from "babylonjs/Cameras/camera";
  63281. import { Engine } from "babylonjs/Engines/engine";
  63282. import "babylonjs/Shaders/chromaticAberration.fragment";
  63283. /**
  63284. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63285. */
  63286. export class ChromaticAberrationPostProcess extends PostProcess {
  63287. /**
  63288. * The amount of seperation of rgb channels (default: 30)
  63289. */
  63290. aberrationAmount: number;
  63291. /**
  63292. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63293. */
  63294. radialIntensity: number;
  63295. /**
  63296. * 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))
  63297. */
  63298. direction: Vector2;
  63299. /**
  63300. * 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))
  63301. */
  63302. centerPosition: Vector2;
  63303. /**
  63304. * Creates a new instance ChromaticAberrationPostProcess
  63305. * @param name The name of the effect.
  63306. * @param screenWidth The width of the screen to apply the effect on.
  63307. * @param screenHeight The height of the screen to apply the effect on.
  63308. * @param options The required width/height ratio to downsize to before computing the render pass.
  63309. * @param camera The camera to apply the render pass to.
  63310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63311. * @param engine The engine which the post process will be applied. (default: current engine)
  63312. * @param reusable If the post process can be reused on the same frame. (default: false)
  63313. * @param textureType Type of textures used when performing the post process. (default: 0)
  63314. * @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)
  63315. */
  63316. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63317. }
  63318. }
  63319. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63320. /** @hidden */
  63321. export var circleOfConfusionPixelShader: {
  63322. name: string;
  63323. shader: string;
  63324. };
  63325. }
  63326. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63327. import { Nullable } from "babylonjs/types";
  63328. import { Engine } from "babylonjs/Engines/engine";
  63329. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63331. import { Camera } from "babylonjs/Cameras/camera";
  63332. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63333. /**
  63334. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63335. */
  63336. export class CircleOfConfusionPostProcess extends PostProcess {
  63337. /**
  63338. * 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.
  63339. */
  63340. lensSize: number;
  63341. /**
  63342. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63343. */
  63344. fStop: number;
  63345. /**
  63346. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63347. */
  63348. focusDistance: number;
  63349. /**
  63350. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63351. */
  63352. focalLength: number;
  63353. private _depthTexture;
  63354. /**
  63355. * Creates a new instance CircleOfConfusionPostProcess
  63356. * @param name The name of the effect.
  63357. * @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.
  63358. * @param options The required width/height ratio to downsize to before computing the render pass.
  63359. * @param camera The camera to apply the render pass to.
  63360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63361. * @param engine The engine which the post process will be applied. (default: current engine)
  63362. * @param reusable If the post process can be reused on the same frame. (default: false)
  63363. * @param textureType Type of textures used when performing the post process. (default: 0)
  63364. * @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)
  63365. */
  63366. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63367. /**
  63368. * 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.
  63369. */
  63370. depthTexture: RenderTargetTexture;
  63371. }
  63372. }
  63373. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63374. /** @hidden */
  63375. export var colorCorrectionPixelShader: {
  63376. name: string;
  63377. shader: string;
  63378. };
  63379. }
  63380. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63381. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63382. import { Engine } from "babylonjs/Engines/engine";
  63383. import { Camera } from "babylonjs/Cameras/camera";
  63384. import "babylonjs/Shaders/colorCorrection.fragment";
  63385. /**
  63386. *
  63387. * This post-process allows the modification of rendered colors by using
  63388. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63389. *
  63390. * The object needs to be provided an url to a texture containing the color
  63391. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63392. * Use an image editing software to tweak the LUT to match your needs.
  63393. *
  63394. * For an example of a color LUT, see here:
  63395. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63396. * For explanations on color grading, see here:
  63397. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63398. *
  63399. */
  63400. export class ColorCorrectionPostProcess extends PostProcess {
  63401. private _colorTableTexture;
  63402. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63403. }
  63404. }
  63405. declare module "babylonjs/Shaders/convolution.fragment" {
  63406. /** @hidden */
  63407. export var convolutionPixelShader: {
  63408. name: string;
  63409. shader: string;
  63410. };
  63411. }
  63412. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63413. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63414. import { Nullable } from "babylonjs/types";
  63415. import { Camera } from "babylonjs/Cameras/camera";
  63416. import { Engine } from "babylonjs/Engines/engine";
  63417. import "babylonjs/Shaders/convolution.fragment";
  63418. /**
  63419. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63420. * input texture to perform effects such as edge detection or sharpening
  63421. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63422. */
  63423. export class ConvolutionPostProcess extends PostProcess {
  63424. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63425. kernel: number[];
  63426. /**
  63427. * Creates a new instance ConvolutionPostProcess
  63428. * @param name The name of the effect.
  63429. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63430. * @param options The required width/height ratio to downsize to before computing the render pass.
  63431. * @param camera The camera to apply the render pass to.
  63432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63433. * @param engine The engine which the post process will be applied. (default: current engine)
  63434. * @param reusable If the post process can be reused on the same frame. (default: false)
  63435. * @param textureType Type of textures used when performing the post process. (default: 0)
  63436. */
  63437. constructor(name: string,
  63438. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63439. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63440. /**
  63441. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63442. */
  63443. static EdgeDetect0Kernel: number[];
  63444. /**
  63445. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63446. */
  63447. static EdgeDetect1Kernel: number[];
  63448. /**
  63449. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63450. */
  63451. static EdgeDetect2Kernel: number[];
  63452. /**
  63453. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63454. */
  63455. static SharpenKernel: number[];
  63456. /**
  63457. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63458. */
  63459. static EmbossKernel: number[];
  63460. /**
  63461. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63462. */
  63463. static GaussianKernel: number[];
  63464. }
  63465. }
  63466. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63467. import { Nullable } from "babylonjs/types";
  63468. import { Vector2 } from "babylonjs/Maths/math.vector";
  63469. import { Camera } from "babylonjs/Cameras/camera";
  63470. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63471. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63472. import { Engine } from "babylonjs/Engines/engine";
  63473. import { Scene } from "babylonjs/scene";
  63474. /**
  63475. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63476. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63477. * based on samples that have a large difference in distance than the center pixel.
  63478. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63479. */
  63480. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63481. direction: Vector2;
  63482. /**
  63483. * Creates a new instance CircleOfConfusionPostProcess
  63484. * @param name The name of the effect.
  63485. * @param scene The scene the effect belongs to.
  63486. * @param direction The direction the blur should be applied.
  63487. * @param kernel The size of the kernel used to blur.
  63488. * @param options The required width/height ratio to downsize to before computing the render pass.
  63489. * @param camera The camera to apply the render pass to.
  63490. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63491. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63493. * @param engine The engine which the post process will be applied. (default: current engine)
  63494. * @param reusable If the post process can be reused on the same frame. (default: false)
  63495. * @param textureType Type of textures used when performing the post process. (default: 0)
  63496. * @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)
  63497. */
  63498. 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);
  63499. }
  63500. }
  63501. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63502. /** @hidden */
  63503. export var depthOfFieldMergePixelShader: {
  63504. name: string;
  63505. shader: string;
  63506. };
  63507. }
  63508. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63509. import { Nullable } from "babylonjs/types";
  63510. import { Camera } from "babylonjs/Cameras/camera";
  63511. import { Effect } from "babylonjs/Materials/effect";
  63512. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63513. import { Engine } from "babylonjs/Engines/engine";
  63514. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63515. /**
  63516. * Options to be set when merging outputs from the default pipeline.
  63517. */
  63518. export class DepthOfFieldMergePostProcessOptions {
  63519. /**
  63520. * The original image to merge on top of
  63521. */
  63522. originalFromInput: PostProcess;
  63523. /**
  63524. * Parameters to perform the merge of the depth of field effect
  63525. */
  63526. depthOfField?: {
  63527. circleOfConfusion: PostProcess;
  63528. blurSteps: Array<PostProcess>;
  63529. };
  63530. /**
  63531. * Parameters to perform the merge of bloom effect
  63532. */
  63533. bloom?: {
  63534. blurred: PostProcess;
  63535. weight: number;
  63536. };
  63537. }
  63538. /**
  63539. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63540. */
  63541. export class DepthOfFieldMergePostProcess extends PostProcess {
  63542. private blurSteps;
  63543. /**
  63544. * Creates a new instance of DepthOfFieldMergePostProcess
  63545. * @param name The name of the effect.
  63546. * @param originalFromInput Post process which's input will be used for the merge.
  63547. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63548. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63549. * @param options The required width/height ratio to downsize to before computing the render pass.
  63550. * @param camera The camera to apply the render pass to.
  63551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63552. * @param engine The engine which the post process will be applied. (default: current engine)
  63553. * @param reusable If the post process can be reused on the same frame. (default: false)
  63554. * @param textureType Type of textures used when performing the post process. (default: 0)
  63555. * @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)
  63556. */
  63557. 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);
  63558. /**
  63559. * Updates the effect with the current post process compile time values and recompiles the shader.
  63560. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63561. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63562. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63563. * @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
  63564. * @param onCompiled Called when the shader has been compiled.
  63565. * @param onError Called if there is an error when compiling a shader.
  63566. */
  63567. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63568. }
  63569. }
  63570. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63571. import { Nullable } from "babylonjs/types";
  63572. import { Camera } from "babylonjs/Cameras/camera";
  63573. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63574. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63575. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63576. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63577. import { Scene } from "babylonjs/scene";
  63578. /**
  63579. * Specifies the level of max blur that should be applied when using the depth of field effect
  63580. */
  63581. export enum DepthOfFieldEffectBlurLevel {
  63582. /**
  63583. * Subtle blur
  63584. */
  63585. Low = 0,
  63586. /**
  63587. * Medium blur
  63588. */
  63589. Medium = 1,
  63590. /**
  63591. * Large blur
  63592. */
  63593. High = 2
  63594. }
  63595. /**
  63596. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63597. */
  63598. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63599. private _circleOfConfusion;
  63600. /**
  63601. * @hidden Internal, blurs from high to low
  63602. */
  63603. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63604. private _depthOfFieldBlurY;
  63605. private _dofMerge;
  63606. /**
  63607. * @hidden Internal post processes in depth of field effect
  63608. */
  63609. _effects: Array<PostProcess>;
  63610. /**
  63611. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63612. */
  63613. focalLength: number;
  63614. /**
  63615. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63616. */
  63617. fStop: number;
  63618. /**
  63619. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63620. */
  63621. focusDistance: number;
  63622. /**
  63623. * 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.
  63624. */
  63625. lensSize: number;
  63626. /**
  63627. * Creates a new instance DepthOfFieldEffect
  63628. * @param scene The scene the effect belongs to.
  63629. * @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.
  63630. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63631. * @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)
  63632. */
  63633. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63634. /**
  63635. * Get the current class name of the current effet
  63636. * @returns "DepthOfFieldEffect"
  63637. */
  63638. getClassName(): string;
  63639. /**
  63640. * 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.
  63641. */
  63642. depthTexture: RenderTargetTexture;
  63643. /**
  63644. * Disposes each of the internal effects for a given camera.
  63645. * @param camera The camera to dispose the effect on.
  63646. */
  63647. disposeEffects(camera: Camera): void;
  63648. /**
  63649. * @hidden Internal
  63650. */
  63651. _updateEffects(): void;
  63652. /**
  63653. * Internal
  63654. * @returns if all the contained post processes are ready.
  63655. * @hidden
  63656. */
  63657. _isReady(): boolean;
  63658. }
  63659. }
  63660. declare module "babylonjs/Shaders/displayPass.fragment" {
  63661. /** @hidden */
  63662. export var displayPassPixelShader: {
  63663. name: string;
  63664. shader: string;
  63665. };
  63666. }
  63667. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63668. import { Nullable } from "babylonjs/types";
  63669. import { Camera } from "babylonjs/Cameras/camera";
  63670. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63671. import { Engine } from "babylonjs/Engines/engine";
  63672. import "babylonjs/Shaders/displayPass.fragment";
  63673. /**
  63674. * DisplayPassPostProcess which produces an output the same as it's input
  63675. */
  63676. export class DisplayPassPostProcess extends PostProcess {
  63677. /**
  63678. * Creates the DisplayPassPostProcess
  63679. * @param name The name of the effect.
  63680. * @param options The required width/height ratio to downsize to before computing the render pass.
  63681. * @param camera The camera to apply the render pass to.
  63682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63683. * @param engine The engine which the post process will be applied. (default: current engine)
  63684. * @param reusable If the post process can be reused on the same frame. (default: false)
  63685. */
  63686. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63687. }
  63688. }
  63689. declare module "babylonjs/Shaders/filter.fragment" {
  63690. /** @hidden */
  63691. export var filterPixelShader: {
  63692. name: string;
  63693. shader: string;
  63694. };
  63695. }
  63696. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63697. import { Nullable } from "babylonjs/types";
  63698. import { Matrix } from "babylonjs/Maths/math.vector";
  63699. import { Camera } from "babylonjs/Cameras/camera";
  63700. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63701. import { Engine } from "babylonjs/Engines/engine";
  63702. import "babylonjs/Shaders/filter.fragment";
  63703. /**
  63704. * Applies a kernel filter to the image
  63705. */
  63706. export class FilterPostProcess extends PostProcess {
  63707. /** The matrix to be applied to the image */
  63708. kernelMatrix: Matrix;
  63709. /**
  63710. *
  63711. * @param name The name of the effect.
  63712. * @param kernelMatrix The matrix to be applied to the image
  63713. * @param options The required width/height ratio to downsize to before computing the render pass.
  63714. * @param camera The camera to apply the render pass to.
  63715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63716. * @param engine The engine which the post process will be applied. (default: current engine)
  63717. * @param reusable If the post process can be reused on the same frame. (default: false)
  63718. */
  63719. constructor(name: string,
  63720. /** The matrix to be applied to the image */
  63721. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63722. }
  63723. }
  63724. declare module "babylonjs/Shaders/fxaa.fragment" {
  63725. /** @hidden */
  63726. export var fxaaPixelShader: {
  63727. name: string;
  63728. shader: string;
  63729. };
  63730. }
  63731. declare module "babylonjs/Shaders/fxaa.vertex" {
  63732. /** @hidden */
  63733. export var fxaaVertexShader: {
  63734. name: string;
  63735. shader: string;
  63736. };
  63737. }
  63738. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63739. import { Nullable } from "babylonjs/types";
  63740. import { Camera } from "babylonjs/Cameras/camera";
  63741. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63742. import { Engine } from "babylonjs/Engines/engine";
  63743. import "babylonjs/Shaders/fxaa.fragment";
  63744. import "babylonjs/Shaders/fxaa.vertex";
  63745. /**
  63746. * Fxaa post process
  63747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63748. */
  63749. export class FxaaPostProcess extends PostProcess {
  63750. /** @hidden */
  63751. texelWidth: number;
  63752. /** @hidden */
  63753. texelHeight: number;
  63754. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63755. private _getDefines;
  63756. }
  63757. }
  63758. declare module "babylonjs/Shaders/grain.fragment" {
  63759. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63760. /** @hidden */
  63761. export var grainPixelShader: {
  63762. name: string;
  63763. shader: string;
  63764. };
  63765. }
  63766. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63767. import { Nullable } from "babylonjs/types";
  63768. import { Camera } from "babylonjs/Cameras/camera";
  63769. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63770. import { Engine } from "babylonjs/Engines/engine";
  63771. import "babylonjs/Shaders/grain.fragment";
  63772. /**
  63773. * The GrainPostProcess adds noise to the image at mid luminance levels
  63774. */
  63775. export class GrainPostProcess extends PostProcess {
  63776. /**
  63777. * The intensity of the grain added (default: 30)
  63778. */
  63779. intensity: number;
  63780. /**
  63781. * If the grain should be randomized on every frame
  63782. */
  63783. animated: boolean;
  63784. /**
  63785. * Creates a new instance of @see GrainPostProcess
  63786. * @param name The name of the effect.
  63787. * @param options The required width/height ratio to downsize to before computing the render pass.
  63788. * @param camera The camera to apply the render pass to.
  63789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63790. * @param engine The engine which the post process will be applied. (default: current engine)
  63791. * @param reusable If the post process can be reused on the same frame. (default: false)
  63792. * @param textureType Type of textures used when performing the post process. (default: 0)
  63793. * @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)
  63794. */
  63795. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63796. }
  63797. }
  63798. declare module "babylonjs/Shaders/highlights.fragment" {
  63799. /** @hidden */
  63800. export var highlightsPixelShader: {
  63801. name: string;
  63802. shader: string;
  63803. };
  63804. }
  63805. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63806. import { Nullable } from "babylonjs/types";
  63807. import { Camera } from "babylonjs/Cameras/camera";
  63808. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63809. import { Engine } from "babylonjs/Engines/engine";
  63810. import "babylonjs/Shaders/highlights.fragment";
  63811. /**
  63812. * Extracts highlights from the image
  63813. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63814. */
  63815. export class HighlightsPostProcess extends PostProcess {
  63816. /**
  63817. * Extracts highlights from the image
  63818. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63819. * @param name The name of the effect.
  63820. * @param options The required width/height ratio to downsize to before computing the render pass.
  63821. * @param camera The camera to apply the render pass to.
  63822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63823. * @param engine The engine which the post process will be applied. (default: current engine)
  63824. * @param reusable If the post process can be reused on the same frame. (default: false)
  63825. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63826. */
  63827. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63828. }
  63829. }
  63830. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63831. /** @hidden */
  63832. export var mrtFragmentDeclaration: {
  63833. name: string;
  63834. shader: string;
  63835. };
  63836. }
  63837. declare module "babylonjs/Shaders/geometry.fragment" {
  63838. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63839. /** @hidden */
  63840. export var geometryPixelShader: {
  63841. name: string;
  63842. shader: string;
  63843. };
  63844. }
  63845. declare module "babylonjs/Shaders/geometry.vertex" {
  63846. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63847. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63848. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63849. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63850. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63851. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63852. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63853. /** @hidden */
  63854. export var geometryVertexShader: {
  63855. name: string;
  63856. shader: string;
  63857. };
  63858. }
  63859. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63860. import { Matrix } from "babylonjs/Maths/math.vector";
  63861. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63862. import { Mesh } from "babylonjs/Meshes/mesh";
  63863. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63864. import { Effect } from "babylonjs/Materials/effect";
  63865. import { Scene } from "babylonjs/scene";
  63866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63867. import "babylonjs/Shaders/geometry.fragment";
  63868. import "babylonjs/Shaders/geometry.vertex";
  63869. /** @hidden */
  63870. interface ISavedTransformationMatrix {
  63871. world: Matrix;
  63872. viewProjection: Matrix;
  63873. }
  63874. /**
  63875. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63876. */
  63877. export class GeometryBufferRenderer {
  63878. /**
  63879. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63880. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63881. */
  63882. static readonly POSITION_TEXTURE_TYPE: number;
  63883. /**
  63884. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63885. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63886. */
  63887. static readonly VELOCITY_TEXTURE_TYPE: number;
  63888. /**
  63889. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63890. * in order to compute objects velocities when enableVelocity is set to "true"
  63891. * @hidden
  63892. */
  63893. _previousTransformationMatrices: {
  63894. [index: number]: ISavedTransformationMatrix;
  63895. };
  63896. /**
  63897. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63898. * in order to compute objects velocities when enableVelocity is set to "true"
  63899. * @hidden
  63900. */
  63901. _previousBonesTransformationMatrices: {
  63902. [index: number]: Float32Array;
  63903. };
  63904. /**
  63905. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63906. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63907. */
  63908. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63909. private _scene;
  63910. private _multiRenderTarget;
  63911. private _ratio;
  63912. private _enablePosition;
  63913. private _enableVelocity;
  63914. private _positionIndex;
  63915. private _velocityIndex;
  63916. protected _effect: Effect;
  63917. protected _cachedDefines: string;
  63918. /**
  63919. * Set the render list (meshes to be rendered) used in the G buffer.
  63920. */
  63921. renderList: Mesh[];
  63922. /**
  63923. * Gets wether or not G buffer are supported by the running hardware.
  63924. * This requires draw buffer supports
  63925. */
  63926. readonly isSupported: boolean;
  63927. /**
  63928. * Returns the index of the given texture type in the G-Buffer textures array
  63929. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63930. * @returns the index of the given texture type in the G-Buffer textures array
  63931. */
  63932. getTextureIndex(textureType: number): number;
  63933. /**
  63934. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63935. */
  63936. /**
  63937. * Sets whether or not objects positions are enabled for the G buffer.
  63938. */
  63939. enablePosition: boolean;
  63940. /**
  63941. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63942. */
  63943. /**
  63944. * Sets wether or not objects velocities are enabled for the G buffer.
  63945. */
  63946. enableVelocity: boolean;
  63947. /**
  63948. * Gets the scene associated with the buffer.
  63949. */
  63950. readonly scene: Scene;
  63951. /**
  63952. * Gets the ratio used by the buffer during its creation.
  63953. * How big is the buffer related to the main canvas.
  63954. */
  63955. readonly ratio: number;
  63956. /** @hidden */
  63957. static _SceneComponentInitialization: (scene: Scene) => void;
  63958. /**
  63959. * Creates a new G Buffer for the scene
  63960. * @param scene The scene the buffer belongs to
  63961. * @param ratio How big is the buffer related to the main canvas.
  63962. */
  63963. constructor(scene: Scene, ratio?: number);
  63964. /**
  63965. * Checks wether everything is ready to render a submesh to the G buffer.
  63966. * @param subMesh the submesh to check readiness for
  63967. * @param useInstances is the mesh drawn using instance or not
  63968. * @returns true if ready otherwise false
  63969. */
  63970. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63971. /**
  63972. * Gets the current underlying G Buffer.
  63973. * @returns the buffer
  63974. */
  63975. getGBuffer(): MultiRenderTarget;
  63976. /**
  63977. * Gets the number of samples used to render the buffer (anti aliasing).
  63978. */
  63979. /**
  63980. * Sets the number of samples used to render the buffer (anti aliasing).
  63981. */
  63982. samples: number;
  63983. /**
  63984. * Disposes the renderer and frees up associated resources.
  63985. */
  63986. dispose(): void;
  63987. protected _createRenderTargets(): void;
  63988. private _copyBonesTransformationMatrices;
  63989. }
  63990. }
  63991. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63992. import { Nullable } from "babylonjs/types";
  63993. import { Scene } from "babylonjs/scene";
  63994. import { ISceneComponent } from "babylonjs/sceneComponent";
  63995. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63996. module "babylonjs/scene" {
  63997. interface Scene {
  63998. /** @hidden (Backing field) */
  63999. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64000. /**
  64001. * Gets or Sets the current geometry buffer associated to the scene.
  64002. */
  64003. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64004. /**
  64005. * Enables a GeometryBufferRender and associates it with the scene
  64006. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64007. * @returns the GeometryBufferRenderer
  64008. */
  64009. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64010. /**
  64011. * Disables the GeometryBufferRender associated with the scene
  64012. */
  64013. disableGeometryBufferRenderer(): void;
  64014. }
  64015. }
  64016. /**
  64017. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64018. * in several rendering techniques.
  64019. */
  64020. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64021. /**
  64022. * The component name helpful to identify the component in the list of scene components.
  64023. */
  64024. readonly name: string;
  64025. /**
  64026. * The scene the component belongs to.
  64027. */
  64028. scene: Scene;
  64029. /**
  64030. * Creates a new instance of the component for the given scene
  64031. * @param scene Defines the scene to register the component in
  64032. */
  64033. constructor(scene: Scene);
  64034. /**
  64035. * Registers the component in a given scene
  64036. */
  64037. register(): void;
  64038. /**
  64039. * Rebuilds the elements related to this component in case of
  64040. * context lost for instance.
  64041. */
  64042. rebuild(): void;
  64043. /**
  64044. * Disposes the component and the associated ressources
  64045. */
  64046. dispose(): void;
  64047. private _gatherRenderTargets;
  64048. }
  64049. }
  64050. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64051. /** @hidden */
  64052. export var motionBlurPixelShader: {
  64053. name: string;
  64054. shader: string;
  64055. };
  64056. }
  64057. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64058. import { Nullable } from "babylonjs/types";
  64059. import { Camera } from "babylonjs/Cameras/camera";
  64060. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64061. import { Scene } from "babylonjs/scene";
  64062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64063. import "babylonjs/Animations/animatable";
  64064. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64065. import "babylonjs/Shaders/motionBlur.fragment";
  64066. import { Engine } from "babylonjs/Engines/engine";
  64067. /**
  64068. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64069. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64070. * As an example, all you have to do is to create the post-process:
  64071. * var mb = new BABYLON.MotionBlurPostProcess(
  64072. * 'mb', // The name of the effect.
  64073. * scene, // The scene containing the objects to blur according to their velocity.
  64074. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64075. * camera // The camera to apply the render pass to.
  64076. * );
  64077. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64078. */
  64079. export class MotionBlurPostProcess extends PostProcess {
  64080. /**
  64081. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64082. */
  64083. motionStrength: number;
  64084. /**
  64085. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64086. */
  64087. /**
  64088. * Sets the number of iterations to be used for motion blur quality
  64089. */
  64090. motionBlurSamples: number;
  64091. private _motionBlurSamples;
  64092. private _geometryBufferRenderer;
  64093. /**
  64094. * Creates a new instance MotionBlurPostProcess
  64095. * @param name The name of the effect.
  64096. * @param scene The scene containing the objects to blur according to their velocity.
  64097. * @param options The required width/height ratio to downsize to before computing the render pass.
  64098. * @param camera The camera to apply the render pass to.
  64099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64100. * @param engine The engine which the post process will be applied. (default: current engine)
  64101. * @param reusable If the post process can be reused on the same frame. (default: false)
  64102. * @param textureType Type of textures used when performing the post process. (default: 0)
  64103. * @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)
  64104. */
  64105. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64106. /**
  64107. * Excludes the given skinned mesh from computing bones velocities.
  64108. * 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.
  64109. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64110. */
  64111. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64112. /**
  64113. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64114. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64115. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64116. */
  64117. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64118. /**
  64119. * Disposes the post process.
  64120. * @param camera The camera to dispose the post process on.
  64121. */
  64122. dispose(camera?: Camera): void;
  64123. }
  64124. }
  64125. declare module "babylonjs/Shaders/refraction.fragment" {
  64126. /** @hidden */
  64127. export var refractionPixelShader: {
  64128. name: string;
  64129. shader: string;
  64130. };
  64131. }
  64132. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64133. import { Color3 } from "babylonjs/Maths/math.color";
  64134. import { Camera } from "babylonjs/Cameras/camera";
  64135. import { Texture } from "babylonjs/Materials/Textures/texture";
  64136. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64137. import { Engine } from "babylonjs/Engines/engine";
  64138. import "babylonjs/Shaders/refraction.fragment";
  64139. /**
  64140. * Post process which applies a refractin texture
  64141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64142. */
  64143. export class RefractionPostProcess extends PostProcess {
  64144. /** the base color of the refraction (used to taint the rendering) */
  64145. color: Color3;
  64146. /** simulated refraction depth */
  64147. depth: number;
  64148. /** the coefficient of the base color (0 to remove base color tainting) */
  64149. colorLevel: number;
  64150. private _refTexture;
  64151. private _ownRefractionTexture;
  64152. /**
  64153. * Gets or sets the refraction texture
  64154. * Please note that you are responsible for disposing the texture if you set it manually
  64155. */
  64156. refractionTexture: Texture;
  64157. /**
  64158. * Initializes the RefractionPostProcess
  64159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64160. * @param name The name of the effect.
  64161. * @param refractionTextureUrl Url of the refraction texture to use
  64162. * @param color the base color of the refraction (used to taint the rendering)
  64163. * @param depth simulated refraction depth
  64164. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64165. * @param camera The camera to apply the render pass to.
  64166. * @param options The required width/height ratio to downsize to before computing the render pass.
  64167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64168. * @param engine The engine which the post process will be applied. (default: current engine)
  64169. * @param reusable If the post process can be reused on the same frame. (default: false)
  64170. */
  64171. constructor(name: string, refractionTextureUrl: string,
  64172. /** the base color of the refraction (used to taint the rendering) */
  64173. color: Color3,
  64174. /** simulated refraction depth */
  64175. depth: number,
  64176. /** the coefficient of the base color (0 to remove base color tainting) */
  64177. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64178. /**
  64179. * Disposes of the post process
  64180. * @param camera Camera to dispose post process on
  64181. */
  64182. dispose(camera: Camera): void;
  64183. }
  64184. }
  64185. declare module "babylonjs/Shaders/sharpen.fragment" {
  64186. /** @hidden */
  64187. export var sharpenPixelShader: {
  64188. name: string;
  64189. shader: string;
  64190. };
  64191. }
  64192. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64193. import { Nullable } from "babylonjs/types";
  64194. import { Camera } from "babylonjs/Cameras/camera";
  64195. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64196. import "babylonjs/Shaders/sharpen.fragment";
  64197. import { Engine } from "babylonjs/Engines/engine";
  64198. /**
  64199. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64200. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64201. */
  64202. export class SharpenPostProcess extends PostProcess {
  64203. /**
  64204. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64205. */
  64206. colorAmount: number;
  64207. /**
  64208. * How much sharpness should be applied (default: 0.3)
  64209. */
  64210. edgeAmount: number;
  64211. /**
  64212. * Creates a new instance ConvolutionPostProcess
  64213. * @param name The name of the effect.
  64214. * @param options The required width/height ratio to downsize to before computing the render pass.
  64215. * @param camera The camera to apply the render pass to.
  64216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64217. * @param engine The engine which the post process will be applied. (default: current engine)
  64218. * @param reusable If the post process can be reused on the same frame. (default: false)
  64219. * @param textureType Type of textures used when performing the post process. (default: 0)
  64220. * @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)
  64221. */
  64222. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64223. }
  64224. }
  64225. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64226. import { Nullable } from "babylonjs/types";
  64227. import { Camera } from "babylonjs/Cameras/camera";
  64228. import { Engine } from "babylonjs/Engines/engine";
  64229. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64230. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64231. /**
  64232. * PostProcessRenderPipeline
  64233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64234. */
  64235. export class PostProcessRenderPipeline {
  64236. private engine;
  64237. private _renderEffects;
  64238. private _renderEffectsForIsolatedPass;
  64239. /**
  64240. * List of inspectable custom properties (used by the Inspector)
  64241. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64242. */
  64243. inspectableCustomProperties: IInspectable[];
  64244. /**
  64245. * @hidden
  64246. */
  64247. protected _cameras: Camera[];
  64248. /** @hidden */
  64249. _name: string;
  64250. /**
  64251. * Gets pipeline name
  64252. */
  64253. readonly name: string;
  64254. /** Gets the list of attached cameras */
  64255. readonly cameras: Camera[];
  64256. /**
  64257. * Initializes a PostProcessRenderPipeline
  64258. * @param engine engine to add the pipeline to
  64259. * @param name name of the pipeline
  64260. */
  64261. constructor(engine: Engine, name: string);
  64262. /**
  64263. * Gets the class name
  64264. * @returns "PostProcessRenderPipeline"
  64265. */
  64266. getClassName(): string;
  64267. /**
  64268. * If all the render effects in the pipeline are supported
  64269. */
  64270. readonly isSupported: boolean;
  64271. /**
  64272. * Adds an effect to the pipeline
  64273. * @param renderEffect the effect to add
  64274. */
  64275. addEffect(renderEffect: PostProcessRenderEffect): void;
  64276. /** @hidden */
  64277. _rebuild(): void;
  64278. /** @hidden */
  64279. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64280. /** @hidden */
  64281. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64282. /** @hidden */
  64283. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64284. /** @hidden */
  64285. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64286. /** @hidden */
  64287. _attachCameras(cameras: Camera, unique: boolean): void;
  64288. /** @hidden */
  64289. _attachCameras(cameras: Camera[], unique: boolean): void;
  64290. /** @hidden */
  64291. _detachCameras(cameras: Camera): void;
  64292. /** @hidden */
  64293. _detachCameras(cameras: Nullable<Camera[]>): void;
  64294. /** @hidden */
  64295. _update(): void;
  64296. /** @hidden */
  64297. _reset(): void;
  64298. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64299. /**
  64300. * Disposes of the pipeline
  64301. */
  64302. dispose(): void;
  64303. }
  64304. }
  64305. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64306. import { Camera } from "babylonjs/Cameras/camera";
  64307. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64308. /**
  64309. * PostProcessRenderPipelineManager class
  64310. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64311. */
  64312. export class PostProcessRenderPipelineManager {
  64313. private _renderPipelines;
  64314. /**
  64315. * Initializes a PostProcessRenderPipelineManager
  64316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64317. */
  64318. constructor();
  64319. /**
  64320. * Gets the list of supported render pipelines
  64321. */
  64322. readonly supportedPipelines: PostProcessRenderPipeline[];
  64323. /**
  64324. * Adds a pipeline to the manager
  64325. * @param renderPipeline The pipeline to add
  64326. */
  64327. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64328. /**
  64329. * Attaches a camera to the pipeline
  64330. * @param renderPipelineName The name of the pipeline to attach to
  64331. * @param cameras the camera to attach
  64332. * @param unique if the camera can be attached multiple times to the pipeline
  64333. */
  64334. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64335. /**
  64336. * Detaches a camera from the pipeline
  64337. * @param renderPipelineName The name of the pipeline to detach from
  64338. * @param cameras the camera to detach
  64339. */
  64340. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64341. /**
  64342. * Enables an effect by name on a pipeline
  64343. * @param renderPipelineName the name of the pipeline to enable the effect in
  64344. * @param renderEffectName the name of the effect to enable
  64345. * @param cameras the cameras that the effect should be enabled on
  64346. */
  64347. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64348. /**
  64349. * Disables an effect by name on a pipeline
  64350. * @param renderPipelineName the name of the pipeline to disable the effect in
  64351. * @param renderEffectName the name of the effect to disable
  64352. * @param cameras the cameras that the effect should be disabled on
  64353. */
  64354. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64355. /**
  64356. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64357. */
  64358. update(): void;
  64359. /** @hidden */
  64360. _rebuild(): void;
  64361. /**
  64362. * Disposes of the manager and pipelines
  64363. */
  64364. dispose(): void;
  64365. }
  64366. }
  64367. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64368. import { ISceneComponent } from "babylonjs/sceneComponent";
  64369. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64370. import { Scene } from "babylonjs/scene";
  64371. module "babylonjs/scene" {
  64372. interface Scene {
  64373. /** @hidden (Backing field) */
  64374. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64375. /**
  64376. * Gets the postprocess render pipeline manager
  64377. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64378. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64379. */
  64380. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64381. }
  64382. }
  64383. /**
  64384. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64385. */
  64386. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64387. /**
  64388. * The component name helpfull to identify the component in the list of scene components.
  64389. */
  64390. readonly name: string;
  64391. /**
  64392. * The scene the component belongs to.
  64393. */
  64394. scene: Scene;
  64395. /**
  64396. * Creates a new instance of the component for the given scene
  64397. * @param scene Defines the scene to register the component in
  64398. */
  64399. constructor(scene: Scene);
  64400. /**
  64401. * Registers the component in a given scene
  64402. */
  64403. register(): void;
  64404. /**
  64405. * Rebuilds the elements related to this component in case of
  64406. * context lost for instance.
  64407. */
  64408. rebuild(): void;
  64409. /**
  64410. * Disposes the component and the associated ressources
  64411. */
  64412. dispose(): void;
  64413. private _gatherRenderTargets;
  64414. }
  64415. }
  64416. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64417. import { Nullable } from "babylonjs/types";
  64418. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64419. import { Camera } from "babylonjs/Cameras/camera";
  64420. import { IDisposable } from "babylonjs/scene";
  64421. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64422. import { Scene } from "babylonjs/scene";
  64423. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64424. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64425. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64426. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64427. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64428. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64429. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64430. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64431. import { Animation } from "babylonjs/Animations/animation";
  64432. /**
  64433. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64434. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64435. */
  64436. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64437. private _scene;
  64438. private _camerasToBeAttached;
  64439. /**
  64440. * ID of the sharpen post process,
  64441. */
  64442. private readonly SharpenPostProcessId;
  64443. /**
  64444. * @ignore
  64445. * ID of the image processing post process;
  64446. */
  64447. readonly ImageProcessingPostProcessId: string;
  64448. /**
  64449. * @ignore
  64450. * ID of the Fast Approximate Anti-Aliasing post process;
  64451. */
  64452. readonly FxaaPostProcessId: string;
  64453. /**
  64454. * ID of the chromatic aberration post process,
  64455. */
  64456. private readonly ChromaticAberrationPostProcessId;
  64457. /**
  64458. * ID of the grain post process
  64459. */
  64460. private readonly GrainPostProcessId;
  64461. /**
  64462. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64463. */
  64464. sharpen: SharpenPostProcess;
  64465. private _sharpenEffect;
  64466. private bloom;
  64467. /**
  64468. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64469. */
  64470. depthOfField: DepthOfFieldEffect;
  64471. /**
  64472. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64473. */
  64474. fxaa: FxaaPostProcess;
  64475. /**
  64476. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64477. */
  64478. imageProcessing: ImageProcessingPostProcess;
  64479. /**
  64480. * Chromatic aberration post process which will shift rgb colors in the image
  64481. */
  64482. chromaticAberration: ChromaticAberrationPostProcess;
  64483. private _chromaticAberrationEffect;
  64484. /**
  64485. * Grain post process which add noise to the image
  64486. */
  64487. grain: GrainPostProcess;
  64488. private _grainEffect;
  64489. /**
  64490. * Glow post process which adds a glow to emissive areas of the image
  64491. */
  64492. private _glowLayer;
  64493. /**
  64494. * Animations which can be used to tweak settings over a period of time
  64495. */
  64496. animations: Animation[];
  64497. private _imageProcessingConfigurationObserver;
  64498. private _sharpenEnabled;
  64499. private _bloomEnabled;
  64500. private _depthOfFieldEnabled;
  64501. private _depthOfFieldBlurLevel;
  64502. private _fxaaEnabled;
  64503. private _imageProcessingEnabled;
  64504. private _defaultPipelineTextureType;
  64505. private _bloomScale;
  64506. private _chromaticAberrationEnabled;
  64507. private _grainEnabled;
  64508. private _buildAllowed;
  64509. /**
  64510. * Gets active scene
  64511. */
  64512. readonly scene: Scene;
  64513. /**
  64514. * Enable or disable the sharpen process from the pipeline
  64515. */
  64516. sharpenEnabled: boolean;
  64517. private _resizeObserver;
  64518. private _hardwareScaleLevel;
  64519. private _bloomKernel;
  64520. /**
  64521. * Specifies the size of the bloom blur kernel, relative to the final output size
  64522. */
  64523. bloomKernel: number;
  64524. /**
  64525. * Specifies the weight of the bloom in the final rendering
  64526. */
  64527. private _bloomWeight;
  64528. /**
  64529. * Specifies the luma threshold for the area that will be blurred by the bloom
  64530. */
  64531. private _bloomThreshold;
  64532. private _hdr;
  64533. /**
  64534. * The strength of the bloom.
  64535. */
  64536. bloomWeight: number;
  64537. /**
  64538. * The strength of the bloom.
  64539. */
  64540. bloomThreshold: number;
  64541. /**
  64542. * The scale of the bloom, lower value will provide better performance.
  64543. */
  64544. bloomScale: number;
  64545. /**
  64546. * Enable or disable the bloom from the pipeline
  64547. */
  64548. bloomEnabled: boolean;
  64549. private _rebuildBloom;
  64550. /**
  64551. * If the depth of field is enabled.
  64552. */
  64553. depthOfFieldEnabled: boolean;
  64554. /**
  64555. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64556. */
  64557. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64558. /**
  64559. * If the anti aliasing is enabled.
  64560. */
  64561. fxaaEnabled: boolean;
  64562. private _samples;
  64563. /**
  64564. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64565. */
  64566. samples: number;
  64567. /**
  64568. * If image processing is enabled.
  64569. */
  64570. imageProcessingEnabled: boolean;
  64571. /**
  64572. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64573. */
  64574. glowLayerEnabled: boolean;
  64575. /**
  64576. * Gets the glow layer (or null if not defined)
  64577. */
  64578. readonly glowLayer: Nullable<GlowLayer>;
  64579. /**
  64580. * Enable or disable the chromaticAberration process from the pipeline
  64581. */
  64582. chromaticAberrationEnabled: boolean;
  64583. /**
  64584. * Enable or disable the grain process from the pipeline
  64585. */
  64586. grainEnabled: boolean;
  64587. /**
  64588. * @constructor
  64589. * @param name - The rendering pipeline name (default: "")
  64590. * @param hdr - If high dynamic range textures should be used (default: true)
  64591. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64592. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64593. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64594. */
  64595. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64596. /**
  64597. * Get the class name
  64598. * @returns "DefaultRenderingPipeline"
  64599. */
  64600. getClassName(): string;
  64601. /**
  64602. * Force the compilation of the entire pipeline.
  64603. */
  64604. prepare(): void;
  64605. private _hasCleared;
  64606. private _prevPostProcess;
  64607. private _prevPrevPostProcess;
  64608. private _setAutoClearAndTextureSharing;
  64609. private _depthOfFieldSceneObserver;
  64610. private _buildPipeline;
  64611. private _disposePostProcesses;
  64612. /**
  64613. * Adds a camera to the pipeline
  64614. * @param camera the camera to be added
  64615. */
  64616. addCamera(camera: Camera): void;
  64617. /**
  64618. * Removes a camera from the pipeline
  64619. * @param camera the camera to remove
  64620. */
  64621. removeCamera(camera: Camera): void;
  64622. /**
  64623. * Dispose of the pipeline and stop all post processes
  64624. */
  64625. dispose(): void;
  64626. /**
  64627. * Serialize the rendering pipeline (Used when exporting)
  64628. * @returns the serialized object
  64629. */
  64630. serialize(): any;
  64631. /**
  64632. * Parse the serialized pipeline
  64633. * @param source Source pipeline.
  64634. * @param scene The scene to load the pipeline to.
  64635. * @param rootUrl The URL of the serialized pipeline.
  64636. * @returns An instantiated pipeline from the serialized object.
  64637. */
  64638. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64639. }
  64640. }
  64641. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64642. /** @hidden */
  64643. export var lensHighlightsPixelShader: {
  64644. name: string;
  64645. shader: string;
  64646. };
  64647. }
  64648. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64649. /** @hidden */
  64650. export var depthOfFieldPixelShader: {
  64651. name: string;
  64652. shader: string;
  64653. };
  64654. }
  64655. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64656. import { Camera } from "babylonjs/Cameras/camera";
  64657. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64658. import { Scene } from "babylonjs/scene";
  64659. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64660. import "babylonjs/Shaders/chromaticAberration.fragment";
  64661. import "babylonjs/Shaders/lensHighlights.fragment";
  64662. import "babylonjs/Shaders/depthOfField.fragment";
  64663. /**
  64664. * BABYLON.JS Chromatic Aberration GLSL Shader
  64665. * Author: Olivier Guyot
  64666. * Separates very slightly R, G and B colors on the edges of the screen
  64667. * Inspired by Francois Tarlier & Martins Upitis
  64668. */
  64669. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64670. /**
  64671. * @ignore
  64672. * The chromatic aberration PostProcess id in the pipeline
  64673. */
  64674. LensChromaticAberrationEffect: string;
  64675. /**
  64676. * @ignore
  64677. * The highlights enhancing PostProcess id in the pipeline
  64678. */
  64679. HighlightsEnhancingEffect: string;
  64680. /**
  64681. * @ignore
  64682. * The depth-of-field PostProcess id in the pipeline
  64683. */
  64684. LensDepthOfFieldEffect: string;
  64685. private _scene;
  64686. private _depthTexture;
  64687. private _grainTexture;
  64688. private _chromaticAberrationPostProcess;
  64689. private _highlightsPostProcess;
  64690. private _depthOfFieldPostProcess;
  64691. private _edgeBlur;
  64692. private _grainAmount;
  64693. private _chromaticAberration;
  64694. private _distortion;
  64695. private _highlightsGain;
  64696. private _highlightsThreshold;
  64697. private _dofDistance;
  64698. private _dofAperture;
  64699. private _dofDarken;
  64700. private _dofPentagon;
  64701. private _blurNoise;
  64702. /**
  64703. * @constructor
  64704. *
  64705. * Effect parameters are as follow:
  64706. * {
  64707. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64708. * edge_blur: number; // from 0 to x (1 for realism)
  64709. * distortion: number; // from 0 to x (1 for realism)
  64710. * grain_amount: number; // from 0 to 1
  64711. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64712. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64713. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64714. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64715. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64716. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64717. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64718. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64719. * }
  64720. * Note: if an effect parameter is unset, effect is disabled
  64721. *
  64722. * @param name The rendering pipeline name
  64723. * @param parameters - An object containing all parameters (see above)
  64724. * @param scene The scene linked to this pipeline
  64725. * @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)
  64726. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64727. */
  64728. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64729. /**
  64730. * Get the class name
  64731. * @returns "LensRenderingPipeline"
  64732. */
  64733. getClassName(): string;
  64734. /**
  64735. * Gets associated scene
  64736. */
  64737. readonly scene: Scene;
  64738. /**
  64739. * Gets or sets the edge blur
  64740. */
  64741. edgeBlur: number;
  64742. /**
  64743. * Gets or sets the grain amount
  64744. */
  64745. grainAmount: number;
  64746. /**
  64747. * Gets or sets the chromatic aberration amount
  64748. */
  64749. chromaticAberration: number;
  64750. /**
  64751. * Gets or sets the depth of field aperture
  64752. */
  64753. dofAperture: number;
  64754. /**
  64755. * Gets or sets the edge distortion
  64756. */
  64757. edgeDistortion: number;
  64758. /**
  64759. * Gets or sets the depth of field distortion
  64760. */
  64761. dofDistortion: number;
  64762. /**
  64763. * Gets or sets the darken out of focus amount
  64764. */
  64765. darkenOutOfFocus: number;
  64766. /**
  64767. * Gets or sets a boolean indicating if blur noise is enabled
  64768. */
  64769. blurNoise: boolean;
  64770. /**
  64771. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64772. */
  64773. pentagonBokeh: boolean;
  64774. /**
  64775. * Gets or sets the highlight grain amount
  64776. */
  64777. highlightsGain: number;
  64778. /**
  64779. * Gets or sets the highlight threshold
  64780. */
  64781. highlightsThreshold: number;
  64782. /**
  64783. * Sets the amount of blur at the edges
  64784. * @param amount blur amount
  64785. */
  64786. setEdgeBlur(amount: number): void;
  64787. /**
  64788. * Sets edge blur to 0
  64789. */
  64790. disableEdgeBlur(): void;
  64791. /**
  64792. * Sets the amout of grain
  64793. * @param amount Amount of grain
  64794. */
  64795. setGrainAmount(amount: number): void;
  64796. /**
  64797. * Set grain amount to 0
  64798. */
  64799. disableGrain(): void;
  64800. /**
  64801. * Sets the chromatic aberration amount
  64802. * @param amount amount of chromatic aberration
  64803. */
  64804. setChromaticAberration(amount: number): void;
  64805. /**
  64806. * Sets chromatic aberration amount to 0
  64807. */
  64808. disableChromaticAberration(): void;
  64809. /**
  64810. * Sets the EdgeDistortion amount
  64811. * @param amount amount of EdgeDistortion
  64812. */
  64813. setEdgeDistortion(amount: number): void;
  64814. /**
  64815. * Sets edge distortion to 0
  64816. */
  64817. disableEdgeDistortion(): void;
  64818. /**
  64819. * Sets the FocusDistance amount
  64820. * @param amount amount of FocusDistance
  64821. */
  64822. setFocusDistance(amount: number): void;
  64823. /**
  64824. * Disables depth of field
  64825. */
  64826. disableDepthOfField(): void;
  64827. /**
  64828. * Sets the Aperture amount
  64829. * @param amount amount of Aperture
  64830. */
  64831. setAperture(amount: number): void;
  64832. /**
  64833. * Sets the DarkenOutOfFocus amount
  64834. * @param amount amount of DarkenOutOfFocus
  64835. */
  64836. setDarkenOutOfFocus(amount: number): void;
  64837. private _pentagonBokehIsEnabled;
  64838. /**
  64839. * Creates a pentagon bokeh effect
  64840. */
  64841. enablePentagonBokeh(): void;
  64842. /**
  64843. * Disables the pentagon bokeh effect
  64844. */
  64845. disablePentagonBokeh(): void;
  64846. /**
  64847. * Enables noise blur
  64848. */
  64849. enableNoiseBlur(): void;
  64850. /**
  64851. * Disables noise blur
  64852. */
  64853. disableNoiseBlur(): void;
  64854. /**
  64855. * Sets the HighlightsGain amount
  64856. * @param amount amount of HighlightsGain
  64857. */
  64858. setHighlightsGain(amount: number): void;
  64859. /**
  64860. * Sets the HighlightsThreshold amount
  64861. * @param amount amount of HighlightsThreshold
  64862. */
  64863. setHighlightsThreshold(amount: number): void;
  64864. /**
  64865. * Disables highlights
  64866. */
  64867. disableHighlights(): void;
  64868. /**
  64869. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64870. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64871. */
  64872. dispose(disableDepthRender?: boolean): void;
  64873. private _createChromaticAberrationPostProcess;
  64874. private _createHighlightsPostProcess;
  64875. private _createDepthOfFieldPostProcess;
  64876. private _createGrainTexture;
  64877. }
  64878. }
  64879. declare module "babylonjs/Shaders/ssao2.fragment" {
  64880. /** @hidden */
  64881. export var ssao2PixelShader: {
  64882. name: string;
  64883. shader: string;
  64884. };
  64885. }
  64886. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64887. /** @hidden */
  64888. export var ssaoCombinePixelShader: {
  64889. name: string;
  64890. shader: string;
  64891. };
  64892. }
  64893. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64894. import { Camera } from "babylonjs/Cameras/camera";
  64895. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64896. import { Scene } from "babylonjs/scene";
  64897. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64898. import "babylonjs/Shaders/ssao2.fragment";
  64899. import "babylonjs/Shaders/ssaoCombine.fragment";
  64900. /**
  64901. * Render pipeline to produce ssao effect
  64902. */
  64903. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64904. /**
  64905. * @ignore
  64906. * The PassPostProcess id in the pipeline that contains the original scene color
  64907. */
  64908. SSAOOriginalSceneColorEffect: string;
  64909. /**
  64910. * @ignore
  64911. * The SSAO PostProcess id in the pipeline
  64912. */
  64913. SSAORenderEffect: string;
  64914. /**
  64915. * @ignore
  64916. * The horizontal blur PostProcess id in the pipeline
  64917. */
  64918. SSAOBlurHRenderEffect: string;
  64919. /**
  64920. * @ignore
  64921. * The vertical blur PostProcess id in the pipeline
  64922. */
  64923. SSAOBlurVRenderEffect: string;
  64924. /**
  64925. * @ignore
  64926. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64927. */
  64928. SSAOCombineRenderEffect: string;
  64929. /**
  64930. * The output strength of the SSAO post-process. Default value is 1.0.
  64931. */
  64932. totalStrength: number;
  64933. /**
  64934. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64935. */
  64936. maxZ: number;
  64937. /**
  64938. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64939. */
  64940. minZAspect: number;
  64941. private _samples;
  64942. /**
  64943. * Number of samples used for the SSAO calculations. Default value is 8
  64944. */
  64945. samples: number;
  64946. private _textureSamples;
  64947. /**
  64948. * Number of samples to use for antialiasing
  64949. */
  64950. textureSamples: number;
  64951. /**
  64952. * Ratio object used for SSAO ratio and blur ratio
  64953. */
  64954. private _ratio;
  64955. /**
  64956. * Dynamically generated sphere sampler.
  64957. */
  64958. private _sampleSphere;
  64959. /**
  64960. * Blur filter offsets
  64961. */
  64962. private _samplerOffsets;
  64963. private _expensiveBlur;
  64964. /**
  64965. * If bilateral blur should be used
  64966. */
  64967. expensiveBlur: boolean;
  64968. /**
  64969. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64970. */
  64971. radius: number;
  64972. /**
  64973. * The base color of the SSAO post-process
  64974. * The final result is "base + ssao" between [0, 1]
  64975. */
  64976. base: number;
  64977. /**
  64978. * Support test.
  64979. */
  64980. static readonly IsSupported: boolean;
  64981. private _scene;
  64982. private _depthTexture;
  64983. private _normalTexture;
  64984. private _randomTexture;
  64985. private _originalColorPostProcess;
  64986. private _ssaoPostProcess;
  64987. private _blurHPostProcess;
  64988. private _blurVPostProcess;
  64989. private _ssaoCombinePostProcess;
  64990. /**
  64991. * Gets active scene
  64992. */
  64993. readonly scene: Scene;
  64994. /**
  64995. * @constructor
  64996. * @param name The rendering pipeline name
  64997. * @param scene The scene linked to this pipeline
  64998. * @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 }
  64999. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65000. */
  65001. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65002. /**
  65003. * Get the class name
  65004. * @returns "SSAO2RenderingPipeline"
  65005. */
  65006. getClassName(): string;
  65007. /**
  65008. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65009. */
  65010. dispose(disableGeometryBufferRenderer?: boolean): void;
  65011. private _createBlurPostProcess;
  65012. /** @hidden */
  65013. _rebuild(): void;
  65014. private _bits;
  65015. private _radicalInverse_VdC;
  65016. private _hammersley;
  65017. private _hemisphereSample_uniform;
  65018. private _generateHemisphere;
  65019. private _createSSAOPostProcess;
  65020. private _createSSAOCombinePostProcess;
  65021. private _createRandomTexture;
  65022. /**
  65023. * Serialize the rendering pipeline (Used when exporting)
  65024. * @returns the serialized object
  65025. */
  65026. serialize(): any;
  65027. /**
  65028. * Parse the serialized pipeline
  65029. * @param source Source pipeline.
  65030. * @param scene The scene to load the pipeline to.
  65031. * @param rootUrl The URL of the serialized pipeline.
  65032. * @returns An instantiated pipeline from the serialized object.
  65033. */
  65034. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65035. }
  65036. }
  65037. declare module "babylonjs/Shaders/ssao.fragment" {
  65038. /** @hidden */
  65039. export var ssaoPixelShader: {
  65040. name: string;
  65041. shader: string;
  65042. };
  65043. }
  65044. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65045. import { Camera } from "babylonjs/Cameras/camera";
  65046. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65047. import { Scene } from "babylonjs/scene";
  65048. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65049. import "babylonjs/Shaders/ssao.fragment";
  65050. import "babylonjs/Shaders/ssaoCombine.fragment";
  65051. /**
  65052. * Render pipeline to produce ssao effect
  65053. */
  65054. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65055. /**
  65056. * @ignore
  65057. * The PassPostProcess id in the pipeline that contains the original scene color
  65058. */
  65059. SSAOOriginalSceneColorEffect: string;
  65060. /**
  65061. * @ignore
  65062. * The SSAO PostProcess id in the pipeline
  65063. */
  65064. SSAORenderEffect: string;
  65065. /**
  65066. * @ignore
  65067. * The horizontal blur PostProcess id in the pipeline
  65068. */
  65069. SSAOBlurHRenderEffect: string;
  65070. /**
  65071. * @ignore
  65072. * The vertical blur PostProcess id in the pipeline
  65073. */
  65074. SSAOBlurVRenderEffect: string;
  65075. /**
  65076. * @ignore
  65077. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65078. */
  65079. SSAOCombineRenderEffect: string;
  65080. /**
  65081. * The output strength of the SSAO post-process. Default value is 1.0.
  65082. */
  65083. totalStrength: number;
  65084. /**
  65085. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65086. */
  65087. radius: number;
  65088. /**
  65089. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65090. * Must not be equal to fallOff and superior to fallOff.
  65091. * Default value is 0.0075
  65092. */
  65093. area: number;
  65094. /**
  65095. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65096. * Must not be equal to area and inferior to area.
  65097. * Default value is 0.000001
  65098. */
  65099. fallOff: number;
  65100. /**
  65101. * The base color of the SSAO post-process
  65102. * The final result is "base + ssao" between [0, 1]
  65103. */
  65104. base: number;
  65105. private _scene;
  65106. private _depthTexture;
  65107. private _randomTexture;
  65108. private _originalColorPostProcess;
  65109. private _ssaoPostProcess;
  65110. private _blurHPostProcess;
  65111. private _blurVPostProcess;
  65112. private _ssaoCombinePostProcess;
  65113. private _firstUpdate;
  65114. /**
  65115. * Gets active scene
  65116. */
  65117. readonly scene: Scene;
  65118. /**
  65119. * @constructor
  65120. * @param name - The rendering pipeline name
  65121. * @param scene - The scene linked to this pipeline
  65122. * @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 }
  65123. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65124. */
  65125. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65126. /**
  65127. * Get the class name
  65128. * @returns "SSAORenderingPipeline"
  65129. */
  65130. getClassName(): string;
  65131. /**
  65132. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65133. */
  65134. dispose(disableDepthRender?: boolean): void;
  65135. private _createBlurPostProcess;
  65136. /** @hidden */
  65137. _rebuild(): void;
  65138. private _createSSAOPostProcess;
  65139. private _createSSAOCombinePostProcess;
  65140. private _createRandomTexture;
  65141. }
  65142. }
  65143. declare module "babylonjs/Shaders/standard.fragment" {
  65144. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65145. /** @hidden */
  65146. export var standardPixelShader: {
  65147. name: string;
  65148. shader: string;
  65149. };
  65150. }
  65151. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65152. import { Nullable } from "babylonjs/types";
  65153. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65154. import { Camera } from "babylonjs/Cameras/camera";
  65155. import { Texture } from "babylonjs/Materials/Textures/texture";
  65156. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65157. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65158. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65159. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65160. import { IDisposable } from "babylonjs/scene";
  65161. import { SpotLight } from "babylonjs/Lights/spotLight";
  65162. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65163. import { Scene } from "babylonjs/scene";
  65164. import { Animation } from "babylonjs/Animations/animation";
  65165. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65166. import "babylonjs/Shaders/standard.fragment";
  65167. /**
  65168. * Standard rendering pipeline
  65169. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65170. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65171. */
  65172. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65173. /**
  65174. * Public members
  65175. */
  65176. /**
  65177. * Post-process which contains the original scene color before the pipeline applies all the effects
  65178. */
  65179. originalPostProcess: Nullable<PostProcess>;
  65180. /**
  65181. * Post-process used to down scale an image x4
  65182. */
  65183. downSampleX4PostProcess: Nullable<PostProcess>;
  65184. /**
  65185. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65186. */
  65187. brightPassPostProcess: Nullable<PostProcess>;
  65188. /**
  65189. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65190. */
  65191. blurHPostProcesses: PostProcess[];
  65192. /**
  65193. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65194. */
  65195. blurVPostProcesses: PostProcess[];
  65196. /**
  65197. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65198. */
  65199. textureAdderPostProcess: Nullable<PostProcess>;
  65200. /**
  65201. * Post-process used to create volumetric lighting effect
  65202. */
  65203. volumetricLightPostProcess: Nullable<PostProcess>;
  65204. /**
  65205. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65206. */
  65207. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65208. /**
  65209. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65210. */
  65211. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65212. /**
  65213. * Post-process used to merge the volumetric light effect and the real scene color
  65214. */
  65215. volumetricLightMergePostProces: Nullable<PostProcess>;
  65216. /**
  65217. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65218. */
  65219. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65220. /**
  65221. * Base post-process used to calculate the average luminance of the final image for HDR
  65222. */
  65223. luminancePostProcess: Nullable<PostProcess>;
  65224. /**
  65225. * Post-processes used to create down sample post-processes in order to get
  65226. * the average luminance of the final image for HDR
  65227. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65228. */
  65229. luminanceDownSamplePostProcesses: PostProcess[];
  65230. /**
  65231. * Post-process used to create a HDR effect (light adaptation)
  65232. */
  65233. hdrPostProcess: Nullable<PostProcess>;
  65234. /**
  65235. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65236. */
  65237. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65238. /**
  65239. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65240. */
  65241. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65242. /**
  65243. * Post-process used to merge the final HDR post-process and the real scene color
  65244. */
  65245. hdrFinalPostProcess: Nullable<PostProcess>;
  65246. /**
  65247. * Post-process used to create a lens flare effect
  65248. */
  65249. lensFlarePostProcess: Nullable<PostProcess>;
  65250. /**
  65251. * Post-process that merges the result of the lens flare post-process and the real scene color
  65252. */
  65253. lensFlareComposePostProcess: Nullable<PostProcess>;
  65254. /**
  65255. * Post-process used to create a motion blur effect
  65256. */
  65257. motionBlurPostProcess: Nullable<PostProcess>;
  65258. /**
  65259. * Post-process used to create a depth of field effect
  65260. */
  65261. depthOfFieldPostProcess: Nullable<PostProcess>;
  65262. /**
  65263. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65264. */
  65265. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65266. /**
  65267. * Represents the brightness threshold in order to configure the illuminated surfaces
  65268. */
  65269. brightThreshold: number;
  65270. /**
  65271. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65272. */
  65273. blurWidth: number;
  65274. /**
  65275. * Sets if the blur for highlighted surfaces must be only horizontal
  65276. */
  65277. horizontalBlur: boolean;
  65278. /**
  65279. * Gets the overall exposure used by the pipeline
  65280. */
  65281. /**
  65282. * Sets the overall exposure used by the pipeline
  65283. */
  65284. exposure: number;
  65285. /**
  65286. * Texture used typically to simulate "dirty" on camera lens
  65287. */
  65288. lensTexture: Nullable<Texture>;
  65289. /**
  65290. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65291. */
  65292. volumetricLightCoefficient: number;
  65293. /**
  65294. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65295. */
  65296. volumetricLightPower: number;
  65297. /**
  65298. * Used the set the blur intensity to smooth the volumetric lights
  65299. */
  65300. volumetricLightBlurScale: number;
  65301. /**
  65302. * Light (spot or directional) used to generate the volumetric lights rays
  65303. * The source light must have a shadow generate so the pipeline can get its
  65304. * depth map
  65305. */
  65306. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65307. /**
  65308. * For eye adaptation, represents the minimum luminance the eye can see
  65309. */
  65310. hdrMinimumLuminance: number;
  65311. /**
  65312. * For eye adaptation, represents the decrease luminance speed
  65313. */
  65314. hdrDecreaseRate: number;
  65315. /**
  65316. * For eye adaptation, represents the increase luminance speed
  65317. */
  65318. hdrIncreaseRate: number;
  65319. /**
  65320. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65321. */
  65322. /**
  65323. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65324. */
  65325. hdrAutoExposure: boolean;
  65326. /**
  65327. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65328. */
  65329. lensColorTexture: Nullable<Texture>;
  65330. /**
  65331. * The overall strengh for the lens flare effect
  65332. */
  65333. lensFlareStrength: number;
  65334. /**
  65335. * Dispersion coefficient for lens flare ghosts
  65336. */
  65337. lensFlareGhostDispersal: number;
  65338. /**
  65339. * Main lens flare halo width
  65340. */
  65341. lensFlareHaloWidth: number;
  65342. /**
  65343. * Based on the lens distortion effect, defines how much the lens flare result
  65344. * is distorted
  65345. */
  65346. lensFlareDistortionStrength: number;
  65347. /**
  65348. * Configures the blur intensity used for for lens flare (halo)
  65349. */
  65350. lensFlareBlurWidth: number;
  65351. /**
  65352. * Lens star texture must be used to simulate rays on the flares and is available
  65353. * in the documentation
  65354. */
  65355. lensStarTexture: Nullable<Texture>;
  65356. /**
  65357. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65358. * flare effect by taking account of the dirt texture
  65359. */
  65360. lensFlareDirtTexture: Nullable<Texture>;
  65361. /**
  65362. * Represents the focal length for the depth of field effect
  65363. */
  65364. depthOfFieldDistance: number;
  65365. /**
  65366. * Represents the blur intensity for the blurred part of the depth of field effect
  65367. */
  65368. depthOfFieldBlurWidth: number;
  65369. /**
  65370. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65371. */
  65372. /**
  65373. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65374. */
  65375. motionStrength: number;
  65376. /**
  65377. * Gets wether or not the motion blur post-process is object based or screen based.
  65378. */
  65379. /**
  65380. * Sets wether or not the motion blur post-process should be object based or screen based
  65381. */
  65382. objectBasedMotionBlur: boolean;
  65383. /**
  65384. * List of animations for the pipeline (IAnimatable implementation)
  65385. */
  65386. animations: Animation[];
  65387. /**
  65388. * Private members
  65389. */
  65390. private _scene;
  65391. private _currentDepthOfFieldSource;
  65392. private _basePostProcess;
  65393. private _fixedExposure;
  65394. private _currentExposure;
  65395. private _hdrAutoExposure;
  65396. private _hdrCurrentLuminance;
  65397. private _motionStrength;
  65398. private _isObjectBasedMotionBlur;
  65399. private _floatTextureType;
  65400. private _camerasToBeAttached;
  65401. private _ratio;
  65402. private _bloomEnabled;
  65403. private _depthOfFieldEnabled;
  65404. private _vlsEnabled;
  65405. private _lensFlareEnabled;
  65406. private _hdrEnabled;
  65407. private _motionBlurEnabled;
  65408. private _fxaaEnabled;
  65409. private _motionBlurSamples;
  65410. private _volumetricLightStepsCount;
  65411. private _samples;
  65412. /**
  65413. * @ignore
  65414. * Specifies if the bloom pipeline is enabled
  65415. */
  65416. BloomEnabled: boolean;
  65417. /**
  65418. * @ignore
  65419. * Specifies if the depth of field pipeline is enabed
  65420. */
  65421. DepthOfFieldEnabled: boolean;
  65422. /**
  65423. * @ignore
  65424. * Specifies if the lens flare pipeline is enabed
  65425. */
  65426. LensFlareEnabled: boolean;
  65427. /**
  65428. * @ignore
  65429. * Specifies if the HDR pipeline is enabled
  65430. */
  65431. HDREnabled: boolean;
  65432. /**
  65433. * @ignore
  65434. * Specifies if the volumetric lights scattering effect is enabled
  65435. */
  65436. VLSEnabled: boolean;
  65437. /**
  65438. * @ignore
  65439. * Specifies if the motion blur effect is enabled
  65440. */
  65441. MotionBlurEnabled: boolean;
  65442. /**
  65443. * Specifies if anti-aliasing is enabled
  65444. */
  65445. fxaaEnabled: boolean;
  65446. /**
  65447. * Specifies the number of steps used to calculate the volumetric lights
  65448. * Typically in interval [50, 200]
  65449. */
  65450. volumetricLightStepsCount: number;
  65451. /**
  65452. * Specifies the number of samples used for the motion blur effect
  65453. * Typically in interval [16, 64]
  65454. */
  65455. motionBlurSamples: number;
  65456. /**
  65457. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65458. */
  65459. samples: number;
  65460. /**
  65461. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65462. * @constructor
  65463. * @param name The rendering pipeline name
  65464. * @param scene The scene linked to this pipeline
  65465. * @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)
  65466. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65467. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65468. */
  65469. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65470. private _buildPipeline;
  65471. private _createDownSampleX4PostProcess;
  65472. private _createBrightPassPostProcess;
  65473. private _createBlurPostProcesses;
  65474. private _createTextureAdderPostProcess;
  65475. private _createVolumetricLightPostProcess;
  65476. private _createLuminancePostProcesses;
  65477. private _createHdrPostProcess;
  65478. private _createLensFlarePostProcess;
  65479. private _createDepthOfFieldPostProcess;
  65480. private _createMotionBlurPostProcess;
  65481. private _getDepthTexture;
  65482. private _disposePostProcesses;
  65483. /**
  65484. * Dispose of the pipeline and stop all post processes
  65485. */
  65486. dispose(): void;
  65487. /**
  65488. * Serialize the rendering pipeline (Used when exporting)
  65489. * @returns the serialized object
  65490. */
  65491. serialize(): any;
  65492. /**
  65493. * Parse the serialized pipeline
  65494. * @param source Source pipeline.
  65495. * @param scene The scene to load the pipeline to.
  65496. * @param rootUrl The URL of the serialized pipeline.
  65497. * @returns An instantiated pipeline from the serialized object.
  65498. */
  65499. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65500. /**
  65501. * Luminance steps
  65502. */
  65503. static LuminanceSteps: number;
  65504. }
  65505. }
  65506. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65507. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65508. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65509. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65510. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65511. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65512. }
  65513. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65514. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65515. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65516. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65517. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65518. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65519. }
  65520. declare module "babylonjs/Shaders/tonemap.fragment" {
  65521. /** @hidden */
  65522. export var tonemapPixelShader: {
  65523. name: string;
  65524. shader: string;
  65525. };
  65526. }
  65527. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65528. import { Camera } from "babylonjs/Cameras/camera";
  65529. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65530. import "babylonjs/Shaders/tonemap.fragment";
  65531. import { Engine } from "babylonjs/Engines/engine";
  65532. /** Defines operator used for tonemapping */
  65533. export enum TonemappingOperator {
  65534. /** Hable */
  65535. Hable = 0,
  65536. /** Reinhard */
  65537. Reinhard = 1,
  65538. /** HejiDawson */
  65539. HejiDawson = 2,
  65540. /** Photographic */
  65541. Photographic = 3
  65542. }
  65543. /**
  65544. * Defines a post process to apply tone mapping
  65545. */
  65546. export class TonemapPostProcess extends PostProcess {
  65547. private _operator;
  65548. /** Defines the required exposure adjustement */
  65549. exposureAdjustment: number;
  65550. /**
  65551. * Creates a new TonemapPostProcess
  65552. * @param name defines the name of the postprocess
  65553. * @param _operator defines the operator to use
  65554. * @param exposureAdjustment defines the required exposure adjustement
  65555. * @param camera defines the camera to use (can be null)
  65556. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65557. * @param engine defines the hosting engine (can be ignore if camera is set)
  65558. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65559. */
  65560. constructor(name: string, _operator: TonemappingOperator,
  65561. /** Defines the required exposure adjustement */
  65562. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65563. }
  65564. }
  65565. declare module "babylonjs/Shaders/depth.vertex" {
  65566. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65567. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65569. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65570. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65571. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65572. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65573. /** @hidden */
  65574. export var depthVertexShader: {
  65575. name: string;
  65576. shader: string;
  65577. };
  65578. }
  65579. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65580. /** @hidden */
  65581. export var volumetricLightScatteringPixelShader: {
  65582. name: string;
  65583. shader: string;
  65584. };
  65585. }
  65586. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65587. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65588. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65589. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65590. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65591. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65592. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65593. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65594. /** @hidden */
  65595. export var volumetricLightScatteringPassVertexShader: {
  65596. name: string;
  65597. shader: string;
  65598. };
  65599. }
  65600. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65601. /** @hidden */
  65602. export var volumetricLightScatteringPassPixelShader: {
  65603. name: string;
  65604. shader: string;
  65605. };
  65606. }
  65607. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65608. import { Vector3 } from "babylonjs/Maths/math.vector";
  65609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65610. import { Mesh } from "babylonjs/Meshes/mesh";
  65611. import { Camera } from "babylonjs/Cameras/camera";
  65612. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65613. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65614. import { Scene } from "babylonjs/scene";
  65615. import "babylonjs/Meshes/Builders/planeBuilder";
  65616. import "babylonjs/Shaders/depth.vertex";
  65617. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65618. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65619. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65620. import { Engine } from "babylonjs/Engines/engine";
  65621. /**
  65622. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65623. */
  65624. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65625. private _volumetricLightScatteringPass;
  65626. private _volumetricLightScatteringRTT;
  65627. private _viewPort;
  65628. private _screenCoordinates;
  65629. private _cachedDefines;
  65630. /**
  65631. * If not undefined, the mesh position is computed from the attached node position
  65632. */
  65633. attachedNode: {
  65634. position: Vector3;
  65635. };
  65636. /**
  65637. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65638. */
  65639. customMeshPosition: Vector3;
  65640. /**
  65641. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65642. */
  65643. useCustomMeshPosition: boolean;
  65644. /**
  65645. * If the post-process should inverse the light scattering direction
  65646. */
  65647. invert: boolean;
  65648. /**
  65649. * The internal mesh used by the post-process
  65650. */
  65651. mesh: Mesh;
  65652. /**
  65653. * @hidden
  65654. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65655. */
  65656. useDiffuseColor: boolean;
  65657. /**
  65658. * Array containing the excluded meshes not rendered in the internal pass
  65659. */
  65660. excludedMeshes: AbstractMesh[];
  65661. /**
  65662. * Controls the overall intensity of the post-process
  65663. */
  65664. exposure: number;
  65665. /**
  65666. * Dissipates each sample's contribution in range [0, 1]
  65667. */
  65668. decay: number;
  65669. /**
  65670. * Controls the overall intensity of each sample
  65671. */
  65672. weight: number;
  65673. /**
  65674. * Controls the density of each sample
  65675. */
  65676. density: number;
  65677. /**
  65678. * @constructor
  65679. * @param name The post-process name
  65680. * @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)
  65681. * @param camera The camera that the post-process will be attached to
  65682. * @param mesh The mesh used to create the light scattering
  65683. * @param samples The post-process quality, default 100
  65684. * @param samplingModeThe post-process filtering mode
  65685. * @param engine The babylon engine
  65686. * @param reusable If the post-process is reusable
  65687. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65688. */
  65689. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65690. /**
  65691. * Returns the string "VolumetricLightScatteringPostProcess"
  65692. * @returns "VolumetricLightScatteringPostProcess"
  65693. */
  65694. getClassName(): string;
  65695. private _isReady;
  65696. /**
  65697. * Sets the new light position for light scattering effect
  65698. * @param position The new custom light position
  65699. */
  65700. setCustomMeshPosition(position: Vector3): void;
  65701. /**
  65702. * Returns the light position for light scattering effect
  65703. * @return Vector3 The custom light position
  65704. */
  65705. getCustomMeshPosition(): Vector3;
  65706. /**
  65707. * Disposes the internal assets and detaches the post-process from the camera
  65708. */
  65709. dispose(camera: Camera): void;
  65710. /**
  65711. * Returns the render target texture used by the post-process
  65712. * @return the render target texture used by the post-process
  65713. */
  65714. getPass(): RenderTargetTexture;
  65715. private _meshExcluded;
  65716. private _createPass;
  65717. private _updateMeshScreenCoordinates;
  65718. /**
  65719. * Creates a default mesh for the Volumeric Light Scattering post-process
  65720. * @param name The mesh name
  65721. * @param scene The scene where to create the mesh
  65722. * @return the default mesh
  65723. */
  65724. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65725. }
  65726. }
  65727. declare module "babylonjs/PostProcesses/index" {
  65728. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65729. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65730. export * from "babylonjs/PostProcesses/bloomEffect";
  65731. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65732. export * from "babylonjs/PostProcesses/blurPostProcess";
  65733. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65734. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65735. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65736. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65737. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65738. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65739. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65740. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65741. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65742. export * from "babylonjs/PostProcesses/filterPostProcess";
  65743. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65744. export * from "babylonjs/PostProcesses/grainPostProcess";
  65745. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65746. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65747. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65748. export * from "babylonjs/PostProcesses/passPostProcess";
  65749. export * from "babylonjs/PostProcesses/postProcess";
  65750. export * from "babylonjs/PostProcesses/postProcessManager";
  65751. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65752. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65753. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65754. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65755. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65756. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65757. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65758. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65759. }
  65760. declare module "babylonjs/Probes/index" {
  65761. export * from "babylonjs/Probes/reflectionProbe";
  65762. }
  65763. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65764. import { Scene } from "babylonjs/scene";
  65765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65766. import { SmartArray } from "babylonjs/Misc/smartArray";
  65767. import { ISceneComponent } from "babylonjs/sceneComponent";
  65768. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65769. import "babylonjs/Meshes/Builders/boxBuilder";
  65770. import "babylonjs/Shaders/color.fragment";
  65771. import "babylonjs/Shaders/color.vertex";
  65772. import { Color3 } from "babylonjs/Maths/math.color";
  65773. module "babylonjs/scene" {
  65774. interface Scene {
  65775. /** @hidden (Backing field) */
  65776. _boundingBoxRenderer: BoundingBoxRenderer;
  65777. /** @hidden (Backing field) */
  65778. _forceShowBoundingBoxes: boolean;
  65779. /**
  65780. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65781. */
  65782. forceShowBoundingBoxes: boolean;
  65783. /**
  65784. * Gets the bounding box renderer associated with the scene
  65785. * @returns a BoundingBoxRenderer
  65786. */
  65787. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65788. }
  65789. }
  65790. module "babylonjs/Meshes/abstractMesh" {
  65791. interface AbstractMesh {
  65792. /** @hidden (Backing field) */
  65793. _showBoundingBox: boolean;
  65794. /**
  65795. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65796. */
  65797. showBoundingBox: boolean;
  65798. }
  65799. }
  65800. /**
  65801. * Component responsible of rendering the bounding box of the meshes in a scene.
  65802. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65803. */
  65804. export class BoundingBoxRenderer implements ISceneComponent {
  65805. /**
  65806. * The component name helpfull to identify the component in the list of scene components.
  65807. */
  65808. readonly name: string;
  65809. /**
  65810. * The scene the component belongs to.
  65811. */
  65812. scene: Scene;
  65813. /**
  65814. * Color of the bounding box lines placed in front of an object
  65815. */
  65816. frontColor: Color3;
  65817. /**
  65818. * Color of the bounding box lines placed behind an object
  65819. */
  65820. backColor: Color3;
  65821. /**
  65822. * Defines if the renderer should show the back lines or not
  65823. */
  65824. showBackLines: boolean;
  65825. /**
  65826. * @hidden
  65827. */
  65828. renderList: SmartArray<BoundingBox>;
  65829. private _colorShader;
  65830. private _vertexBuffers;
  65831. private _indexBuffer;
  65832. private _fillIndexBuffer;
  65833. private _fillIndexData;
  65834. /**
  65835. * Instantiates a new bounding box renderer in a scene.
  65836. * @param scene the scene the renderer renders in
  65837. */
  65838. constructor(scene: Scene);
  65839. /**
  65840. * Registers the component in a given scene
  65841. */
  65842. register(): void;
  65843. private _evaluateSubMesh;
  65844. private _activeMesh;
  65845. private _prepareRessources;
  65846. private _createIndexBuffer;
  65847. /**
  65848. * Rebuilds the elements related to this component in case of
  65849. * context lost for instance.
  65850. */
  65851. rebuild(): void;
  65852. /**
  65853. * @hidden
  65854. */
  65855. reset(): void;
  65856. /**
  65857. * Render the bounding boxes of a specific rendering group
  65858. * @param renderingGroupId defines the rendering group to render
  65859. */
  65860. render(renderingGroupId: number): void;
  65861. /**
  65862. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65863. * @param mesh Define the mesh to render the occlusion bounding box for
  65864. */
  65865. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65866. /**
  65867. * Dispose and release the resources attached to this renderer.
  65868. */
  65869. dispose(): void;
  65870. }
  65871. }
  65872. declare module "babylonjs/Shaders/depth.fragment" {
  65873. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65874. /** @hidden */
  65875. export var depthPixelShader: {
  65876. name: string;
  65877. shader: string;
  65878. };
  65879. }
  65880. declare module "babylonjs/Rendering/depthRenderer" {
  65881. import { Nullable } from "babylonjs/types";
  65882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65883. import { Scene } from "babylonjs/scene";
  65884. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65885. import { Camera } from "babylonjs/Cameras/camera";
  65886. import "babylonjs/Shaders/depth.fragment";
  65887. import "babylonjs/Shaders/depth.vertex";
  65888. /**
  65889. * This represents a depth renderer in Babylon.
  65890. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65891. */
  65892. export class DepthRenderer {
  65893. private _scene;
  65894. private _depthMap;
  65895. private _effect;
  65896. private readonly _storeNonLinearDepth;
  65897. private readonly _clearColor;
  65898. /** Get if the depth renderer is using packed depth or not */
  65899. readonly isPacked: boolean;
  65900. private _cachedDefines;
  65901. private _camera;
  65902. /**
  65903. * Specifiess that the depth renderer will only be used within
  65904. * the camera it is created for.
  65905. * This can help forcing its rendering during the camera processing.
  65906. */
  65907. useOnlyInActiveCamera: boolean;
  65908. /** @hidden */
  65909. static _SceneComponentInitialization: (scene: Scene) => void;
  65910. /**
  65911. * Instantiates a depth renderer
  65912. * @param scene The scene the renderer belongs to
  65913. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65914. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65915. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65916. */
  65917. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65918. /**
  65919. * Creates the depth rendering effect and checks if the effect is ready.
  65920. * @param subMesh The submesh to be used to render the depth map of
  65921. * @param useInstances If multiple world instances should be used
  65922. * @returns if the depth renderer is ready to render the depth map
  65923. */
  65924. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65925. /**
  65926. * Gets the texture which the depth map will be written to.
  65927. * @returns The depth map texture
  65928. */
  65929. getDepthMap(): RenderTargetTexture;
  65930. /**
  65931. * Disposes of the depth renderer.
  65932. */
  65933. dispose(): void;
  65934. }
  65935. }
  65936. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65937. import { Nullable } from "babylonjs/types";
  65938. import { Scene } from "babylonjs/scene";
  65939. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65940. import { Camera } from "babylonjs/Cameras/camera";
  65941. import { ISceneComponent } from "babylonjs/sceneComponent";
  65942. module "babylonjs/scene" {
  65943. interface Scene {
  65944. /** @hidden (Backing field) */
  65945. _depthRenderer: {
  65946. [id: string]: DepthRenderer;
  65947. };
  65948. /**
  65949. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65950. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65951. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65952. * @returns the created depth renderer
  65953. */
  65954. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65955. /**
  65956. * Disables a depth renderer for a given camera
  65957. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65958. */
  65959. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65960. }
  65961. }
  65962. /**
  65963. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65964. * in several rendering techniques.
  65965. */
  65966. export class DepthRendererSceneComponent implements ISceneComponent {
  65967. /**
  65968. * The component name helpfull to identify the component in the list of scene components.
  65969. */
  65970. readonly name: string;
  65971. /**
  65972. * The scene the component belongs to.
  65973. */
  65974. scene: Scene;
  65975. /**
  65976. * Creates a new instance of the component for the given scene
  65977. * @param scene Defines the scene to register the component in
  65978. */
  65979. constructor(scene: Scene);
  65980. /**
  65981. * Registers the component in a given scene
  65982. */
  65983. register(): void;
  65984. /**
  65985. * Rebuilds the elements related to this component in case of
  65986. * context lost for instance.
  65987. */
  65988. rebuild(): void;
  65989. /**
  65990. * Disposes the component and the associated ressources
  65991. */
  65992. dispose(): void;
  65993. private _gatherRenderTargets;
  65994. private _gatherActiveCameraRenderTargets;
  65995. }
  65996. }
  65997. declare module "babylonjs/Shaders/outline.fragment" {
  65998. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65999. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66000. /** @hidden */
  66001. export var outlinePixelShader: {
  66002. name: string;
  66003. shader: string;
  66004. };
  66005. }
  66006. declare module "babylonjs/Shaders/outline.vertex" {
  66007. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66009. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66010. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66011. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66012. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66013. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66014. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66015. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66016. /** @hidden */
  66017. export var outlineVertexShader: {
  66018. name: string;
  66019. shader: string;
  66020. };
  66021. }
  66022. declare module "babylonjs/Rendering/outlineRenderer" {
  66023. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66024. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66025. import { Scene } from "babylonjs/scene";
  66026. import { ISceneComponent } from "babylonjs/sceneComponent";
  66027. import "babylonjs/Shaders/outline.fragment";
  66028. import "babylonjs/Shaders/outline.vertex";
  66029. module "babylonjs/scene" {
  66030. interface Scene {
  66031. /** @hidden */
  66032. _outlineRenderer: OutlineRenderer;
  66033. /**
  66034. * Gets the outline renderer associated with the scene
  66035. * @returns a OutlineRenderer
  66036. */
  66037. getOutlineRenderer(): OutlineRenderer;
  66038. }
  66039. }
  66040. module "babylonjs/Meshes/abstractMesh" {
  66041. interface AbstractMesh {
  66042. /** @hidden (Backing field) */
  66043. _renderOutline: boolean;
  66044. /**
  66045. * Gets or sets a boolean indicating if the outline must be rendered as well
  66046. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66047. */
  66048. renderOutline: boolean;
  66049. /** @hidden (Backing field) */
  66050. _renderOverlay: boolean;
  66051. /**
  66052. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66053. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66054. */
  66055. renderOverlay: boolean;
  66056. }
  66057. }
  66058. /**
  66059. * This class is responsible to draw bothe outline/overlay of meshes.
  66060. * It should not be used directly but through the available method on mesh.
  66061. */
  66062. export class OutlineRenderer implements ISceneComponent {
  66063. /**
  66064. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66065. */
  66066. private static _StencilReference;
  66067. /**
  66068. * The name of the component. Each component must have a unique name.
  66069. */
  66070. name: string;
  66071. /**
  66072. * The scene the component belongs to.
  66073. */
  66074. scene: Scene;
  66075. /**
  66076. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66077. */
  66078. zOffset: number;
  66079. private _engine;
  66080. private _effect;
  66081. private _cachedDefines;
  66082. private _savedDepthWrite;
  66083. /**
  66084. * Instantiates a new outline renderer. (There could be only one per scene).
  66085. * @param scene Defines the scene it belongs to
  66086. */
  66087. constructor(scene: Scene);
  66088. /**
  66089. * Register the component to one instance of a scene.
  66090. */
  66091. register(): void;
  66092. /**
  66093. * Rebuilds the elements related to this component in case of
  66094. * context lost for instance.
  66095. */
  66096. rebuild(): void;
  66097. /**
  66098. * Disposes the component and the associated ressources.
  66099. */
  66100. dispose(): void;
  66101. /**
  66102. * Renders the outline in the canvas.
  66103. * @param subMesh Defines the sumesh to render
  66104. * @param batch Defines the batch of meshes in case of instances
  66105. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66106. */
  66107. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66108. /**
  66109. * Returns whether or not the outline renderer is ready for a given submesh.
  66110. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66111. * @param subMesh Defines the submesh to check readyness for
  66112. * @param useInstances Defines wheter wee are trying to render instances or not
  66113. * @returns true if ready otherwise false
  66114. */
  66115. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66116. private _beforeRenderingMesh;
  66117. private _afterRenderingMesh;
  66118. }
  66119. }
  66120. declare module "babylonjs/Rendering/index" {
  66121. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66122. export * from "babylonjs/Rendering/depthRenderer";
  66123. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66124. export * from "babylonjs/Rendering/edgesRenderer";
  66125. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66126. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66127. export * from "babylonjs/Rendering/outlineRenderer";
  66128. export * from "babylonjs/Rendering/renderingGroup";
  66129. export * from "babylonjs/Rendering/renderingManager";
  66130. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66131. }
  66132. declare module "babylonjs/Sprites/spritePackedManager" {
  66133. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66134. import { Scene } from "babylonjs/scene";
  66135. /**
  66136. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66137. * @see http://doc.babylonjs.com/babylon101/sprites
  66138. */
  66139. export class SpritePackedManager extends SpriteManager {
  66140. /** defines the packed manager's name */
  66141. name: string;
  66142. /**
  66143. * Creates a new sprite manager from a packed sprite sheet
  66144. * @param name defines the manager's name
  66145. * @param imgUrl defines the sprite sheet url
  66146. * @param capacity defines the maximum allowed number of sprites
  66147. * @param scene defines the hosting scene
  66148. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66149. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66150. * @param samplingMode defines the smapling mode to use with spritesheet
  66151. * @param fromPacked set to true; do not alter
  66152. */
  66153. constructor(
  66154. /** defines the packed manager's name */
  66155. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66156. }
  66157. }
  66158. declare module "babylonjs/Sprites/index" {
  66159. export * from "babylonjs/Sprites/sprite";
  66160. export * from "babylonjs/Sprites/spriteManager";
  66161. export * from "babylonjs/Sprites/spritePackedManager";
  66162. export * from "babylonjs/Sprites/spriteSceneComponent";
  66163. }
  66164. declare module "babylonjs/States/index" {
  66165. export * from "babylonjs/States/alphaCullingState";
  66166. export * from "babylonjs/States/depthCullingState";
  66167. export * from "babylonjs/States/stencilState";
  66168. }
  66169. declare module "babylonjs/Misc/assetsManager" {
  66170. import { Scene } from "babylonjs/scene";
  66171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66172. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66173. import { Skeleton } from "babylonjs/Bones/skeleton";
  66174. import { Observable } from "babylonjs/Misc/observable";
  66175. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66176. import { Texture } from "babylonjs/Materials/Textures/texture";
  66177. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66178. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66179. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66180. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66181. /**
  66182. * Defines the list of states available for a task inside a AssetsManager
  66183. */
  66184. export enum AssetTaskState {
  66185. /**
  66186. * Initialization
  66187. */
  66188. INIT = 0,
  66189. /**
  66190. * Running
  66191. */
  66192. RUNNING = 1,
  66193. /**
  66194. * Done
  66195. */
  66196. DONE = 2,
  66197. /**
  66198. * Error
  66199. */
  66200. ERROR = 3
  66201. }
  66202. /**
  66203. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66204. */
  66205. export abstract class AbstractAssetTask {
  66206. /**
  66207. * Task name
  66208. */ name: string;
  66209. /**
  66210. * Callback called when the task is successful
  66211. */
  66212. onSuccess: (task: any) => void;
  66213. /**
  66214. * Callback called when the task is not successful
  66215. */
  66216. onError: (task: any, message?: string, exception?: any) => void;
  66217. /**
  66218. * Creates a new AssetsManager
  66219. * @param name defines the name of the task
  66220. */
  66221. constructor(
  66222. /**
  66223. * Task name
  66224. */ name: string);
  66225. private _isCompleted;
  66226. private _taskState;
  66227. private _errorObject;
  66228. /**
  66229. * Get if the task is completed
  66230. */
  66231. readonly isCompleted: boolean;
  66232. /**
  66233. * Gets the current state of the task
  66234. */
  66235. readonly taskState: AssetTaskState;
  66236. /**
  66237. * Gets the current error object (if task is in error)
  66238. */
  66239. readonly errorObject: {
  66240. message?: string;
  66241. exception?: any;
  66242. };
  66243. /**
  66244. * Internal only
  66245. * @hidden
  66246. */
  66247. _setErrorObject(message?: string, exception?: any): void;
  66248. /**
  66249. * Execute the current task
  66250. * @param scene defines the scene where you want your assets to be loaded
  66251. * @param onSuccess is a callback called when the task is successfully executed
  66252. * @param onError is a callback called if an error occurs
  66253. */
  66254. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66255. /**
  66256. * Execute the current task
  66257. * @param scene defines the scene where you want your assets to be loaded
  66258. * @param onSuccess is a callback called when the task is successfully executed
  66259. * @param onError is a callback called if an error occurs
  66260. */
  66261. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66262. /**
  66263. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66264. * This can be used with failed tasks that have the reason for failure fixed.
  66265. */
  66266. reset(): void;
  66267. private onErrorCallback;
  66268. private onDoneCallback;
  66269. }
  66270. /**
  66271. * Define the interface used by progress events raised during assets loading
  66272. */
  66273. export interface IAssetsProgressEvent {
  66274. /**
  66275. * Defines the number of remaining tasks to process
  66276. */
  66277. remainingCount: number;
  66278. /**
  66279. * Defines the total number of tasks
  66280. */
  66281. totalCount: number;
  66282. /**
  66283. * Defines the task that was just processed
  66284. */
  66285. task: AbstractAssetTask;
  66286. }
  66287. /**
  66288. * Class used to share progress information about assets loading
  66289. */
  66290. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66291. /**
  66292. * Defines the number of remaining tasks to process
  66293. */
  66294. remainingCount: number;
  66295. /**
  66296. * Defines the total number of tasks
  66297. */
  66298. totalCount: number;
  66299. /**
  66300. * Defines the task that was just processed
  66301. */
  66302. task: AbstractAssetTask;
  66303. /**
  66304. * Creates a AssetsProgressEvent
  66305. * @param remainingCount defines the number of remaining tasks to process
  66306. * @param totalCount defines the total number of tasks
  66307. * @param task defines the task that was just processed
  66308. */
  66309. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66310. }
  66311. /**
  66312. * Define a task used by AssetsManager to load meshes
  66313. */
  66314. export class MeshAssetTask extends AbstractAssetTask {
  66315. /**
  66316. * Defines the name of the task
  66317. */
  66318. name: string;
  66319. /**
  66320. * Defines the list of mesh's names you want to load
  66321. */
  66322. meshesNames: any;
  66323. /**
  66324. * Defines the root url to use as a base to load your meshes and associated resources
  66325. */
  66326. rootUrl: string;
  66327. /**
  66328. * Defines the filename of the scene to load from
  66329. */
  66330. sceneFilename: string;
  66331. /**
  66332. * Gets the list of loaded meshes
  66333. */
  66334. loadedMeshes: Array<AbstractMesh>;
  66335. /**
  66336. * Gets the list of loaded particle systems
  66337. */
  66338. loadedParticleSystems: Array<IParticleSystem>;
  66339. /**
  66340. * Gets the list of loaded skeletons
  66341. */
  66342. loadedSkeletons: Array<Skeleton>;
  66343. /**
  66344. * Gets the list of loaded animation groups
  66345. */
  66346. loadedAnimationGroups: Array<AnimationGroup>;
  66347. /**
  66348. * Callback called when the task is successful
  66349. */
  66350. onSuccess: (task: MeshAssetTask) => void;
  66351. /**
  66352. * Callback called when the task is successful
  66353. */
  66354. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66355. /**
  66356. * Creates a new MeshAssetTask
  66357. * @param name defines the name of the task
  66358. * @param meshesNames defines the list of mesh's names you want to load
  66359. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66360. * @param sceneFilename defines the filename of the scene to load from
  66361. */
  66362. constructor(
  66363. /**
  66364. * Defines the name of the task
  66365. */
  66366. name: string,
  66367. /**
  66368. * Defines the list of mesh's names you want to load
  66369. */
  66370. meshesNames: any,
  66371. /**
  66372. * Defines the root url to use as a base to load your meshes and associated resources
  66373. */
  66374. rootUrl: string,
  66375. /**
  66376. * Defines the filename of the scene to load from
  66377. */
  66378. sceneFilename: string);
  66379. /**
  66380. * Execute the current task
  66381. * @param scene defines the scene where you want your assets to be loaded
  66382. * @param onSuccess is a callback called when the task is successfully executed
  66383. * @param onError is a callback called if an error occurs
  66384. */
  66385. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66386. }
  66387. /**
  66388. * Define a task used by AssetsManager to load text content
  66389. */
  66390. export class TextFileAssetTask extends AbstractAssetTask {
  66391. /**
  66392. * Defines the name of the task
  66393. */
  66394. name: string;
  66395. /**
  66396. * Defines the location of the file to load
  66397. */
  66398. url: string;
  66399. /**
  66400. * Gets the loaded text string
  66401. */
  66402. text: string;
  66403. /**
  66404. * Callback called when the task is successful
  66405. */
  66406. onSuccess: (task: TextFileAssetTask) => void;
  66407. /**
  66408. * Callback called when the task is successful
  66409. */
  66410. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66411. /**
  66412. * Creates a new TextFileAssetTask object
  66413. * @param name defines the name of the task
  66414. * @param url defines the location of the file to load
  66415. */
  66416. constructor(
  66417. /**
  66418. * Defines the name of the task
  66419. */
  66420. name: string,
  66421. /**
  66422. * Defines the location of the file to load
  66423. */
  66424. url: string);
  66425. /**
  66426. * Execute the current task
  66427. * @param scene defines the scene where you want your assets to be loaded
  66428. * @param onSuccess is a callback called when the task is successfully executed
  66429. * @param onError is a callback called if an error occurs
  66430. */
  66431. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66432. }
  66433. /**
  66434. * Define a task used by AssetsManager to load binary data
  66435. */
  66436. export class BinaryFileAssetTask extends AbstractAssetTask {
  66437. /**
  66438. * Defines the name of the task
  66439. */
  66440. name: string;
  66441. /**
  66442. * Defines the location of the file to load
  66443. */
  66444. url: string;
  66445. /**
  66446. * Gets the lodaded data (as an array buffer)
  66447. */
  66448. data: ArrayBuffer;
  66449. /**
  66450. * Callback called when the task is successful
  66451. */
  66452. onSuccess: (task: BinaryFileAssetTask) => void;
  66453. /**
  66454. * Callback called when the task is successful
  66455. */
  66456. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66457. /**
  66458. * Creates a new BinaryFileAssetTask object
  66459. * @param name defines the name of the new task
  66460. * @param url defines the location of the file to load
  66461. */
  66462. constructor(
  66463. /**
  66464. * Defines the name of the task
  66465. */
  66466. name: string,
  66467. /**
  66468. * Defines the location of the file to load
  66469. */
  66470. url: string);
  66471. /**
  66472. * Execute the current task
  66473. * @param scene defines the scene where you want your assets to be loaded
  66474. * @param onSuccess is a callback called when the task is successfully executed
  66475. * @param onError is a callback called if an error occurs
  66476. */
  66477. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66478. }
  66479. /**
  66480. * Define a task used by AssetsManager to load images
  66481. */
  66482. export class ImageAssetTask extends AbstractAssetTask {
  66483. /**
  66484. * Defines the name of the task
  66485. */
  66486. name: string;
  66487. /**
  66488. * Defines the location of the image to load
  66489. */
  66490. url: string;
  66491. /**
  66492. * Gets the loaded images
  66493. */
  66494. image: HTMLImageElement;
  66495. /**
  66496. * Callback called when the task is successful
  66497. */
  66498. onSuccess: (task: ImageAssetTask) => void;
  66499. /**
  66500. * Callback called when the task is successful
  66501. */
  66502. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66503. /**
  66504. * Creates a new ImageAssetTask
  66505. * @param name defines the name of the task
  66506. * @param url defines the location of the image to load
  66507. */
  66508. constructor(
  66509. /**
  66510. * Defines the name of the task
  66511. */
  66512. name: string,
  66513. /**
  66514. * Defines the location of the image to load
  66515. */
  66516. url: string);
  66517. /**
  66518. * Execute the current task
  66519. * @param scene defines the scene where you want your assets to be loaded
  66520. * @param onSuccess is a callback called when the task is successfully executed
  66521. * @param onError is a callback called if an error occurs
  66522. */
  66523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66524. }
  66525. /**
  66526. * Defines the interface used by texture loading tasks
  66527. */
  66528. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66529. /**
  66530. * Gets the loaded texture
  66531. */
  66532. texture: TEX;
  66533. }
  66534. /**
  66535. * Define a task used by AssetsManager to load 2D textures
  66536. */
  66537. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66538. /**
  66539. * Defines the name of the task
  66540. */
  66541. name: string;
  66542. /**
  66543. * Defines the location of the file to load
  66544. */
  66545. url: string;
  66546. /**
  66547. * Defines if mipmap should not be generated (default is false)
  66548. */
  66549. noMipmap?: boolean | undefined;
  66550. /**
  66551. * Defines if texture must be inverted on Y axis (default is false)
  66552. */
  66553. invertY?: boolean | undefined;
  66554. /**
  66555. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66556. */
  66557. samplingMode: number;
  66558. /**
  66559. * Gets the loaded texture
  66560. */
  66561. texture: Texture;
  66562. /**
  66563. * Callback called when the task is successful
  66564. */
  66565. onSuccess: (task: TextureAssetTask) => void;
  66566. /**
  66567. * Callback called when the task is successful
  66568. */
  66569. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66570. /**
  66571. * Creates a new TextureAssetTask object
  66572. * @param name defines the name of the task
  66573. * @param url defines the location of the file to load
  66574. * @param noMipmap defines if mipmap should not be generated (default is false)
  66575. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66576. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66577. */
  66578. constructor(
  66579. /**
  66580. * Defines the name of the task
  66581. */
  66582. name: string,
  66583. /**
  66584. * Defines the location of the file to load
  66585. */
  66586. url: string,
  66587. /**
  66588. * Defines if mipmap should not be generated (default is false)
  66589. */
  66590. noMipmap?: boolean | undefined,
  66591. /**
  66592. * Defines if texture must be inverted on Y axis (default is false)
  66593. */
  66594. invertY?: boolean | undefined,
  66595. /**
  66596. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66597. */
  66598. samplingMode?: number);
  66599. /**
  66600. * Execute the current task
  66601. * @param scene defines the scene where you want your assets to be loaded
  66602. * @param onSuccess is a callback called when the task is successfully executed
  66603. * @param onError is a callback called if an error occurs
  66604. */
  66605. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66606. }
  66607. /**
  66608. * Define a task used by AssetsManager to load cube textures
  66609. */
  66610. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66611. /**
  66612. * Defines the name of the task
  66613. */
  66614. name: string;
  66615. /**
  66616. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66617. */
  66618. url: string;
  66619. /**
  66620. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66621. */
  66622. extensions?: string[] | undefined;
  66623. /**
  66624. * Defines if mipmaps should not be generated (default is false)
  66625. */
  66626. noMipmap?: boolean | undefined;
  66627. /**
  66628. * Defines the explicit list of files (undefined by default)
  66629. */
  66630. files?: string[] | undefined;
  66631. /**
  66632. * Gets the loaded texture
  66633. */
  66634. texture: CubeTexture;
  66635. /**
  66636. * Callback called when the task is successful
  66637. */
  66638. onSuccess: (task: CubeTextureAssetTask) => void;
  66639. /**
  66640. * Callback called when the task is successful
  66641. */
  66642. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66643. /**
  66644. * Creates a new CubeTextureAssetTask
  66645. * @param name defines the name of the task
  66646. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66647. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66648. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66649. * @param files defines the explicit list of files (undefined by default)
  66650. */
  66651. constructor(
  66652. /**
  66653. * Defines the name of the task
  66654. */
  66655. name: string,
  66656. /**
  66657. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66658. */
  66659. url: string,
  66660. /**
  66661. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66662. */
  66663. extensions?: string[] | undefined,
  66664. /**
  66665. * Defines if mipmaps should not be generated (default is false)
  66666. */
  66667. noMipmap?: boolean | undefined,
  66668. /**
  66669. * Defines the explicit list of files (undefined by default)
  66670. */
  66671. files?: string[] | undefined);
  66672. /**
  66673. * Execute the current task
  66674. * @param scene defines the scene where you want your assets to be loaded
  66675. * @param onSuccess is a callback called when the task is successfully executed
  66676. * @param onError is a callback called if an error occurs
  66677. */
  66678. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66679. }
  66680. /**
  66681. * Define a task used by AssetsManager to load HDR cube textures
  66682. */
  66683. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66684. /**
  66685. * Defines the name of the task
  66686. */
  66687. name: string;
  66688. /**
  66689. * Defines the location of the file to load
  66690. */
  66691. url: string;
  66692. /**
  66693. * Defines the desired size (the more it increases the longer the generation will be)
  66694. */
  66695. size: number;
  66696. /**
  66697. * Defines if mipmaps should not be generated (default is false)
  66698. */
  66699. noMipmap: boolean;
  66700. /**
  66701. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66702. */
  66703. generateHarmonics: boolean;
  66704. /**
  66705. * 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)
  66706. */
  66707. gammaSpace: boolean;
  66708. /**
  66709. * Internal Use Only
  66710. */
  66711. reserved: boolean;
  66712. /**
  66713. * Gets the loaded texture
  66714. */
  66715. texture: HDRCubeTexture;
  66716. /**
  66717. * Callback called when the task is successful
  66718. */
  66719. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66720. /**
  66721. * Callback called when the task is successful
  66722. */
  66723. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66724. /**
  66725. * Creates a new HDRCubeTextureAssetTask object
  66726. * @param name defines the name of the task
  66727. * @param url defines the location of the file to load
  66728. * @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.
  66729. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66730. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66731. * @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)
  66732. * @param reserved Internal use only
  66733. */
  66734. constructor(
  66735. /**
  66736. * Defines the name of the task
  66737. */
  66738. name: string,
  66739. /**
  66740. * Defines the location of the file to load
  66741. */
  66742. url: string,
  66743. /**
  66744. * Defines the desired size (the more it increases the longer the generation will be)
  66745. */
  66746. size: number,
  66747. /**
  66748. * Defines if mipmaps should not be generated (default is false)
  66749. */
  66750. noMipmap?: boolean,
  66751. /**
  66752. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66753. */
  66754. generateHarmonics?: boolean,
  66755. /**
  66756. * 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)
  66757. */
  66758. gammaSpace?: boolean,
  66759. /**
  66760. * Internal Use Only
  66761. */
  66762. reserved?: boolean);
  66763. /**
  66764. * Execute the current task
  66765. * @param scene defines the scene where you want your assets to be loaded
  66766. * @param onSuccess is a callback called when the task is successfully executed
  66767. * @param onError is a callback called if an error occurs
  66768. */
  66769. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66770. }
  66771. /**
  66772. * Define a task used by AssetsManager to load Equirectangular cube textures
  66773. */
  66774. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66775. /**
  66776. * Defines the name of the task
  66777. */
  66778. name: string;
  66779. /**
  66780. * Defines the location of the file to load
  66781. */
  66782. url: string;
  66783. /**
  66784. * Defines the desired size (the more it increases the longer the generation will be)
  66785. */
  66786. size: number;
  66787. /**
  66788. * Defines if mipmaps should not be generated (default is false)
  66789. */
  66790. noMipmap: boolean;
  66791. /**
  66792. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66793. * but the standard material would require them in Gamma space) (default is true)
  66794. */
  66795. gammaSpace: boolean;
  66796. /**
  66797. * Gets the loaded texture
  66798. */
  66799. texture: EquiRectangularCubeTexture;
  66800. /**
  66801. * Callback called when the task is successful
  66802. */
  66803. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66804. /**
  66805. * Callback called when the task is successful
  66806. */
  66807. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66808. /**
  66809. * Creates a new EquiRectangularCubeTextureAssetTask object
  66810. * @param name defines the name of the task
  66811. * @param url defines the location of the file to load
  66812. * @param size defines the desired size (the more it increases the longer the generation will be)
  66813. * If the size is omitted this implies you are using a preprocessed cubemap.
  66814. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66815. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66816. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66817. * (default is true)
  66818. */
  66819. constructor(
  66820. /**
  66821. * Defines the name of the task
  66822. */
  66823. name: string,
  66824. /**
  66825. * Defines the location of the file to load
  66826. */
  66827. url: string,
  66828. /**
  66829. * Defines the desired size (the more it increases the longer the generation will be)
  66830. */
  66831. size: number,
  66832. /**
  66833. * Defines if mipmaps should not be generated (default is false)
  66834. */
  66835. noMipmap?: boolean,
  66836. /**
  66837. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66838. * but the standard material would require them in Gamma space) (default is true)
  66839. */
  66840. gammaSpace?: boolean);
  66841. /**
  66842. * Execute the current task
  66843. * @param scene defines the scene where you want your assets to be loaded
  66844. * @param onSuccess is a callback called when the task is successfully executed
  66845. * @param onError is a callback called if an error occurs
  66846. */
  66847. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66848. }
  66849. /**
  66850. * This class can be used to easily import assets into a scene
  66851. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66852. */
  66853. export class AssetsManager {
  66854. private _scene;
  66855. private _isLoading;
  66856. protected _tasks: AbstractAssetTask[];
  66857. protected _waitingTasksCount: number;
  66858. protected _totalTasksCount: number;
  66859. /**
  66860. * Callback called when all tasks are processed
  66861. */
  66862. onFinish: (tasks: AbstractAssetTask[]) => void;
  66863. /**
  66864. * Callback called when a task is successful
  66865. */
  66866. onTaskSuccess: (task: AbstractAssetTask) => void;
  66867. /**
  66868. * Callback called when a task had an error
  66869. */
  66870. onTaskError: (task: AbstractAssetTask) => void;
  66871. /**
  66872. * Callback called when a task is done (whatever the result is)
  66873. */
  66874. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66875. /**
  66876. * Observable called when all tasks are processed
  66877. */
  66878. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66879. /**
  66880. * Observable called when a task had an error
  66881. */
  66882. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66883. /**
  66884. * Observable called when all tasks were executed
  66885. */
  66886. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66887. /**
  66888. * Observable called when a task is done (whatever the result is)
  66889. */
  66890. onProgressObservable: Observable<IAssetsProgressEvent>;
  66891. /**
  66892. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66893. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66894. */
  66895. useDefaultLoadingScreen: boolean;
  66896. /**
  66897. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66898. * when all assets have been downloaded.
  66899. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66900. */
  66901. autoHideLoadingUI: boolean;
  66902. /**
  66903. * Creates a new AssetsManager
  66904. * @param scene defines the scene to work on
  66905. */
  66906. constructor(scene: Scene);
  66907. /**
  66908. * Add a MeshAssetTask to the list of active tasks
  66909. * @param taskName defines the name of the new task
  66910. * @param meshesNames defines the name of meshes to load
  66911. * @param rootUrl defines the root url to use to locate files
  66912. * @param sceneFilename defines the filename of the scene file
  66913. * @returns a new MeshAssetTask object
  66914. */
  66915. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66916. /**
  66917. * Add a TextFileAssetTask to the list of active tasks
  66918. * @param taskName defines the name of the new task
  66919. * @param url defines the url of the file to load
  66920. * @returns a new TextFileAssetTask object
  66921. */
  66922. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66923. /**
  66924. * Add a BinaryFileAssetTask 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. * @returns a new BinaryFileAssetTask object
  66928. */
  66929. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66930. /**
  66931. * Add a ImageAssetTask to the list of active tasks
  66932. * @param taskName defines the name of the new task
  66933. * @param url defines the url of the file to load
  66934. * @returns a new ImageAssetTask object
  66935. */
  66936. addImageTask(taskName: string, url: string): ImageAssetTask;
  66937. /**
  66938. * Add a TextureAssetTask to the list of active tasks
  66939. * @param taskName defines the name of the new task
  66940. * @param url defines the url of the file to load
  66941. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66942. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66943. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66944. * @returns a new TextureAssetTask object
  66945. */
  66946. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66947. /**
  66948. * Add a CubeTextureAssetTask 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 extensions defines the extension to use to load the cube map (can be null)
  66952. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66953. * @param files defines the list of files to load (can be null)
  66954. * @returns a new CubeTextureAssetTask object
  66955. */
  66956. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66957. /**
  66958. *
  66959. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66960. * @param taskName defines the name of the new task
  66961. * @param url defines the url of the file to load
  66962. * @param size defines the size you want for the cubemap (can be null)
  66963. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66964. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66965. * @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)
  66966. * @param reserved Internal use only
  66967. * @returns a new HDRCubeTextureAssetTask object
  66968. */
  66969. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66970. /**
  66971. *
  66972. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66973. * @param taskName defines the name of the new task
  66974. * @param url defines the url of the file to load
  66975. * @param size defines the size you want for the cubemap (can be null)
  66976. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66977. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66978. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66979. * @returns a new EquiRectangularCubeTextureAssetTask object
  66980. */
  66981. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66982. /**
  66983. * Remove a task from the assets manager.
  66984. * @param task the task to remove
  66985. */
  66986. removeTask(task: AbstractAssetTask): void;
  66987. private _decreaseWaitingTasksCount;
  66988. private _runTask;
  66989. /**
  66990. * Reset the AssetsManager and remove all tasks
  66991. * @return the current instance of the AssetsManager
  66992. */
  66993. reset(): AssetsManager;
  66994. /**
  66995. * Start the loading process
  66996. * @return the current instance of the AssetsManager
  66997. */
  66998. load(): AssetsManager;
  66999. /**
  67000. * Start the loading process as an async operation
  67001. * @return a promise returning the list of failed tasks
  67002. */
  67003. loadAsync(): Promise<void>;
  67004. }
  67005. }
  67006. declare module "babylonjs/Misc/deferred" {
  67007. /**
  67008. * Wrapper class for promise with external resolve and reject.
  67009. */
  67010. export class Deferred<T> {
  67011. /**
  67012. * The promise associated with this deferred object.
  67013. */
  67014. readonly promise: Promise<T>;
  67015. private _resolve;
  67016. private _reject;
  67017. /**
  67018. * The resolve method of the promise associated with this deferred object.
  67019. */
  67020. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67021. /**
  67022. * The reject method of the promise associated with this deferred object.
  67023. */
  67024. readonly reject: (reason?: any) => void;
  67025. /**
  67026. * Constructor for this deferred object.
  67027. */
  67028. constructor();
  67029. }
  67030. }
  67031. declare module "babylonjs/Misc/meshExploder" {
  67032. import { Mesh } from "babylonjs/Meshes/mesh";
  67033. /**
  67034. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67035. */
  67036. export class MeshExploder {
  67037. private _centerMesh;
  67038. private _meshes;
  67039. private _meshesOrigins;
  67040. private _toCenterVectors;
  67041. private _scaledDirection;
  67042. private _newPosition;
  67043. private _centerPosition;
  67044. /**
  67045. * Explodes meshes from a center mesh.
  67046. * @param meshes The meshes to explode.
  67047. * @param centerMesh The mesh to be center of explosion.
  67048. */
  67049. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67050. private _setCenterMesh;
  67051. /**
  67052. * Get class name
  67053. * @returns "MeshExploder"
  67054. */
  67055. getClassName(): string;
  67056. /**
  67057. * "Exploded meshes"
  67058. * @returns Array of meshes with the centerMesh at index 0.
  67059. */
  67060. getMeshes(): Array<Mesh>;
  67061. /**
  67062. * Explodes meshes giving a specific direction
  67063. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67064. */
  67065. explode(direction?: number): void;
  67066. }
  67067. }
  67068. declare module "babylonjs/Misc/filesInput" {
  67069. import { Engine } from "babylonjs/Engines/engine";
  67070. import { Scene } from "babylonjs/scene";
  67071. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67072. /**
  67073. * Class used to help managing file picking and drag'n'drop
  67074. */
  67075. export class FilesInput {
  67076. /**
  67077. * List of files ready to be loaded
  67078. */
  67079. static readonly FilesToLoad: {
  67080. [key: string]: File;
  67081. };
  67082. /**
  67083. * Callback called when a file is processed
  67084. */
  67085. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67086. private _engine;
  67087. private _currentScene;
  67088. private _sceneLoadedCallback;
  67089. private _progressCallback;
  67090. private _additionalRenderLoopLogicCallback;
  67091. private _textureLoadingCallback;
  67092. private _startingProcessingFilesCallback;
  67093. private _onReloadCallback;
  67094. private _errorCallback;
  67095. private _elementToMonitor;
  67096. private _sceneFileToLoad;
  67097. private _filesToLoad;
  67098. /**
  67099. * Creates a new FilesInput
  67100. * @param engine defines the rendering engine
  67101. * @param scene defines the hosting scene
  67102. * @param sceneLoadedCallback callback called when scene is loaded
  67103. * @param progressCallback callback called to track progress
  67104. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67105. * @param textureLoadingCallback callback called when a texture is loading
  67106. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67107. * @param onReloadCallback callback called when a reload is requested
  67108. * @param errorCallback callback call if an error occurs
  67109. */
  67110. 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);
  67111. private _dragEnterHandler;
  67112. private _dragOverHandler;
  67113. private _dropHandler;
  67114. /**
  67115. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67116. * @param elementToMonitor defines the DOM element to track
  67117. */
  67118. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67119. /**
  67120. * Release all associated resources
  67121. */
  67122. dispose(): void;
  67123. private renderFunction;
  67124. private drag;
  67125. private drop;
  67126. private _traverseFolder;
  67127. private _processFiles;
  67128. /**
  67129. * Load files from a drop event
  67130. * @param event defines the drop event to use as source
  67131. */
  67132. loadFiles(event: any): void;
  67133. private _processReload;
  67134. /**
  67135. * Reload the current scene from the loaded files
  67136. */
  67137. reload(): void;
  67138. }
  67139. }
  67140. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67141. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67142. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67143. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67144. }
  67145. declare module "babylonjs/Misc/sceneOptimizer" {
  67146. import { Scene, IDisposable } from "babylonjs/scene";
  67147. import { Observable } from "babylonjs/Misc/observable";
  67148. /**
  67149. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67151. */
  67152. export class SceneOptimization {
  67153. /**
  67154. * Defines the priority of this optimization (0 by default which means first in the list)
  67155. */
  67156. priority: number;
  67157. /**
  67158. * Gets a string describing the action executed by the current optimization
  67159. * @returns description string
  67160. */
  67161. getDescription(): string;
  67162. /**
  67163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67164. * @param scene defines the current scene where to apply this optimization
  67165. * @param optimizer defines the current optimizer
  67166. * @returns true if everything that can be done was applied
  67167. */
  67168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67169. /**
  67170. * Creates the SceneOptimization object
  67171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67172. * @param desc defines the description associated with the optimization
  67173. */
  67174. constructor(
  67175. /**
  67176. * Defines the priority of this optimization (0 by default which means first in the list)
  67177. */
  67178. priority?: number);
  67179. }
  67180. /**
  67181. * Defines an optimization used to reduce the size of render target textures
  67182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67183. */
  67184. export class TextureOptimization extends SceneOptimization {
  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. * Gets a string describing the action executed by the current optimization
  67199. * @returns description string
  67200. */
  67201. getDescription(): string;
  67202. /**
  67203. * Creates the TextureOptimization object
  67204. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67205. * @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
  67206. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67207. */
  67208. constructor(
  67209. /**
  67210. * Defines the priority of this optimization (0 by default which means first in the list)
  67211. */
  67212. priority?: number,
  67213. /**
  67214. * 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
  67215. */
  67216. maximumSize?: number,
  67217. /**
  67218. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67219. */
  67220. step?: number);
  67221. /**
  67222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67223. * @param scene defines the current scene where to apply this optimization
  67224. * @param optimizer defines the current optimizer
  67225. * @returns true if everything that can be done was applied
  67226. */
  67227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67228. }
  67229. /**
  67230. * Defines an optimization used to increase or decrease the rendering resolution
  67231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67232. */
  67233. export class HardwareScalingOptimization extends SceneOptimization {
  67234. /**
  67235. * Defines the priority of this optimization (0 by default which means first in the list)
  67236. */
  67237. priority: number;
  67238. /**
  67239. * Defines the maximum scale to use (2 by default)
  67240. */
  67241. maximumScale: number;
  67242. /**
  67243. * Defines the step to use between two passes (0.5 by default)
  67244. */
  67245. step: number;
  67246. private _currentScale;
  67247. private _directionOffset;
  67248. /**
  67249. * Gets a string describing the action executed by the current optimization
  67250. * @return description string
  67251. */
  67252. getDescription(): string;
  67253. /**
  67254. * Creates the HardwareScalingOptimization object
  67255. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67256. * @param maximumScale defines the maximum scale to use (2 by default)
  67257. * @param step defines the step to use between two passes (0.5 by default)
  67258. */
  67259. constructor(
  67260. /**
  67261. * Defines the priority of this optimization (0 by default which means first in the list)
  67262. */
  67263. priority?: number,
  67264. /**
  67265. * Defines the maximum scale to use (2 by default)
  67266. */
  67267. maximumScale?: number,
  67268. /**
  67269. * Defines the step to use between two passes (0.5 by default)
  67270. */
  67271. step?: number);
  67272. /**
  67273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67274. * @param scene defines the current scene where to apply this optimization
  67275. * @param optimizer defines the current optimizer
  67276. * @returns true if everything that can be done was applied
  67277. */
  67278. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67279. }
  67280. /**
  67281. * Defines an optimization used to remove shadows
  67282. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67283. */
  67284. export class ShadowsOptimization extends SceneOptimization {
  67285. /**
  67286. * Gets a string describing the action executed by the current optimization
  67287. * @return description string
  67288. */
  67289. getDescription(): string;
  67290. /**
  67291. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67292. * @param scene defines the current scene where to apply this optimization
  67293. * @param optimizer defines the current optimizer
  67294. * @returns true if everything that can be done was applied
  67295. */
  67296. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67297. }
  67298. /**
  67299. * Defines an optimization used to turn post-processes off
  67300. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67301. */
  67302. export class PostProcessesOptimization extends SceneOptimization {
  67303. /**
  67304. * Gets a string describing the action executed by the current optimization
  67305. * @return description string
  67306. */
  67307. getDescription(): string;
  67308. /**
  67309. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67310. * @param scene defines the current scene where to apply this optimization
  67311. * @param optimizer defines the current optimizer
  67312. * @returns true if everything that can be done was applied
  67313. */
  67314. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67315. }
  67316. /**
  67317. * Defines an optimization used to turn lens flares off
  67318. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67319. */
  67320. export class LensFlaresOptimization extends SceneOptimization {
  67321. /**
  67322. * Gets a string describing the action executed by the current optimization
  67323. * @return description string
  67324. */
  67325. getDescription(): string;
  67326. /**
  67327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67328. * @param scene defines the current scene where to apply this optimization
  67329. * @param optimizer defines the current optimizer
  67330. * @returns true if everything that can be done was applied
  67331. */
  67332. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67333. }
  67334. /**
  67335. * Defines an optimization based on user defined callback.
  67336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67337. */
  67338. export class CustomOptimization extends SceneOptimization {
  67339. /**
  67340. * Callback called to apply the custom optimization.
  67341. */
  67342. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67343. /**
  67344. * Callback called to get custom description
  67345. */
  67346. onGetDescription: () => string;
  67347. /**
  67348. * Gets a string describing the action executed by the current optimization
  67349. * @returns description string
  67350. */
  67351. getDescription(): string;
  67352. /**
  67353. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67354. * @param scene defines the current scene where to apply this optimization
  67355. * @param optimizer defines the current optimizer
  67356. * @returns true if everything that can be done was applied
  67357. */
  67358. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67359. }
  67360. /**
  67361. * Defines an optimization used to turn particles off
  67362. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67363. */
  67364. export class ParticlesOptimization extends SceneOptimization {
  67365. /**
  67366. * Gets a string describing the action executed by the current optimization
  67367. * @return description string
  67368. */
  67369. getDescription(): string;
  67370. /**
  67371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67372. * @param scene defines the current scene where to apply this optimization
  67373. * @param optimizer defines the current optimizer
  67374. * @returns true if everything that can be done was applied
  67375. */
  67376. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67377. }
  67378. /**
  67379. * Defines an optimization used to turn render targets off
  67380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67381. */
  67382. export class RenderTargetsOptimization extends SceneOptimization {
  67383. /**
  67384. * Gets a string describing the action executed by the current optimization
  67385. * @return description string
  67386. */
  67387. getDescription(): string;
  67388. /**
  67389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67390. * @param scene defines the current scene where to apply this optimization
  67391. * @param optimizer defines the current optimizer
  67392. * @returns true if everything that can be done was applied
  67393. */
  67394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67395. }
  67396. /**
  67397. * Defines an optimization used to merge meshes with compatible materials
  67398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67399. */
  67400. export class MergeMeshesOptimization extends SceneOptimization {
  67401. private static _UpdateSelectionTree;
  67402. /**
  67403. * Gets or sets a boolean which defines if optimization octree has to be updated
  67404. */
  67405. /**
  67406. * Gets or sets a boolean which defines if optimization octree has to be updated
  67407. */
  67408. static UpdateSelectionTree: boolean;
  67409. /**
  67410. * Gets a string describing the action executed by the current optimization
  67411. * @return description string
  67412. */
  67413. getDescription(): string;
  67414. private _canBeMerged;
  67415. /**
  67416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67417. * @param scene defines the current scene where to apply this optimization
  67418. * @param optimizer defines the current optimizer
  67419. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67420. * @returns true if everything that can be done was applied
  67421. */
  67422. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67423. }
  67424. /**
  67425. * Defines a list of options used by SceneOptimizer
  67426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67427. */
  67428. export class SceneOptimizerOptions {
  67429. /**
  67430. * Defines the target frame rate to reach (60 by default)
  67431. */
  67432. targetFrameRate: number;
  67433. /**
  67434. * Defines the interval between two checkes (2000ms by default)
  67435. */
  67436. trackerDuration: number;
  67437. /**
  67438. * Gets the list of optimizations to apply
  67439. */
  67440. optimizations: SceneOptimization[];
  67441. /**
  67442. * Creates a new list of options used by SceneOptimizer
  67443. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67444. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67445. */
  67446. constructor(
  67447. /**
  67448. * Defines the target frame rate to reach (60 by default)
  67449. */
  67450. targetFrameRate?: number,
  67451. /**
  67452. * Defines the interval between two checkes (2000ms by default)
  67453. */
  67454. trackerDuration?: number);
  67455. /**
  67456. * Add a new optimization
  67457. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67458. * @returns the current SceneOptimizerOptions
  67459. */
  67460. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67461. /**
  67462. * Add a new custom optimization
  67463. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67464. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67465. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67466. * @returns the current SceneOptimizerOptions
  67467. */
  67468. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67469. /**
  67470. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67471. * @param targetFrameRate defines the target frame rate (60 by default)
  67472. * @returns a SceneOptimizerOptions object
  67473. */
  67474. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67475. /**
  67476. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67477. * @param targetFrameRate defines the target frame rate (60 by default)
  67478. * @returns a SceneOptimizerOptions object
  67479. */
  67480. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67481. /**
  67482. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67483. * @param targetFrameRate defines the target frame rate (60 by default)
  67484. * @returns a SceneOptimizerOptions object
  67485. */
  67486. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67487. }
  67488. /**
  67489. * Class used to run optimizations in order to reach a target frame rate
  67490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67491. */
  67492. export class SceneOptimizer implements IDisposable {
  67493. private _isRunning;
  67494. private _options;
  67495. private _scene;
  67496. private _currentPriorityLevel;
  67497. private _targetFrameRate;
  67498. private _trackerDuration;
  67499. private _currentFrameRate;
  67500. private _sceneDisposeObserver;
  67501. private _improvementMode;
  67502. /**
  67503. * Defines an observable called when the optimizer reaches the target frame rate
  67504. */
  67505. onSuccessObservable: Observable<SceneOptimizer>;
  67506. /**
  67507. * Defines an observable called when the optimizer enables an optimization
  67508. */
  67509. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67510. /**
  67511. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67512. */
  67513. onFailureObservable: Observable<SceneOptimizer>;
  67514. /**
  67515. * Gets a boolean indicating if the optimizer is in improvement mode
  67516. */
  67517. readonly isInImprovementMode: boolean;
  67518. /**
  67519. * Gets the current priority level (0 at start)
  67520. */
  67521. readonly currentPriorityLevel: number;
  67522. /**
  67523. * Gets the current frame rate checked by the SceneOptimizer
  67524. */
  67525. readonly currentFrameRate: number;
  67526. /**
  67527. * Gets or sets the current target frame rate (60 by default)
  67528. */
  67529. /**
  67530. * Gets or sets the current target frame rate (60 by default)
  67531. */
  67532. targetFrameRate: number;
  67533. /**
  67534. * Gets or sets the current interval between two checks (every 2000ms by default)
  67535. */
  67536. /**
  67537. * Gets or sets the current interval between two checks (every 2000ms by default)
  67538. */
  67539. trackerDuration: number;
  67540. /**
  67541. * Gets the list of active optimizations
  67542. */
  67543. readonly optimizations: SceneOptimization[];
  67544. /**
  67545. * Creates a new SceneOptimizer
  67546. * @param scene defines the scene to work on
  67547. * @param options defines the options to use with the SceneOptimizer
  67548. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67549. * @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)
  67550. */
  67551. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67552. /**
  67553. * Stops the current optimizer
  67554. */
  67555. stop(): void;
  67556. /**
  67557. * Reset the optimizer to initial step (current priority level = 0)
  67558. */
  67559. reset(): void;
  67560. /**
  67561. * Start the optimizer. By default it will try to reach a specific framerate
  67562. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67563. */
  67564. start(): void;
  67565. private _checkCurrentState;
  67566. /**
  67567. * Release all resources
  67568. */
  67569. dispose(): void;
  67570. /**
  67571. * Helper function to create a SceneOptimizer with one single line of code
  67572. * @param scene defines the scene to work on
  67573. * @param options defines the options to use with the SceneOptimizer
  67574. * @param onSuccess defines a callback to call on success
  67575. * @param onFailure defines a callback to call on failure
  67576. * @returns the new SceneOptimizer object
  67577. */
  67578. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67579. }
  67580. }
  67581. declare module "babylonjs/Misc/sceneSerializer" {
  67582. import { Scene } from "babylonjs/scene";
  67583. /**
  67584. * Class used to serialize a scene into a string
  67585. */
  67586. export class SceneSerializer {
  67587. /**
  67588. * Clear cache used by a previous serialization
  67589. */
  67590. static ClearCache(): void;
  67591. /**
  67592. * Serialize a scene into a JSON compatible object
  67593. * @param scene defines the scene to serialize
  67594. * @returns a JSON compatible object
  67595. */
  67596. static Serialize(scene: Scene): any;
  67597. /**
  67598. * Serialize a mesh into a JSON compatible object
  67599. * @param toSerialize defines the mesh to serialize
  67600. * @param withParents defines if parents must be serialized as well
  67601. * @param withChildren defines if children must be serialized as well
  67602. * @returns a JSON compatible object
  67603. */
  67604. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67605. }
  67606. }
  67607. declare module "babylonjs/Misc/textureTools" {
  67608. import { Texture } from "babylonjs/Materials/Textures/texture";
  67609. /**
  67610. * Class used to host texture specific utilities
  67611. */
  67612. export class TextureTools {
  67613. /**
  67614. * Uses the GPU to create a copy texture rescaled at a given size
  67615. * @param texture Texture to copy from
  67616. * @param width defines the desired width
  67617. * @param height defines the desired height
  67618. * @param useBilinearMode defines if bilinear mode has to be used
  67619. * @return the generated texture
  67620. */
  67621. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67622. }
  67623. }
  67624. declare module "babylonjs/Misc/videoRecorder" {
  67625. import { Nullable } from "babylonjs/types";
  67626. import { Engine } from "babylonjs/Engines/engine";
  67627. /**
  67628. * This represents the different options available for the video capture.
  67629. */
  67630. export interface VideoRecorderOptions {
  67631. /** Defines the mime type of the video. */
  67632. mimeType: string;
  67633. /** Defines the FPS the video should be recorded at. */
  67634. fps: number;
  67635. /** Defines the chunk size for the recording data. */
  67636. recordChunckSize: number;
  67637. /** The audio tracks to attach to the recording. */
  67638. audioTracks?: MediaStreamTrack[];
  67639. }
  67640. /**
  67641. * This can help with recording videos from BabylonJS.
  67642. * This is based on the available WebRTC functionalities of the browser.
  67643. *
  67644. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67645. */
  67646. export class VideoRecorder {
  67647. private static readonly _defaultOptions;
  67648. /**
  67649. * Returns whether or not the VideoRecorder is available in your browser.
  67650. * @param engine Defines the Babylon Engine.
  67651. * @returns true if supported otherwise false.
  67652. */
  67653. static IsSupported(engine: Engine): boolean;
  67654. private readonly _options;
  67655. private _canvas;
  67656. private _mediaRecorder;
  67657. private _recordedChunks;
  67658. private _fileName;
  67659. private _resolve;
  67660. private _reject;
  67661. /**
  67662. * True when a recording is already in progress.
  67663. */
  67664. readonly isRecording: boolean;
  67665. /**
  67666. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67667. * @param engine Defines the BabylonJS Engine you wish to record.
  67668. * @param options Defines options that can be used to customize the capture.
  67669. */
  67670. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67671. /**
  67672. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67673. */
  67674. stopRecording(): void;
  67675. /**
  67676. * Starts recording the canvas for a max duration specified in parameters.
  67677. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67678. * If null no automatic download will start and you can rely on the promise to get the data back.
  67679. * @param maxDuration Defines the maximum recording time in seconds.
  67680. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67681. * @return A promise callback at the end of the recording with the video data in Blob.
  67682. */
  67683. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67684. /**
  67685. * Releases internal resources used during the recording.
  67686. */
  67687. dispose(): void;
  67688. private _handleDataAvailable;
  67689. private _handleError;
  67690. private _handleStop;
  67691. }
  67692. }
  67693. declare module "babylonjs/Misc/screenshotTools" {
  67694. import { Camera } from "babylonjs/Cameras/camera";
  67695. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67696. import { Engine } from "babylonjs/Engines/engine";
  67697. /**
  67698. * Class containing a set of static utilities functions for screenshots
  67699. */
  67700. export class ScreenshotTools {
  67701. /**
  67702. * Captures a screenshot of the current rendering
  67703. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67704. * @param engine defines the rendering engine
  67705. * @param camera defines the source camera
  67706. * @param size This parameter can be set to a single number or to an object with the
  67707. * following (optional) properties: precision, width, height. If a single number is passed,
  67708. * it will be used for both width and height. If an object is passed, the screenshot size
  67709. * will be derived from the parameters. The precision property is a multiplier allowing
  67710. * rendering at a higher or lower resolution
  67711. * @param successCallback defines the callback receives a single parameter which contains the
  67712. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67713. * src parameter of an <img> to display it
  67714. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67715. * Check your browser for supported MIME types
  67716. */
  67717. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67718. /**
  67719. * Captures a screenshot of the current rendering
  67720. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67721. * @param engine defines the rendering engine
  67722. * @param camera defines the source camera
  67723. * @param size This parameter can be set to a single number or to an object with the
  67724. * following (optional) properties: precision, width, height. If a single number is passed,
  67725. * it will be used for both width and height. If an object is passed, the screenshot size
  67726. * will be derived from the parameters. The precision property is a multiplier allowing
  67727. * rendering at a higher or lower resolution
  67728. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67729. * Check your browser for supported MIME types
  67730. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67731. * to the src parameter of an <img> to display it
  67732. */
  67733. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67734. /**
  67735. * Generates an image screenshot from the specified camera.
  67736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67737. * @param engine The engine to use for rendering
  67738. * @param camera The camera to use for rendering
  67739. * @param size This parameter can be set to a single number or to an object with the
  67740. * following (optional) properties: precision, width, height. If a single number is passed,
  67741. * it will be used for both width and height. If an object is passed, the screenshot size
  67742. * will be derived from the parameters. The precision property is a multiplier allowing
  67743. * rendering at a higher or lower resolution
  67744. * @param successCallback The callback receives a single parameter which contains the
  67745. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67746. * src parameter of an <img> to display it
  67747. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67748. * Check your browser for supported MIME types
  67749. * @param samples Texture samples (default: 1)
  67750. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67751. * @param fileName A name for for the downloaded file.
  67752. */
  67753. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67754. /**
  67755. * Generates an image screenshot from the specified camera.
  67756. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67757. * @param engine The engine to use for rendering
  67758. * @param camera The camera to use for rendering
  67759. * @param size This parameter can be set to a single number or to an object with the
  67760. * following (optional) properties: precision, width, height. If a single number is passed,
  67761. * it will be used for both width and height. If an object is passed, the screenshot size
  67762. * will be derived from the parameters. The precision property is a multiplier allowing
  67763. * rendering at a higher or lower resolution
  67764. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67765. * Check your browser for supported MIME types
  67766. * @param samples Texture samples (default: 1)
  67767. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67768. * @param fileName A name for for the downloaded file.
  67769. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67770. * to the src parameter of an <img> to display it
  67771. */
  67772. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67773. /**
  67774. * Gets height and width for screenshot size
  67775. * @private
  67776. */
  67777. private static _getScreenshotSize;
  67778. }
  67779. }
  67780. declare module "babylonjs/Misc/dataReader" {
  67781. /**
  67782. * Interface for a data buffer
  67783. */
  67784. export interface IDataBuffer {
  67785. /**
  67786. * Reads bytes from the data buffer.
  67787. * @param byteOffset The byte offset to read
  67788. * @param byteLength The byte length to read
  67789. * @returns A promise that resolves when the bytes are read
  67790. */
  67791. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67792. /**
  67793. * The byte length of the buffer.
  67794. */
  67795. readonly byteLength: number;
  67796. }
  67797. /**
  67798. * Utility class for reading from a data buffer
  67799. */
  67800. export class DataReader {
  67801. /**
  67802. * The data buffer associated with this data reader.
  67803. */
  67804. readonly buffer: IDataBuffer;
  67805. /**
  67806. * The current byte offset from the beginning of the data buffer.
  67807. */
  67808. byteOffset: number;
  67809. private _dataView;
  67810. private _dataByteOffset;
  67811. /**
  67812. * Constructor
  67813. * @param buffer The buffer to read
  67814. */
  67815. constructor(buffer: IDataBuffer);
  67816. /**
  67817. * Loads the given byte length.
  67818. * @param byteLength The byte length to load
  67819. * @returns A promise that resolves when the load is complete
  67820. */
  67821. loadAsync(byteLength: number): Promise<void>;
  67822. /**
  67823. * Read a unsigned 32-bit integer from the currently loaded data range.
  67824. * @returns The 32-bit integer read
  67825. */
  67826. readUint32(): number;
  67827. /**
  67828. * Read a byte array from the currently loaded data range.
  67829. * @param byteLength The byte length to read
  67830. * @returns The byte array read
  67831. */
  67832. readUint8Array(byteLength: number): Uint8Array;
  67833. /**
  67834. * Read a string from the currently loaded data range.
  67835. * @param byteLength The byte length to read
  67836. * @returns The string read
  67837. */
  67838. readString(byteLength: number): string;
  67839. /**
  67840. * Skips the given byte length the currently loaded data range.
  67841. * @param byteLength The byte length to skip
  67842. */
  67843. skipBytes(byteLength: number): void;
  67844. }
  67845. }
  67846. declare module "babylonjs/Misc/index" {
  67847. export * from "babylonjs/Misc/andOrNotEvaluator";
  67848. export * from "babylonjs/Misc/assetsManager";
  67849. export * from "babylonjs/Misc/dds";
  67850. export * from "babylonjs/Misc/decorators";
  67851. export * from "babylonjs/Misc/deferred";
  67852. export * from "babylonjs/Misc/environmentTextureTools";
  67853. export * from "babylonjs/Misc/meshExploder";
  67854. export * from "babylonjs/Misc/filesInput";
  67855. export * from "babylonjs/Misc/HighDynamicRange/index";
  67856. export * from "babylonjs/Misc/khronosTextureContainer";
  67857. export * from "babylonjs/Misc/observable";
  67858. export * from "babylonjs/Misc/performanceMonitor";
  67859. export * from "babylonjs/Misc/promise";
  67860. export * from "babylonjs/Misc/sceneOptimizer";
  67861. export * from "babylonjs/Misc/sceneSerializer";
  67862. export * from "babylonjs/Misc/smartArray";
  67863. export * from "babylonjs/Misc/stringDictionary";
  67864. export * from "babylonjs/Misc/tags";
  67865. export * from "babylonjs/Misc/textureTools";
  67866. export * from "babylonjs/Misc/tga";
  67867. export * from "babylonjs/Misc/tools";
  67868. export * from "babylonjs/Misc/videoRecorder";
  67869. export * from "babylonjs/Misc/virtualJoystick";
  67870. export * from "babylonjs/Misc/workerPool";
  67871. export * from "babylonjs/Misc/logger";
  67872. export * from "babylonjs/Misc/typeStore";
  67873. export * from "babylonjs/Misc/filesInputStore";
  67874. export * from "babylonjs/Misc/deepCopier";
  67875. export * from "babylonjs/Misc/pivotTools";
  67876. export * from "babylonjs/Misc/precisionDate";
  67877. export * from "babylonjs/Misc/screenshotTools";
  67878. export * from "babylonjs/Misc/typeStore";
  67879. export * from "babylonjs/Misc/webRequest";
  67880. export * from "babylonjs/Misc/iInspectable";
  67881. export * from "babylonjs/Misc/brdfTextureTools";
  67882. export * from "babylonjs/Misc/rgbdTextureTools";
  67883. export * from "babylonjs/Misc/gradients";
  67884. export * from "babylonjs/Misc/perfCounter";
  67885. export * from "babylonjs/Misc/fileRequest";
  67886. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67887. export * from "babylonjs/Misc/retryStrategy";
  67888. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67889. export * from "babylonjs/Misc/canvasGenerator";
  67890. export * from "babylonjs/Misc/fileTools";
  67891. export * from "babylonjs/Misc/stringTools";
  67892. export * from "babylonjs/Misc/dataReader";
  67893. }
  67894. declare module "babylonjs/index" {
  67895. export * from "babylonjs/abstractScene";
  67896. export * from "babylonjs/Actions/index";
  67897. export * from "babylonjs/Animations/index";
  67898. export * from "babylonjs/assetContainer";
  67899. export * from "babylonjs/Audio/index";
  67900. export * from "babylonjs/Behaviors/index";
  67901. export * from "babylonjs/Bones/index";
  67902. export * from "babylonjs/Cameras/index";
  67903. export * from "babylonjs/Collisions/index";
  67904. export * from "babylonjs/Culling/index";
  67905. export * from "babylonjs/Debug/index";
  67906. export * from "babylonjs/Engines/index";
  67907. export * from "babylonjs/Events/index";
  67908. export * from "babylonjs/Gamepads/index";
  67909. export * from "babylonjs/Gizmos/index";
  67910. export * from "babylonjs/Helpers/index";
  67911. export * from "babylonjs/Instrumentation/index";
  67912. export * from "babylonjs/Layers/index";
  67913. export * from "babylonjs/LensFlares/index";
  67914. export * from "babylonjs/Lights/index";
  67915. export * from "babylonjs/Loading/index";
  67916. export * from "babylonjs/Materials/index";
  67917. export * from "babylonjs/Maths/index";
  67918. export * from "babylonjs/Meshes/index";
  67919. export * from "babylonjs/Morph/index";
  67920. export * from "babylonjs/Navigation/index";
  67921. export * from "babylonjs/node";
  67922. export * from "babylonjs/Offline/index";
  67923. export * from "babylonjs/Particles/index";
  67924. export * from "babylonjs/Physics/index";
  67925. export * from "babylonjs/PostProcesses/index";
  67926. export * from "babylonjs/Probes/index";
  67927. export * from "babylonjs/Rendering/index";
  67928. export * from "babylonjs/scene";
  67929. export * from "babylonjs/sceneComponent";
  67930. export * from "babylonjs/Sprites/index";
  67931. export * from "babylonjs/States/index";
  67932. export * from "babylonjs/Misc/index";
  67933. export * from "babylonjs/types";
  67934. }
  67935. declare module "babylonjs/Animations/pathCursor" {
  67936. import { Vector3 } from "babylonjs/Maths/math.vector";
  67937. import { Path2 } from "babylonjs/Maths/math.path";
  67938. /**
  67939. * A cursor which tracks a point on a path
  67940. */
  67941. export class PathCursor {
  67942. private path;
  67943. /**
  67944. * Stores path cursor callbacks for when an onchange event is triggered
  67945. */
  67946. private _onchange;
  67947. /**
  67948. * The value of the path cursor
  67949. */
  67950. value: number;
  67951. /**
  67952. * The animation array of the path cursor
  67953. */
  67954. animations: Animation[];
  67955. /**
  67956. * Initializes the path cursor
  67957. * @param path The path to track
  67958. */
  67959. constructor(path: Path2);
  67960. /**
  67961. * Gets the cursor point on the path
  67962. * @returns A point on the path cursor at the cursor location
  67963. */
  67964. getPoint(): Vector3;
  67965. /**
  67966. * Moves the cursor ahead by the step amount
  67967. * @param step The amount to move the cursor forward
  67968. * @returns This path cursor
  67969. */
  67970. moveAhead(step?: number): PathCursor;
  67971. /**
  67972. * Moves the cursor behind by the step amount
  67973. * @param step The amount to move the cursor back
  67974. * @returns This path cursor
  67975. */
  67976. moveBack(step?: number): PathCursor;
  67977. /**
  67978. * Moves the cursor by the step amount
  67979. * If the step amount is greater than one, an exception is thrown
  67980. * @param step The amount to move the cursor
  67981. * @returns This path cursor
  67982. */
  67983. move(step: number): PathCursor;
  67984. /**
  67985. * Ensures that the value is limited between zero and one
  67986. * @returns This path cursor
  67987. */
  67988. private ensureLimits;
  67989. /**
  67990. * Runs onchange callbacks on change (used by the animation engine)
  67991. * @returns This path cursor
  67992. */
  67993. private raiseOnChange;
  67994. /**
  67995. * Executes a function on change
  67996. * @param f A path cursor onchange callback
  67997. * @returns This path cursor
  67998. */
  67999. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68000. }
  68001. }
  68002. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68003. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68004. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68005. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68006. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68007. }
  68008. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68009. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68010. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68011. }
  68012. declare module "babylonjs/Engines/Processors/index" {
  68013. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68014. export * from "babylonjs/Engines/Processors/Expressions/index";
  68015. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68016. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68017. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68018. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68019. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68020. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68021. }
  68022. declare module "babylonjs/Legacy/legacy" {
  68023. import * as Babylon from "babylonjs/index";
  68024. export * from "babylonjs/index";
  68025. }
  68026. declare module "babylonjs/Shaders/blur.fragment" {
  68027. /** @hidden */
  68028. export var blurPixelShader: {
  68029. name: string;
  68030. shader: string;
  68031. };
  68032. }
  68033. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68034. /** @hidden */
  68035. export var pointCloudVertexDeclaration: {
  68036. name: string;
  68037. shader: string;
  68038. };
  68039. }
  68040. declare module "babylonjs" {
  68041. export * from "babylonjs/Legacy/legacy";
  68042. }
  68043. declare module BABYLON {
  68044. /** Alias type for value that can be null */
  68045. export type Nullable<T> = T | null;
  68046. /**
  68047. * Alias type for number that are floats
  68048. * @ignorenaming
  68049. */
  68050. export type float = number;
  68051. /**
  68052. * Alias type for number that are doubles.
  68053. * @ignorenaming
  68054. */
  68055. export type double = number;
  68056. /**
  68057. * Alias type for number that are integer
  68058. * @ignorenaming
  68059. */
  68060. export type int = number;
  68061. /** Alias type for number array or Float32Array */
  68062. export type FloatArray = number[] | Float32Array;
  68063. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68064. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68065. /**
  68066. * Alias for types that can be used by a Buffer or VertexBuffer.
  68067. */
  68068. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68069. /**
  68070. * Alias type for primitive types
  68071. * @ignorenaming
  68072. */
  68073. type Primitive = undefined | null | boolean | string | number | Function;
  68074. /**
  68075. * Type modifier to make all the properties of an object Readonly
  68076. */
  68077. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68078. /**
  68079. * Type modifier to make all the properties of an object Readonly recursively
  68080. */
  68081. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68082. /**
  68083. * Type modifier to make object properties readonly.
  68084. */
  68085. export type DeepImmutableObject<T> = {
  68086. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68087. };
  68088. /** @hidden */
  68089. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68090. }
  68091. }
  68092. declare module BABYLON {
  68093. /**
  68094. * A class serves as a medium between the observable and its observers
  68095. */
  68096. export class EventState {
  68097. /**
  68098. * Create a new EventState
  68099. * @param mask defines the mask associated with this state
  68100. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68101. * @param target defines the original target of the state
  68102. * @param currentTarget defines the current target of the state
  68103. */
  68104. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68105. /**
  68106. * Initialize the current event state
  68107. * @param mask defines the mask associated with this state
  68108. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68109. * @param target defines the original target of the state
  68110. * @param currentTarget defines the current target of the state
  68111. * @returns the current event state
  68112. */
  68113. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68114. /**
  68115. * An Observer can set this property to true to prevent subsequent observers of being notified
  68116. */
  68117. skipNextObservers: boolean;
  68118. /**
  68119. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68120. */
  68121. mask: number;
  68122. /**
  68123. * The object that originally notified the event
  68124. */
  68125. target?: any;
  68126. /**
  68127. * The current object in the bubbling phase
  68128. */
  68129. currentTarget?: any;
  68130. /**
  68131. * This will be populated with the return value of the last function that was executed.
  68132. * If it is the first function in the callback chain it will be the event data.
  68133. */
  68134. lastReturnValue?: any;
  68135. }
  68136. /**
  68137. * Represent an Observer registered to a given Observable object.
  68138. */
  68139. export class Observer<T> {
  68140. /**
  68141. * Defines the callback to call when the observer is notified
  68142. */
  68143. callback: (eventData: T, eventState: EventState) => void;
  68144. /**
  68145. * Defines the mask of the observer (used to filter notifications)
  68146. */
  68147. mask: number;
  68148. /**
  68149. * Defines the current scope used to restore the JS context
  68150. */
  68151. scope: any;
  68152. /** @hidden */
  68153. _willBeUnregistered: boolean;
  68154. /**
  68155. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68156. */
  68157. unregisterOnNextCall: boolean;
  68158. /**
  68159. * Creates a new observer
  68160. * @param callback defines the callback to call when the observer is notified
  68161. * @param mask defines the mask of the observer (used to filter notifications)
  68162. * @param scope defines the current scope used to restore the JS context
  68163. */
  68164. constructor(
  68165. /**
  68166. * Defines the callback to call when the observer is notified
  68167. */
  68168. callback: (eventData: T, eventState: EventState) => void,
  68169. /**
  68170. * Defines the mask of the observer (used to filter notifications)
  68171. */
  68172. mask: number,
  68173. /**
  68174. * Defines the current scope used to restore the JS context
  68175. */
  68176. scope?: any);
  68177. }
  68178. /**
  68179. * Represent a list of observers registered to multiple Observables object.
  68180. */
  68181. export class MultiObserver<T> {
  68182. private _observers;
  68183. private _observables;
  68184. /**
  68185. * Release associated resources
  68186. */
  68187. dispose(): void;
  68188. /**
  68189. * Raise a callback when one of the observable will notify
  68190. * @param observables defines a list of observables to watch
  68191. * @param callback defines the callback to call on notification
  68192. * @param mask defines the mask used to filter notifications
  68193. * @param scope defines the current scope used to restore the JS context
  68194. * @returns the new MultiObserver
  68195. */
  68196. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68197. }
  68198. /**
  68199. * The Observable class is a simple implementation of the Observable pattern.
  68200. *
  68201. * 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.
  68202. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68203. * 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).
  68204. * 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.
  68205. */
  68206. export class Observable<T> {
  68207. private _observers;
  68208. private _eventState;
  68209. private _onObserverAdded;
  68210. /**
  68211. * Gets the list of observers
  68212. */
  68213. readonly observers: Array<Observer<T>>;
  68214. /**
  68215. * Creates a new observable
  68216. * @param onObserverAdded defines a callback to call when a new observer is added
  68217. */
  68218. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68219. /**
  68220. * Create a new Observer with the specified callback
  68221. * @param callback the callback that will be executed for that Observer
  68222. * @param mask the mask used to filter observers
  68223. * @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.
  68224. * @param scope optional scope for the callback to be called from
  68225. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68226. * @returns the new observer created for the callback
  68227. */
  68228. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68229. /**
  68230. * Create a new Observer with the specified callback and unregisters after the next notification
  68231. * @param callback the callback that will be executed for that Observer
  68232. * @returns the new observer created for the callback
  68233. */
  68234. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68235. /**
  68236. * Remove an Observer from the Observable object
  68237. * @param observer the instance of the Observer to remove
  68238. * @returns false if it doesn't belong to this Observable
  68239. */
  68240. remove(observer: Nullable<Observer<T>>): boolean;
  68241. /**
  68242. * Remove a callback from the Observable object
  68243. * @param callback the callback to remove
  68244. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68245. * @returns false if it doesn't belong to this Observable
  68246. */
  68247. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68248. private _deferUnregister;
  68249. private _remove;
  68250. /**
  68251. * Moves the observable to the top of the observer list making it get called first when notified
  68252. * @param observer the observer to move
  68253. */
  68254. makeObserverTopPriority(observer: Observer<T>): void;
  68255. /**
  68256. * Moves the observable to the bottom of the observer list making it get called last when notified
  68257. * @param observer the observer to move
  68258. */
  68259. makeObserverBottomPriority(observer: Observer<T>): void;
  68260. /**
  68261. * Notify all Observers by calling their respective callback with the given data
  68262. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68263. * @param eventData defines the data to send to all observers
  68264. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68265. * @param target defines the original target of the state
  68266. * @param currentTarget defines the current target of the state
  68267. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68268. */
  68269. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68270. /**
  68271. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68272. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68273. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68274. * and it is crucial that all callbacks will be executed.
  68275. * The order of the callbacks is kept, callbacks are not executed parallel.
  68276. *
  68277. * @param eventData The data to be sent to each callback
  68278. * @param mask is used to filter observers defaults to -1
  68279. * @param target defines the callback target (see EventState)
  68280. * @param currentTarget defines he current object in the bubbling phase
  68281. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68282. */
  68283. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68284. /**
  68285. * Notify a specific observer
  68286. * @param observer defines the observer to notify
  68287. * @param eventData defines the data to be sent to each callback
  68288. * @param mask is used to filter observers defaults to -1
  68289. */
  68290. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68291. /**
  68292. * Gets a boolean indicating if the observable has at least one observer
  68293. * @returns true is the Observable has at least one Observer registered
  68294. */
  68295. hasObservers(): boolean;
  68296. /**
  68297. * Clear the list of observers
  68298. */
  68299. clear(): void;
  68300. /**
  68301. * Clone the current observable
  68302. * @returns a new observable
  68303. */
  68304. clone(): Observable<T>;
  68305. /**
  68306. * Does this observable handles observer registered with a given mask
  68307. * @param mask defines the mask to be tested
  68308. * @return whether or not one observer registered with the given mask is handeled
  68309. **/
  68310. hasSpecificMask(mask?: number): boolean;
  68311. }
  68312. }
  68313. declare module BABYLON {
  68314. /**
  68315. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68316. * Babylon.js
  68317. */
  68318. export class DomManagement {
  68319. /**
  68320. * Checks if the window object exists
  68321. * @returns true if the window object exists
  68322. */
  68323. static IsWindowObjectExist(): boolean;
  68324. /**
  68325. * Checks if the navigator object exists
  68326. * @returns true if the navigator object exists
  68327. */
  68328. static IsNavigatorAvailable(): boolean;
  68329. /**
  68330. * Extracts text content from a DOM element hierarchy
  68331. * @param element defines the root element
  68332. * @returns a string
  68333. */
  68334. static GetDOMTextContent(element: HTMLElement): string;
  68335. }
  68336. }
  68337. declare module BABYLON {
  68338. /**
  68339. * Logger used througouht the application to allow configuration of
  68340. * the log level required for the messages.
  68341. */
  68342. export class Logger {
  68343. /**
  68344. * No log
  68345. */
  68346. static readonly NoneLogLevel: number;
  68347. /**
  68348. * Only message logs
  68349. */
  68350. static readonly MessageLogLevel: number;
  68351. /**
  68352. * Only warning logs
  68353. */
  68354. static readonly WarningLogLevel: number;
  68355. /**
  68356. * Only error logs
  68357. */
  68358. static readonly ErrorLogLevel: number;
  68359. /**
  68360. * All logs
  68361. */
  68362. static readonly AllLogLevel: number;
  68363. private static _LogCache;
  68364. /**
  68365. * Gets a value indicating the number of loading errors
  68366. * @ignorenaming
  68367. */
  68368. static errorsCount: number;
  68369. /**
  68370. * Callback called when a new log is added
  68371. */
  68372. static OnNewCacheEntry: (entry: string) => void;
  68373. private static _AddLogEntry;
  68374. private static _FormatMessage;
  68375. private static _LogDisabled;
  68376. private static _LogEnabled;
  68377. private static _WarnDisabled;
  68378. private static _WarnEnabled;
  68379. private static _ErrorDisabled;
  68380. private static _ErrorEnabled;
  68381. /**
  68382. * Log a message to the console
  68383. */
  68384. static Log: (message: string) => void;
  68385. /**
  68386. * Write a warning message to the console
  68387. */
  68388. static Warn: (message: string) => void;
  68389. /**
  68390. * Write an error message to the console
  68391. */
  68392. static Error: (message: string) => void;
  68393. /**
  68394. * Gets current log cache (list of logs)
  68395. */
  68396. static readonly LogCache: string;
  68397. /**
  68398. * Clears the log cache
  68399. */
  68400. static ClearLogCache(): void;
  68401. /**
  68402. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68403. */
  68404. static LogLevels: number;
  68405. }
  68406. }
  68407. declare module BABYLON {
  68408. /** @hidden */
  68409. export class _TypeStore {
  68410. /** @hidden */
  68411. static RegisteredTypes: {
  68412. [key: string]: Object;
  68413. };
  68414. /** @hidden */
  68415. static GetClass(fqdn: string): any;
  68416. }
  68417. }
  68418. declare module BABYLON {
  68419. /**
  68420. * Helper to manipulate strings
  68421. */
  68422. export class StringTools {
  68423. /**
  68424. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68425. * @param str Source string
  68426. * @param suffix Suffix to search for in the source string
  68427. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68428. */
  68429. static EndsWith(str: string, suffix: string): boolean;
  68430. /**
  68431. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68432. * @param str Source string
  68433. * @param suffix Suffix to search for in the source string
  68434. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68435. */
  68436. static StartsWith(str: string, suffix: string): boolean;
  68437. /**
  68438. * Decodes a buffer into a string
  68439. * @param buffer The buffer to decode
  68440. * @returns The decoded string
  68441. */
  68442. static Decode(buffer: Uint8Array | Uint16Array): string;
  68443. /**
  68444. * Encode a buffer to a base64 string
  68445. * @param buffer defines the buffer to encode
  68446. * @returns the encoded string
  68447. */
  68448. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68449. }
  68450. }
  68451. declare module BABYLON {
  68452. /**
  68453. * Class containing a set of static utilities functions for deep copy.
  68454. */
  68455. export class DeepCopier {
  68456. /**
  68457. * Tries to copy an object by duplicating every property
  68458. * @param source defines the source object
  68459. * @param destination defines the target object
  68460. * @param doNotCopyList defines a list of properties to avoid
  68461. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68462. */
  68463. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68464. }
  68465. }
  68466. declare module BABYLON {
  68467. /**
  68468. * Class containing a set of static utilities functions for precision date
  68469. */
  68470. export class PrecisionDate {
  68471. /**
  68472. * Gets either window.performance.now() if supported or Date.now() else
  68473. */
  68474. static readonly Now: number;
  68475. }
  68476. }
  68477. declare module BABYLON {
  68478. /** @hidden */
  68479. export class _DevTools {
  68480. static WarnImport(name: string): string;
  68481. }
  68482. }
  68483. declare module BABYLON {
  68484. /**
  68485. * Interface used to define the mechanism to get data from the network
  68486. */
  68487. export interface IWebRequest {
  68488. /**
  68489. * Returns client's response url
  68490. */
  68491. responseURL: string;
  68492. /**
  68493. * Returns client's status
  68494. */
  68495. status: number;
  68496. /**
  68497. * Returns client's status as a text
  68498. */
  68499. statusText: string;
  68500. }
  68501. }
  68502. declare module BABYLON {
  68503. /**
  68504. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68505. */
  68506. export class WebRequest implements IWebRequest {
  68507. private _xhr;
  68508. /**
  68509. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68510. * i.e. when loading files, where the server/service expects an Authorization header
  68511. */
  68512. static CustomRequestHeaders: {
  68513. [key: string]: string;
  68514. };
  68515. /**
  68516. * Add callback functions in this array to update all the requests before they get sent to the network
  68517. */
  68518. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68519. private _injectCustomRequestHeaders;
  68520. /**
  68521. * Gets or sets a function to be called when loading progress changes
  68522. */
  68523. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68524. /**
  68525. * Returns client's state
  68526. */
  68527. readonly readyState: number;
  68528. /**
  68529. * Returns client's status
  68530. */
  68531. readonly status: number;
  68532. /**
  68533. * Returns client's status as a text
  68534. */
  68535. readonly statusText: string;
  68536. /**
  68537. * Returns client's response
  68538. */
  68539. readonly response: any;
  68540. /**
  68541. * Returns client's response url
  68542. */
  68543. readonly responseURL: string;
  68544. /**
  68545. * Returns client's response as text
  68546. */
  68547. readonly responseText: string;
  68548. /**
  68549. * Gets or sets the expected response type
  68550. */
  68551. responseType: XMLHttpRequestResponseType;
  68552. /** @hidden */
  68553. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68554. /** @hidden */
  68555. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68556. /**
  68557. * Cancels any network activity
  68558. */
  68559. abort(): void;
  68560. /**
  68561. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68562. * @param body defines an optional request body
  68563. */
  68564. send(body?: Document | BodyInit | null): void;
  68565. /**
  68566. * Sets the request method, request URL
  68567. * @param method defines the method to use (GET, POST, etc..)
  68568. * @param url defines the url to connect with
  68569. */
  68570. open(method: string, url: string): void;
  68571. /**
  68572. * Sets the value of a request header.
  68573. * @param name The name of the header whose value is to be set
  68574. * @param value The value to set as the body of the header
  68575. */
  68576. setRequestHeader(name: string, value: string): void;
  68577. /**
  68578. * Get the string containing the text of a particular header's value.
  68579. * @param name The name of the header
  68580. * @returns The string containing the text of the given header name
  68581. */
  68582. getResponseHeader(name: string): Nullable<string>;
  68583. }
  68584. }
  68585. declare module BABYLON {
  68586. /**
  68587. * File request interface
  68588. */
  68589. export interface IFileRequest {
  68590. /**
  68591. * Raised when the request is complete (success or error).
  68592. */
  68593. onCompleteObservable: Observable<IFileRequest>;
  68594. /**
  68595. * Aborts the request for a file.
  68596. */
  68597. abort: () => void;
  68598. }
  68599. }
  68600. declare module BABYLON {
  68601. /**
  68602. * Define options used to create a render target texture
  68603. */
  68604. export class RenderTargetCreationOptions {
  68605. /**
  68606. * Specifies is mipmaps must be generated
  68607. */
  68608. generateMipMaps?: boolean;
  68609. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68610. generateDepthBuffer?: boolean;
  68611. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68612. generateStencilBuffer?: boolean;
  68613. /** Defines texture type (int by default) */
  68614. type?: number;
  68615. /** Defines sampling mode (trilinear by default) */
  68616. samplingMode?: number;
  68617. /** Defines format (RGBA by default) */
  68618. format?: number;
  68619. }
  68620. }
  68621. declare module BABYLON {
  68622. /**
  68623. * @hidden
  68624. **/
  68625. export class _TimeToken {
  68626. _startTimeQuery: Nullable<WebGLQuery>;
  68627. _endTimeQuery: Nullable<WebGLQuery>;
  68628. _timeElapsedQuery: Nullable<WebGLQuery>;
  68629. _timeElapsedQueryEnded: boolean;
  68630. }
  68631. }
  68632. declare module BABYLON {
  68633. /** Defines the cross module used constants to avoid circular dependncies */
  68634. export class Constants {
  68635. /** Defines that alpha blending is disabled */
  68636. static readonly ALPHA_DISABLE: number;
  68637. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68638. static readonly ALPHA_ADD: number;
  68639. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68640. static readonly ALPHA_COMBINE: number;
  68641. /** Defines that alpha blending to DEST - SRC * DEST */
  68642. static readonly ALPHA_SUBTRACT: number;
  68643. /** Defines that alpha blending to SRC * DEST */
  68644. static readonly ALPHA_MULTIPLY: number;
  68645. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68646. static readonly ALPHA_MAXIMIZED: number;
  68647. /** Defines that alpha blending to SRC + DEST */
  68648. static readonly ALPHA_ONEONE: number;
  68649. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68650. static readonly ALPHA_PREMULTIPLIED: number;
  68651. /**
  68652. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68653. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68654. */
  68655. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68656. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68657. static readonly ALPHA_INTERPOLATE: number;
  68658. /**
  68659. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68660. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68661. */
  68662. static readonly ALPHA_SCREENMODE: number;
  68663. /**
  68664. * Defines that alpha blending to SRC + DST
  68665. * Alpha will be set to SRC ALPHA + DST ALPHA
  68666. */
  68667. static readonly ALPHA_ONEONE_ONEONE: number;
  68668. /**
  68669. * Defines that alpha blending to SRC * DST ALPHA + DST
  68670. * Alpha will be set to 0
  68671. */
  68672. static readonly ALPHA_ALPHATOCOLOR: number;
  68673. /**
  68674. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68675. */
  68676. static readonly ALPHA_REVERSEONEMINUS: number;
  68677. /**
  68678. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68679. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68680. */
  68681. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68682. /**
  68683. * Defines that alpha blending to SRC + DST
  68684. * Alpha will be set to SRC ALPHA
  68685. */
  68686. static readonly ALPHA_ONEONE_ONEZERO: number;
  68687. /** Defines that alpha blending equation a SUM */
  68688. static readonly ALPHA_EQUATION_ADD: number;
  68689. /** Defines that alpha blending equation a SUBSTRACTION */
  68690. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68691. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68692. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68693. /** Defines that alpha blending equation a MAX operation */
  68694. static readonly ALPHA_EQUATION_MAX: number;
  68695. /** Defines that alpha blending equation a MIN operation */
  68696. static readonly ALPHA_EQUATION_MIN: number;
  68697. /**
  68698. * Defines that alpha blending equation a DARKEN operation:
  68699. * It takes the min of the src and sums the alpha channels.
  68700. */
  68701. static readonly ALPHA_EQUATION_DARKEN: number;
  68702. /** Defines that the ressource is not delayed*/
  68703. static readonly DELAYLOADSTATE_NONE: number;
  68704. /** Defines that the ressource was successfully delay loaded */
  68705. static readonly DELAYLOADSTATE_LOADED: number;
  68706. /** Defines that the ressource is currently delay loading */
  68707. static readonly DELAYLOADSTATE_LOADING: number;
  68708. /** Defines that the ressource is delayed and has not started loading */
  68709. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68710. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68711. static readonly NEVER: number;
  68712. /** 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 */
  68713. static readonly ALWAYS: number;
  68714. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68715. static readonly LESS: number;
  68716. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68717. static readonly EQUAL: number;
  68718. /** 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 */
  68719. static readonly LEQUAL: number;
  68720. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68721. static readonly GREATER: number;
  68722. /** 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 */
  68723. static readonly GEQUAL: number;
  68724. /** 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 */
  68725. static readonly NOTEQUAL: number;
  68726. /** Passed to stencilOperation to specify that stencil value must be kept */
  68727. static readonly KEEP: number;
  68728. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68729. static readonly REPLACE: number;
  68730. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68731. static readonly INCR: number;
  68732. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68733. static readonly DECR: number;
  68734. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68735. static readonly INVERT: number;
  68736. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68737. static readonly INCR_WRAP: number;
  68738. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68739. static readonly DECR_WRAP: number;
  68740. /** Texture is not repeating outside of 0..1 UVs */
  68741. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68742. /** Texture is repeating outside of 0..1 UVs */
  68743. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68744. /** Texture is repeating and mirrored */
  68745. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68746. /** ALPHA */
  68747. static readonly TEXTUREFORMAT_ALPHA: number;
  68748. /** LUMINANCE */
  68749. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68750. /** LUMINANCE_ALPHA */
  68751. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68752. /** RGB */
  68753. static readonly TEXTUREFORMAT_RGB: number;
  68754. /** RGBA */
  68755. static readonly TEXTUREFORMAT_RGBA: number;
  68756. /** RED */
  68757. static readonly TEXTUREFORMAT_RED: number;
  68758. /** RED (2nd reference) */
  68759. static readonly TEXTUREFORMAT_R: number;
  68760. /** RG */
  68761. static readonly TEXTUREFORMAT_RG: number;
  68762. /** RED_INTEGER */
  68763. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68764. /** RED_INTEGER (2nd reference) */
  68765. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68766. /** RG_INTEGER */
  68767. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68768. /** RGB_INTEGER */
  68769. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68770. /** RGBA_INTEGER */
  68771. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68772. /** UNSIGNED_BYTE */
  68773. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68774. /** UNSIGNED_BYTE (2nd reference) */
  68775. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68776. /** FLOAT */
  68777. static readonly TEXTURETYPE_FLOAT: number;
  68778. /** HALF_FLOAT */
  68779. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68780. /** BYTE */
  68781. static readonly TEXTURETYPE_BYTE: number;
  68782. /** SHORT */
  68783. static readonly TEXTURETYPE_SHORT: number;
  68784. /** UNSIGNED_SHORT */
  68785. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68786. /** INT */
  68787. static readonly TEXTURETYPE_INT: number;
  68788. /** UNSIGNED_INT */
  68789. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68790. /** UNSIGNED_SHORT_4_4_4_4 */
  68791. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68792. /** UNSIGNED_SHORT_5_5_5_1 */
  68793. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68794. /** UNSIGNED_SHORT_5_6_5 */
  68795. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68796. /** UNSIGNED_INT_2_10_10_10_REV */
  68797. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68798. /** UNSIGNED_INT_24_8 */
  68799. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68800. /** UNSIGNED_INT_10F_11F_11F_REV */
  68801. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68802. /** UNSIGNED_INT_5_9_9_9_REV */
  68803. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68804. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68805. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68806. /** nearest is mag = nearest and min = nearest and mip = linear */
  68807. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68809. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68810. /** Trilinear is mag = linear and min = linear and mip = linear */
  68811. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68812. /** nearest is mag = nearest and min = nearest and mip = linear */
  68813. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68814. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68815. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68816. /** Trilinear is mag = linear and min = linear and mip = linear */
  68817. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68818. /** mag = nearest and min = nearest and mip = nearest */
  68819. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68820. /** mag = nearest and min = linear and mip = nearest */
  68821. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68822. /** mag = nearest and min = linear and mip = linear */
  68823. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68824. /** mag = nearest and min = linear and mip = none */
  68825. static readonly TEXTURE_NEAREST_LINEAR: number;
  68826. /** mag = nearest and min = nearest and mip = none */
  68827. static readonly TEXTURE_NEAREST_NEAREST: number;
  68828. /** mag = linear and min = nearest and mip = nearest */
  68829. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68830. /** mag = linear and min = nearest and mip = linear */
  68831. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68832. /** mag = linear and min = linear and mip = none */
  68833. static readonly TEXTURE_LINEAR_LINEAR: number;
  68834. /** mag = linear and min = nearest and mip = none */
  68835. static readonly TEXTURE_LINEAR_NEAREST: number;
  68836. /** Explicit coordinates mode */
  68837. static readonly TEXTURE_EXPLICIT_MODE: number;
  68838. /** Spherical coordinates mode */
  68839. static readonly TEXTURE_SPHERICAL_MODE: number;
  68840. /** Planar coordinates mode */
  68841. static readonly TEXTURE_PLANAR_MODE: number;
  68842. /** Cubic coordinates mode */
  68843. static readonly TEXTURE_CUBIC_MODE: number;
  68844. /** Projection coordinates mode */
  68845. static readonly TEXTURE_PROJECTION_MODE: number;
  68846. /** Skybox coordinates mode */
  68847. static readonly TEXTURE_SKYBOX_MODE: number;
  68848. /** Inverse Cubic coordinates mode */
  68849. static readonly TEXTURE_INVCUBIC_MODE: number;
  68850. /** Equirectangular coordinates mode */
  68851. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68852. /** Equirectangular Fixed coordinates mode */
  68853. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68854. /** Equirectangular Fixed Mirrored coordinates mode */
  68855. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68856. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68857. static readonly SCALEMODE_FLOOR: number;
  68858. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68859. static readonly SCALEMODE_NEAREST: number;
  68860. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68861. static readonly SCALEMODE_CEILING: number;
  68862. /**
  68863. * The dirty texture flag value
  68864. */
  68865. static readonly MATERIAL_TextureDirtyFlag: number;
  68866. /**
  68867. * The dirty light flag value
  68868. */
  68869. static readonly MATERIAL_LightDirtyFlag: number;
  68870. /**
  68871. * The dirty fresnel flag value
  68872. */
  68873. static readonly MATERIAL_FresnelDirtyFlag: number;
  68874. /**
  68875. * The dirty attribute flag value
  68876. */
  68877. static readonly MATERIAL_AttributesDirtyFlag: number;
  68878. /**
  68879. * The dirty misc flag value
  68880. */
  68881. static readonly MATERIAL_MiscDirtyFlag: number;
  68882. /**
  68883. * The all dirty flag value
  68884. */
  68885. static readonly MATERIAL_AllDirtyFlag: number;
  68886. /**
  68887. * Returns the triangle fill mode
  68888. */
  68889. static readonly MATERIAL_TriangleFillMode: number;
  68890. /**
  68891. * Returns the wireframe mode
  68892. */
  68893. static readonly MATERIAL_WireFrameFillMode: number;
  68894. /**
  68895. * Returns the point fill mode
  68896. */
  68897. static readonly MATERIAL_PointFillMode: number;
  68898. /**
  68899. * Returns the point list draw mode
  68900. */
  68901. static readonly MATERIAL_PointListDrawMode: number;
  68902. /**
  68903. * Returns the line list draw mode
  68904. */
  68905. static readonly MATERIAL_LineListDrawMode: number;
  68906. /**
  68907. * Returns the line loop draw mode
  68908. */
  68909. static readonly MATERIAL_LineLoopDrawMode: number;
  68910. /**
  68911. * Returns the line strip draw mode
  68912. */
  68913. static readonly MATERIAL_LineStripDrawMode: number;
  68914. /**
  68915. * Returns the triangle strip draw mode
  68916. */
  68917. static readonly MATERIAL_TriangleStripDrawMode: number;
  68918. /**
  68919. * Returns the triangle fan draw mode
  68920. */
  68921. static readonly MATERIAL_TriangleFanDrawMode: number;
  68922. /**
  68923. * Stores the clock-wise side orientation
  68924. */
  68925. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68926. /**
  68927. * Stores the counter clock-wise side orientation
  68928. */
  68929. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68930. /**
  68931. * Nothing
  68932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68933. */
  68934. static readonly ACTION_NothingTrigger: number;
  68935. /**
  68936. * On pick
  68937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68938. */
  68939. static readonly ACTION_OnPickTrigger: number;
  68940. /**
  68941. * On left pick
  68942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68943. */
  68944. static readonly ACTION_OnLeftPickTrigger: number;
  68945. /**
  68946. * On right pick
  68947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68948. */
  68949. static readonly ACTION_OnRightPickTrigger: number;
  68950. /**
  68951. * On center pick
  68952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68953. */
  68954. static readonly ACTION_OnCenterPickTrigger: number;
  68955. /**
  68956. * On pick down
  68957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68958. */
  68959. static readonly ACTION_OnPickDownTrigger: number;
  68960. /**
  68961. * On double pick
  68962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68963. */
  68964. static readonly ACTION_OnDoublePickTrigger: number;
  68965. /**
  68966. * On pick up
  68967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68968. */
  68969. static readonly ACTION_OnPickUpTrigger: number;
  68970. /**
  68971. * On pick out.
  68972. * This trigger will only be raised if you also declared a OnPickDown
  68973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68974. */
  68975. static readonly ACTION_OnPickOutTrigger: number;
  68976. /**
  68977. * On long press
  68978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68979. */
  68980. static readonly ACTION_OnLongPressTrigger: number;
  68981. /**
  68982. * On pointer over
  68983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68984. */
  68985. static readonly ACTION_OnPointerOverTrigger: number;
  68986. /**
  68987. * On pointer out
  68988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68989. */
  68990. static readonly ACTION_OnPointerOutTrigger: number;
  68991. /**
  68992. * On every frame
  68993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68994. */
  68995. static readonly ACTION_OnEveryFrameTrigger: number;
  68996. /**
  68997. * On intersection enter
  68998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68999. */
  69000. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69001. /**
  69002. * On intersection exit
  69003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69004. */
  69005. static readonly ACTION_OnIntersectionExitTrigger: number;
  69006. /**
  69007. * On key down
  69008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69009. */
  69010. static readonly ACTION_OnKeyDownTrigger: number;
  69011. /**
  69012. * On key up
  69013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69014. */
  69015. static readonly ACTION_OnKeyUpTrigger: number;
  69016. /**
  69017. * Billboard mode will only apply to Y axis
  69018. */
  69019. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69020. /**
  69021. * Billboard mode will apply to all axes
  69022. */
  69023. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69024. /**
  69025. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69026. */
  69027. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69028. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69029. * Test order :
  69030. * Is the bounding sphere outside the frustum ?
  69031. * If not, are the bounding box vertices outside the frustum ?
  69032. * It not, then the cullable object is in the frustum.
  69033. */
  69034. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69035. /** Culling strategy : Bounding Sphere Only.
  69036. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69037. * It's also less accurate than the standard because some not visible objects can still be selected.
  69038. * Test : is the bounding sphere outside the frustum ?
  69039. * If not, then the cullable object is in the frustum.
  69040. */
  69041. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69042. /** Culling strategy : Optimistic Inclusion.
  69043. * This in an inclusion test first, then the standard exclusion test.
  69044. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69045. * 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.
  69046. * Anyway, it's as accurate as the standard strategy.
  69047. * Test :
  69048. * Is the cullable object bounding sphere center in the frustum ?
  69049. * If not, apply the default culling strategy.
  69050. */
  69051. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69052. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69053. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69054. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69055. * 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.
  69056. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69057. * Test :
  69058. * Is the cullable object bounding sphere center in the frustum ?
  69059. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69060. */
  69061. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69062. /**
  69063. * No logging while loading
  69064. */
  69065. static readonly SCENELOADER_NO_LOGGING: number;
  69066. /**
  69067. * Minimal logging while loading
  69068. */
  69069. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69070. /**
  69071. * Summary logging while loading
  69072. */
  69073. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69074. /**
  69075. * Detailled logging while loading
  69076. */
  69077. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69078. }
  69079. }
  69080. declare module BABYLON {
  69081. /**
  69082. * This represents the required contract to create a new type of texture loader.
  69083. */
  69084. export interface IInternalTextureLoader {
  69085. /**
  69086. * Defines wether the loader supports cascade loading the different faces.
  69087. */
  69088. supportCascades: boolean;
  69089. /**
  69090. * This returns if the loader support the current file information.
  69091. * @param extension defines the file extension of the file being loaded
  69092. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69093. * @param fallback defines the fallback internal texture if any
  69094. * @param isBase64 defines whether the texture is encoded as a base64
  69095. * @param isBuffer defines whether the texture data are stored as a buffer
  69096. * @returns true if the loader can load the specified file
  69097. */
  69098. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69099. /**
  69100. * Transform the url before loading if required.
  69101. * @param rootUrl the url of the texture
  69102. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69103. * @returns the transformed texture
  69104. */
  69105. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69106. /**
  69107. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69108. * @param rootUrl the url of the texture
  69109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69110. * @returns the fallback texture
  69111. */
  69112. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69113. /**
  69114. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69115. * @param data contains the texture data
  69116. * @param texture defines the BabylonJS internal texture
  69117. * @param createPolynomials will be true if polynomials have been requested
  69118. * @param onLoad defines the callback to trigger once the texture is ready
  69119. * @param onError defines the callback to trigger in case of error
  69120. */
  69121. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69122. /**
  69123. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69124. * @param data contains the texture data
  69125. * @param texture defines the BabylonJS internal texture
  69126. * @param callback defines the method to call once ready to upload
  69127. */
  69128. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69129. }
  69130. }
  69131. declare module BABYLON {
  69132. /**
  69133. * Class used to store and describe the pipeline context associated with an effect
  69134. */
  69135. export interface IPipelineContext {
  69136. /**
  69137. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69138. */
  69139. isAsync: boolean;
  69140. /**
  69141. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69142. */
  69143. isReady: boolean;
  69144. /** @hidden */
  69145. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69146. }
  69147. }
  69148. declare module BABYLON {
  69149. /**
  69150. * Class used to store gfx data (like WebGLBuffer)
  69151. */
  69152. export class DataBuffer {
  69153. /**
  69154. * Gets or sets the number of objects referencing this buffer
  69155. */
  69156. references: number;
  69157. /** Gets or sets the size of the underlying buffer */
  69158. capacity: number;
  69159. /**
  69160. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69161. */
  69162. is32Bits: boolean;
  69163. /**
  69164. * Gets the underlying buffer
  69165. */
  69166. readonly underlyingResource: any;
  69167. }
  69168. }
  69169. declare module BABYLON {
  69170. /** @hidden */
  69171. export interface IShaderProcessor {
  69172. attributeProcessor?: (attribute: string) => string;
  69173. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69174. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69175. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69176. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69177. lineProcessor?: (line: string, isFragment: boolean) => string;
  69178. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69179. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69180. }
  69181. }
  69182. declare module BABYLON {
  69183. /** @hidden */
  69184. export interface ProcessingOptions {
  69185. defines: string[];
  69186. indexParameters: any;
  69187. isFragment: boolean;
  69188. shouldUseHighPrecisionShader: boolean;
  69189. supportsUniformBuffers: boolean;
  69190. shadersRepository: string;
  69191. includesShadersStore: {
  69192. [key: string]: string;
  69193. };
  69194. processor?: IShaderProcessor;
  69195. version: string;
  69196. platformName: string;
  69197. lookForClosingBracketForUniformBuffer?: boolean;
  69198. }
  69199. }
  69200. declare module BABYLON {
  69201. /** @hidden */
  69202. export class ShaderCodeNode {
  69203. line: string;
  69204. children: ShaderCodeNode[];
  69205. additionalDefineKey?: string;
  69206. additionalDefineValue?: string;
  69207. isValid(preprocessors: {
  69208. [key: string]: string;
  69209. }): boolean;
  69210. process(preprocessors: {
  69211. [key: string]: string;
  69212. }, options: ProcessingOptions): string;
  69213. }
  69214. }
  69215. declare module BABYLON {
  69216. /** @hidden */
  69217. export class ShaderCodeCursor {
  69218. private _lines;
  69219. lineIndex: number;
  69220. readonly currentLine: string;
  69221. readonly canRead: boolean;
  69222. lines: string[];
  69223. }
  69224. }
  69225. declare module BABYLON {
  69226. /** @hidden */
  69227. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69228. process(preprocessors: {
  69229. [key: string]: string;
  69230. }, options: ProcessingOptions): string;
  69231. }
  69232. }
  69233. declare module BABYLON {
  69234. /** @hidden */
  69235. export class ShaderDefineExpression {
  69236. isTrue(preprocessors: {
  69237. [key: string]: string;
  69238. }): boolean;
  69239. }
  69240. }
  69241. declare module BABYLON {
  69242. /** @hidden */
  69243. export class ShaderCodeTestNode extends ShaderCodeNode {
  69244. testExpression: ShaderDefineExpression;
  69245. isValid(preprocessors: {
  69246. [key: string]: string;
  69247. }): boolean;
  69248. }
  69249. }
  69250. declare module BABYLON {
  69251. /** @hidden */
  69252. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69253. define: string;
  69254. not: boolean;
  69255. constructor(define: string, not?: boolean);
  69256. isTrue(preprocessors: {
  69257. [key: string]: string;
  69258. }): boolean;
  69259. }
  69260. }
  69261. declare module BABYLON {
  69262. /** @hidden */
  69263. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69264. leftOperand: ShaderDefineExpression;
  69265. rightOperand: ShaderDefineExpression;
  69266. isTrue(preprocessors: {
  69267. [key: string]: string;
  69268. }): boolean;
  69269. }
  69270. }
  69271. declare module BABYLON {
  69272. /** @hidden */
  69273. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69274. leftOperand: ShaderDefineExpression;
  69275. rightOperand: ShaderDefineExpression;
  69276. isTrue(preprocessors: {
  69277. [key: string]: string;
  69278. }): boolean;
  69279. }
  69280. }
  69281. declare module BABYLON {
  69282. /** @hidden */
  69283. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69284. define: string;
  69285. operand: string;
  69286. testValue: string;
  69287. constructor(define: string, operand: string, testValue: string);
  69288. isTrue(preprocessors: {
  69289. [key: string]: string;
  69290. }): boolean;
  69291. }
  69292. }
  69293. declare module BABYLON {
  69294. /**
  69295. * Class used to enable access to offline support
  69296. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69297. */
  69298. export interface IOfflineProvider {
  69299. /**
  69300. * Gets a boolean indicating if scene must be saved in the database
  69301. */
  69302. enableSceneOffline: boolean;
  69303. /**
  69304. * Gets a boolean indicating if textures must be saved in the database
  69305. */
  69306. enableTexturesOffline: boolean;
  69307. /**
  69308. * Open the offline support and make it available
  69309. * @param successCallback defines the callback to call on success
  69310. * @param errorCallback defines the callback to call on error
  69311. */
  69312. open(successCallback: () => void, errorCallback: () => void): void;
  69313. /**
  69314. * Loads an image from the offline support
  69315. * @param url defines the url to load from
  69316. * @param image defines the target DOM image
  69317. */
  69318. loadImage(url: string, image: HTMLImageElement): void;
  69319. /**
  69320. * Loads a file from offline support
  69321. * @param url defines the URL to load from
  69322. * @param sceneLoaded defines a callback to call on success
  69323. * @param progressCallBack defines a callback to call when progress changed
  69324. * @param errorCallback defines a callback to call on error
  69325. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69326. */
  69327. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69328. }
  69329. }
  69330. declare module BABYLON {
  69331. /**
  69332. * Class used to help managing file picking and drag'n'drop
  69333. * File Storage
  69334. */
  69335. export class FilesInputStore {
  69336. /**
  69337. * List of files ready to be loaded
  69338. */
  69339. static FilesToLoad: {
  69340. [key: string]: File;
  69341. };
  69342. }
  69343. }
  69344. declare module BABYLON {
  69345. /**
  69346. * Class used to define a retry strategy when error happens while loading assets
  69347. */
  69348. export class RetryStrategy {
  69349. /**
  69350. * Function used to defines an exponential back off strategy
  69351. * @param maxRetries defines the maximum number of retries (3 by default)
  69352. * @param baseInterval defines the interval between retries
  69353. * @returns the strategy function to use
  69354. */
  69355. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69356. }
  69357. }
  69358. declare module BABYLON {
  69359. /**
  69360. * @ignore
  69361. * Application error to support additional information when loading a file
  69362. */
  69363. export abstract class BaseError extends Error {
  69364. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69365. }
  69366. }
  69367. declare module BABYLON {
  69368. /** @ignore */
  69369. export class LoadFileError extends BaseError {
  69370. request?: WebRequest;
  69371. file?: File;
  69372. /**
  69373. * Creates a new LoadFileError
  69374. * @param message defines the message of the error
  69375. * @param request defines the optional web request
  69376. * @param file defines the optional file
  69377. */
  69378. constructor(message: string, object?: WebRequest | File);
  69379. }
  69380. /** @ignore */
  69381. export class RequestFileError extends BaseError {
  69382. request: WebRequest;
  69383. /**
  69384. * Creates a new LoadFileError
  69385. * @param message defines the message of the error
  69386. * @param request defines the optional web request
  69387. */
  69388. constructor(message: string, request: WebRequest);
  69389. }
  69390. /** @ignore */
  69391. export class ReadFileError extends BaseError {
  69392. file: File;
  69393. /**
  69394. * Creates a new ReadFileError
  69395. * @param message defines the message of the error
  69396. * @param file defines the optional file
  69397. */
  69398. constructor(message: string, file: File);
  69399. }
  69400. /**
  69401. * @hidden
  69402. */
  69403. export class FileTools {
  69404. /**
  69405. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69406. */
  69407. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69408. /**
  69409. * Gets or sets the base URL to use to load assets
  69410. */
  69411. static BaseUrl: string;
  69412. /**
  69413. * Default behaviour for cors in the application.
  69414. * It can be a string if the expected behavior is identical in the entire app.
  69415. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69416. */
  69417. static CorsBehavior: string | ((url: string | string[]) => string);
  69418. /**
  69419. * Gets or sets a function used to pre-process url before using them to load assets
  69420. */
  69421. static PreprocessUrl: (url: string) => string;
  69422. /**
  69423. * Removes unwanted characters from an url
  69424. * @param url defines the url to clean
  69425. * @returns the cleaned url
  69426. */
  69427. private static _CleanUrl;
  69428. /**
  69429. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69430. * @param url define the url we are trying
  69431. * @param element define the dom element where to configure the cors policy
  69432. */
  69433. static SetCorsBehavior(url: string | string[], element: {
  69434. crossOrigin: string | null;
  69435. }): void;
  69436. /**
  69437. * Loads an image as an HTMLImageElement.
  69438. * @param input url string, ArrayBuffer, or Blob to load
  69439. * @param onLoad callback called when the image successfully loads
  69440. * @param onError callback called when the image fails to load
  69441. * @param offlineProvider offline provider for caching
  69442. * @param mimeType optional mime type
  69443. * @returns the HTMLImageElement of the loaded image
  69444. */
  69445. 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>;
  69446. /**
  69447. * Reads a file from a File object
  69448. * @param file defines the file to load
  69449. * @param onSuccess defines the callback to call when data is loaded
  69450. * @param onProgress defines the callback to call during loading process
  69451. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69452. * @param onError defines the callback to call when an error occurs
  69453. * @returns a file request object
  69454. */
  69455. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69456. /**
  69457. * Loads a file from a url
  69458. * @param url url to load
  69459. * @param onSuccess callback called when the file successfully loads
  69460. * @param onProgress callback called while file is loading (if the server supports this mode)
  69461. * @param offlineProvider defines the offline provider for caching
  69462. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69463. * @param onError callback called when the file fails to load
  69464. * @returns a file request object
  69465. */
  69466. 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;
  69467. /**
  69468. * Loads a file
  69469. * @param url url to load
  69470. * @param onSuccess callback called when the file successfully loads
  69471. * @param onProgress callback called while file is loading (if the server supports this mode)
  69472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69473. * @param onError callback called when the file fails to load
  69474. * @param onOpened callback called when the web request is opened
  69475. * @returns a file request object
  69476. */
  69477. 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;
  69478. /**
  69479. * Checks if the loaded document was accessed via `file:`-Protocol.
  69480. * @returns boolean
  69481. */
  69482. static IsFileURL(): boolean;
  69483. }
  69484. }
  69485. declare module BABYLON {
  69486. /** @hidden */
  69487. export class ShaderProcessor {
  69488. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69489. private static _ProcessPrecision;
  69490. private static _ExtractOperation;
  69491. private static _BuildSubExpression;
  69492. private static _BuildExpression;
  69493. private static _MoveCursorWithinIf;
  69494. private static _MoveCursor;
  69495. private static _EvaluatePreProcessors;
  69496. private static _PreparePreProcessors;
  69497. private static _ProcessShaderConversion;
  69498. private static _ProcessIncludes;
  69499. }
  69500. }
  69501. declare module BABYLON {
  69502. /**
  69503. * @hidden
  69504. */
  69505. export interface IColor4Like {
  69506. r: float;
  69507. g: float;
  69508. b: float;
  69509. a: float;
  69510. }
  69511. /**
  69512. * @hidden
  69513. */
  69514. export interface IColor3Like {
  69515. r: float;
  69516. g: float;
  69517. b: float;
  69518. }
  69519. /**
  69520. * @hidden
  69521. */
  69522. export interface IVector4Like {
  69523. x: float;
  69524. y: float;
  69525. z: float;
  69526. w: float;
  69527. }
  69528. /**
  69529. * @hidden
  69530. */
  69531. export interface IVector3Like {
  69532. x: float;
  69533. y: float;
  69534. z: float;
  69535. }
  69536. /**
  69537. * @hidden
  69538. */
  69539. export interface IVector2Like {
  69540. x: float;
  69541. y: float;
  69542. }
  69543. /**
  69544. * @hidden
  69545. */
  69546. export interface IMatrixLike {
  69547. toArray(): DeepImmutable<Float32Array>;
  69548. updateFlag: int;
  69549. }
  69550. /**
  69551. * @hidden
  69552. */
  69553. export interface IViewportLike {
  69554. x: float;
  69555. y: float;
  69556. width: float;
  69557. height: float;
  69558. }
  69559. /**
  69560. * @hidden
  69561. */
  69562. export interface IPlaneLike {
  69563. normal: IVector3Like;
  69564. d: float;
  69565. normalize(): void;
  69566. }
  69567. }
  69568. declare module BABYLON {
  69569. /**
  69570. * Interface used to define common properties for effect fallbacks
  69571. */
  69572. export interface IEffectFallbacks {
  69573. /**
  69574. * Removes the defines that should be removed when falling back.
  69575. * @param currentDefines defines the current define statements for the shader.
  69576. * @param effect defines the current effect we try to compile
  69577. * @returns The resulting defines with defines of the current rank removed.
  69578. */
  69579. reduce(currentDefines: string, effect: Effect): string;
  69580. /**
  69581. * Removes the fallback from the bound mesh.
  69582. */
  69583. unBindMesh(): void;
  69584. /**
  69585. * Checks to see if more fallbacks are still availible.
  69586. */
  69587. hasMoreFallbacks: boolean;
  69588. }
  69589. }
  69590. declare module BABYLON {
  69591. /**
  69592. * Class used to evalaute queries containing `and` and `or` operators
  69593. */
  69594. export class AndOrNotEvaluator {
  69595. /**
  69596. * Evaluate a query
  69597. * @param query defines the query to evaluate
  69598. * @param evaluateCallback defines the callback used to filter result
  69599. * @returns true if the query matches
  69600. */
  69601. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69602. private static _HandleParenthesisContent;
  69603. private static _SimplifyNegation;
  69604. }
  69605. }
  69606. declare module BABYLON {
  69607. /**
  69608. * Class used to store custom tags
  69609. */
  69610. export class Tags {
  69611. /**
  69612. * Adds support for tags on the given object
  69613. * @param obj defines the object to use
  69614. */
  69615. static EnableFor(obj: any): void;
  69616. /**
  69617. * Removes tags support
  69618. * @param obj defines the object to use
  69619. */
  69620. static DisableFor(obj: any): void;
  69621. /**
  69622. * Gets a boolean indicating if the given object has tags
  69623. * @param obj defines the object to use
  69624. * @returns a boolean
  69625. */
  69626. static HasTags(obj: any): boolean;
  69627. /**
  69628. * Gets the tags available on a given object
  69629. * @param obj defines the object to use
  69630. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69631. * @returns the tags
  69632. */
  69633. static GetTags(obj: any, asString?: boolean): any;
  69634. /**
  69635. * Adds tags to an object
  69636. * @param obj defines the object to use
  69637. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69638. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69639. */
  69640. static AddTagsTo(obj: any, tagsString: string): void;
  69641. /**
  69642. * @hidden
  69643. */
  69644. static _AddTagTo(obj: any, tag: string): void;
  69645. /**
  69646. * Removes specific tags from a specific object
  69647. * @param obj defines the object to use
  69648. * @param tagsString defines the tags to remove
  69649. */
  69650. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69651. /**
  69652. * @hidden
  69653. */
  69654. static _RemoveTagFrom(obj: any, tag: string): void;
  69655. /**
  69656. * Defines if tags hosted on an object match a given query
  69657. * @param obj defines the object to use
  69658. * @param tagsQuery defines the tag query
  69659. * @returns a boolean
  69660. */
  69661. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69662. }
  69663. }
  69664. declare module BABYLON {
  69665. /**
  69666. * Scalar computation library
  69667. */
  69668. export class Scalar {
  69669. /**
  69670. * Two pi constants convenient for computation.
  69671. */
  69672. static TwoPi: number;
  69673. /**
  69674. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69675. * @param a number
  69676. * @param b number
  69677. * @param epsilon (default = 1.401298E-45)
  69678. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69679. */
  69680. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69681. /**
  69682. * Returns a string : the upper case translation of the number i to hexadecimal.
  69683. * @param i number
  69684. * @returns the upper case translation of the number i to hexadecimal.
  69685. */
  69686. static ToHex(i: number): string;
  69687. /**
  69688. * Returns -1 if value is negative and +1 is value is positive.
  69689. * @param value the value
  69690. * @returns the value itself if it's equal to zero.
  69691. */
  69692. static Sign(value: number): number;
  69693. /**
  69694. * Returns the value itself if it's between min and max.
  69695. * Returns min if the value is lower than min.
  69696. * Returns max if the value is greater than max.
  69697. * @param value the value to clmap
  69698. * @param min the min value to clamp to (default: 0)
  69699. * @param max the max value to clamp to (default: 1)
  69700. * @returns the clamped value
  69701. */
  69702. static Clamp(value: number, min?: number, max?: number): number;
  69703. /**
  69704. * the log2 of value.
  69705. * @param value the value to compute log2 of
  69706. * @returns the log2 of value.
  69707. */
  69708. static Log2(value: number): number;
  69709. /**
  69710. * Loops the value, so that it is never larger than length and never smaller than 0.
  69711. *
  69712. * This is similar to the modulo operator but it works with floating point numbers.
  69713. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69714. * With t = 5 and length = 2.5, the result would be 0.0.
  69715. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69716. * @param value the value
  69717. * @param length the length
  69718. * @returns the looped value
  69719. */
  69720. static Repeat(value: number, length: number): number;
  69721. /**
  69722. * Normalize the value between 0.0 and 1.0 using min and max values
  69723. * @param value value to normalize
  69724. * @param min max to normalize between
  69725. * @param max min to normalize between
  69726. * @returns the normalized value
  69727. */
  69728. static Normalize(value: number, min: number, max: number): number;
  69729. /**
  69730. * Denormalize the value from 0.0 and 1.0 using min and max values
  69731. * @param normalized value to denormalize
  69732. * @param min max to denormalize between
  69733. * @param max min to denormalize between
  69734. * @returns the denormalized value
  69735. */
  69736. static Denormalize(normalized: number, min: number, max: number): number;
  69737. /**
  69738. * Calculates the shortest difference between two given angles given in degrees.
  69739. * @param current current angle in degrees
  69740. * @param target target angle in degrees
  69741. * @returns the delta
  69742. */
  69743. static DeltaAngle(current: number, target: number): number;
  69744. /**
  69745. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69746. * @param tx value
  69747. * @param length length
  69748. * @returns The returned value will move back and forth between 0 and length
  69749. */
  69750. static PingPong(tx: number, length: number): number;
  69751. /**
  69752. * Interpolates between min and max with smoothing at the limits.
  69753. *
  69754. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69755. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69756. * @param from from
  69757. * @param to to
  69758. * @param tx value
  69759. * @returns the smooth stepped value
  69760. */
  69761. static SmoothStep(from: number, to: number, tx: number): number;
  69762. /**
  69763. * Moves a value current towards target.
  69764. *
  69765. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69766. * Negative values of maxDelta pushes the value away from target.
  69767. * @param current current value
  69768. * @param target target value
  69769. * @param maxDelta max distance to move
  69770. * @returns resulting value
  69771. */
  69772. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69773. /**
  69774. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69775. *
  69776. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69777. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69778. * @param current current value
  69779. * @param target target value
  69780. * @param maxDelta max distance to move
  69781. * @returns resulting angle
  69782. */
  69783. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69784. /**
  69785. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69786. * @param start start value
  69787. * @param end target value
  69788. * @param amount amount to lerp between
  69789. * @returns the lerped value
  69790. */
  69791. static Lerp(start: number, end: number, amount: number): number;
  69792. /**
  69793. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69794. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69795. * @param start start value
  69796. * @param end target value
  69797. * @param amount amount to lerp between
  69798. * @returns the lerped value
  69799. */
  69800. static LerpAngle(start: number, end: number, amount: number): number;
  69801. /**
  69802. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69803. * @param a start value
  69804. * @param b target value
  69805. * @param value value between a and b
  69806. * @returns the inverseLerp value
  69807. */
  69808. static InverseLerp(a: number, b: number, value: number): number;
  69809. /**
  69810. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69811. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69812. * @param value1 spline value
  69813. * @param tangent1 spline value
  69814. * @param value2 spline value
  69815. * @param tangent2 spline value
  69816. * @param amount input value
  69817. * @returns hermite result
  69818. */
  69819. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69820. /**
  69821. * Returns a random float number between and min and max values
  69822. * @param min min value of random
  69823. * @param max max value of random
  69824. * @returns random value
  69825. */
  69826. static RandomRange(min: number, max: number): number;
  69827. /**
  69828. * This function returns percentage of a number in a given range.
  69829. *
  69830. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69831. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69832. * @param number to convert to percentage
  69833. * @param min min range
  69834. * @param max max range
  69835. * @returns the percentage
  69836. */
  69837. static RangeToPercent(number: number, min: number, max: number): number;
  69838. /**
  69839. * This function returns number that corresponds to the percentage in a given range.
  69840. *
  69841. * PercentToRange(0.34,0,100) will return 34.
  69842. * @param percent to convert to number
  69843. * @param min min range
  69844. * @param max max range
  69845. * @returns the number
  69846. */
  69847. static PercentToRange(percent: number, min: number, max: number): number;
  69848. /**
  69849. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69850. * @param angle The angle to normalize in radian.
  69851. * @return The converted angle.
  69852. */
  69853. static NormalizeRadians(angle: number): number;
  69854. }
  69855. }
  69856. declare module BABYLON {
  69857. /**
  69858. * Constant used to convert a value to gamma space
  69859. * @ignorenaming
  69860. */
  69861. export const ToGammaSpace: number;
  69862. /**
  69863. * Constant used to convert a value to linear space
  69864. * @ignorenaming
  69865. */
  69866. export const ToLinearSpace = 2.2;
  69867. /**
  69868. * Constant used to define the minimal number value in Babylon.js
  69869. * @ignorenaming
  69870. */
  69871. let Epsilon: number;
  69872. }
  69873. declare module BABYLON {
  69874. /**
  69875. * Class used to represent a viewport on screen
  69876. */
  69877. export class Viewport {
  69878. /** viewport left coordinate */
  69879. x: number;
  69880. /** viewport top coordinate */
  69881. y: number;
  69882. /**viewport width */
  69883. width: number;
  69884. /** viewport height */
  69885. height: number;
  69886. /**
  69887. * Creates a Viewport object located at (x, y) and sized (width, height)
  69888. * @param x defines viewport left coordinate
  69889. * @param y defines viewport top coordinate
  69890. * @param width defines the viewport width
  69891. * @param height defines the viewport height
  69892. */
  69893. constructor(
  69894. /** viewport left coordinate */
  69895. x: number,
  69896. /** viewport top coordinate */
  69897. y: number,
  69898. /**viewport width */
  69899. width: number,
  69900. /** viewport height */
  69901. height: number);
  69902. /**
  69903. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69904. * @param renderWidth defines the rendering width
  69905. * @param renderHeight defines the rendering height
  69906. * @returns a new Viewport
  69907. */
  69908. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69909. /**
  69910. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69911. * @param renderWidth defines the rendering width
  69912. * @param renderHeight defines the rendering height
  69913. * @param ref defines the target viewport
  69914. * @returns the current viewport
  69915. */
  69916. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69917. /**
  69918. * Returns a new Viewport copied from the current one
  69919. * @returns a new Viewport
  69920. */
  69921. clone(): Viewport;
  69922. }
  69923. }
  69924. declare module BABYLON {
  69925. /**
  69926. * Class containing a set of static utilities functions for arrays.
  69927. */
  69928. export class ArrayTools {
  69929. /**
  69930. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69931. * @param size the number of element to construct and put in the array
  69932. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69933. * @returns a new array filled with new objects
  69934. */
  69935. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69936. }
  69937. }
  69938. declare module BABYLON {
  69939. /**
  69940. * Class representing a vector containing 2 coordinates
  69941. */
  69942. export class Vector2 {
  69943. /** defines the first coordinate */
  69944. x: number;
  69945. /** defines the second coordinate */
  69946. y: number;
  69947. /**
  69948. * Creates a new Vector2 from the given x and y coordinates
  69949. * @param x defines the first coordinate
  69950. * @param y defines the second coordinate
  69951. */
  69952. constructor(
  69953. /** defines the first coordinate */
  69954. x?: number,
  69955. /** defines the second coordinate */
  69956. y?: number);
  69957. /**
  69958. * Gets a string with the Vector2 coordinates
  69959. * @returns a string with the Vector2 coordinates
  69960. */
  69961. toString(): string;
  69962. /**
  69963. * Gets class name
  69964. * @returns the string "Vector2"
  69965. */
  69966. getClassName(): string;
  69967. /**
  69968. * Gets current vector hash code
  69969. * @returns the Vector2 hash code as a number
  69970. */
  69971. getHashCode(): number;
  69972. /**
  69973. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69974. * @param array defines the source array
  69975. * @param index defines the offset in source array
  69976. * @returns the current Vector2
  69977. */
  69978. toArray(array: FloatArray, index?: number): Vector2;
  69979. /**
  69980. * Copy the current vector to an array
  69981. * @returns a new array with 2 elements: the Vector2 coordinates.
  69982. */
  69983. asArray(): number[];
  69984. /**
  69985. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69986. * @param source defines the source Vector2
  69987. * @returns the current updated Vector2
  69988. */
  69989. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69990. /**
  69991. * Sets the Vector2 coordinates with the given floats
  69992. * @param x defines the first coordinate
  69993. * @param y defines the second coordinate
  69994. * @returns the current updated Vector2
  69995. */
  69996. copyFromFloats(x: number, y: number): Vector2;
  69997. /**
  69998. * Sets the Vector2 coordinates with the given floats
  69999. * @param x defines the first coordinate
  70000. * @param y defines the second coordinate
  70001. * @returns the current updated Vector2
  70002. */
  70003. set(x: number, y: number): Vector2;
  70004. /**
  70005. * Add another vector with the current one
  70006. * @param otherVector defines the other vector
  70007. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70008. */
  70009. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70010. /**
  70011. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70012. * @param otherVector defines the other vector
  70013. * @param result defines the target vector
  70014. * @returns the unmodified current Vector2
  70015. */
  70016. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70017. /**
  70018. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70019. * @param otherVector defines the other vector
  70020. * @returns the current updated Vector2
  70021. */
  70022. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70023. /**
  70024. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70025. * @param otherVector defines the other vector
  70026. * @returns a new Vector2
  70027. */
  70028. addVector3(otherVector: Vector3): Vector2;
  70029. /**
  70030. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70031. * @param otherVector defines the other vector
  70032. * @returns a new Vector2
  70033. */
  70034. subtract(otherVector: Vector2): Vector2;
  70035. /**
  70036. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70037. * @param otherVector defines the other vector
  70038. * @param result defines the target vector
  70039. * @returns the unmodified current Vector2
  70040. */
  70041. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70042. /**
  70043. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70044. * @param otherVector defines the other vector
  70045. * @returns the current updated Vector2
  70046. */
  70047. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70048. /**
  70049. * Multiplies in place the current Vector2 coordinates by the given ones
  70050. * @param otherVector defines the other vector
  70051. * @returns the current updated Vector2
  70052. */
  70053. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70054. /**
  70055. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70056. * @param otherVector defines the other vector
  70057. * @returns a new Vector2
  70058. */
  70059. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70060. /**
  70061. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70062. * @param otherVector defines the other vector
  70063. * @param result defines the target vector
  70064. * @returns the unmodified current Vector2
  70065. */
  70066. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70067. /**
  70068. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70069. * @param x defines the first coordinate
  70070. * @param y defines the second coordinate
  70071. * @returns a new Vector2
  70072. */
  70073. multiplyByFloats(x: number, y: number): Vector2;
  70074. /**
  70075. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70076. * @param otherVector defines the other vector
  70077. * @returns a new Vector2
  70078. */
  70079. divide(otherVector: Vector2): Vector2;
  70080. /**
  70081. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70082. * @param otherVector defines the other vector
  70083. * @param result defines the target vector
  70084. * @returns the unmodified current Vector2
  70085. */
  70086. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70087. /**
  70088. * Divides the current Vector2 coordinates by the given ones
  70089. * @param otherVector defines the other vector
  70090. * @returns the current updated Vector2
  70091. */
  70092. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70093. /**
  70094. * Gets a new Vector2 with current Vector2 negated coordinates
  70095. * @returns a new Vector2
  70096. */
  70097. negate(): Vector2;
  70098. /**
  70099. * Multiply the Vector2 coordinates by scale
  70100. * @param scale defines the scaling factor
  70101. * @returns the current updated Vector2
  70102. */
  70103. scaleInPlace(scale: number): Vector2;
  70104. /**
  70105. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70106. * @param scale defines the scaling factor
  70107. * @returns a new Vector2
  70108. */
  70109. scale(scale: number): Vector2;
  70110. /**
  70111. * Scale the current Vector2 values by a factor to a given Vector2
  70112. * @param scale defines the scale factor
  70113. * @param result defines the Vector2 object where to store the result
  70114. * @returns the unmodified current Vector2
  70115. */
  70116. scaleToRef(scale: number, result: Vector2): Vector2;
  70117. /**
  70118. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70119. * @param scale defines the scale factor
  70120. * @param result defines the Vector2 object where to store the result
  70121. * @returns the unmodified current Vector2
  70122. */
  70123. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70124. /**
  70125. * Gets a boolean if two vectors are equals
  70126. * @param otherVector defines the other vector
  70127. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70128. */
  70129. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70130. /**
  70131. * Gets a boolean if two vectors are equals (using an epsilon value)
  70132. * @param otherVector defines the other vector
  70133. * @param epsilon defines the minimal distance to consider equality
  70134. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70135. */
  70136. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70137. /**
  70138. * Gets a new Vector2 from current Vector2 floored values
  70139. * @returns a new Vector2
  70140. */
  70141. floor(): Vector2;
  70142. /**
  70143. * Gets a new Vector2 from current Vector2 floored values
  70144. * @returns a new Vector2
  70145. */
  70146. fract(): Vector2;
  70147. /**
  70148. * Gets the length of the vector
  70149. * @returns the vector length (float)
  70150. */
  70151. length(): number;
  70152. /**
  70153. * Gets the vector squared length
  70154. * @returns the vector squared length (float)
  70155. */
  70156. lengthSquared(): number;
  70157. /**
  70158. * Normalize the vector
  70159. * @returns the current updated Vector2
  70160. */
  70161. normalize(): Vector2;
  70162. /**
  70163. * Gets a new Vector2 copied from the Vector2
  70164. * @returns a new Vector2
  70165. */
  70166. clone(): Vector2;
  70167. /**
  70168. * Gets a new Vector2(0, 0)
  70169. * @returns a new Vector2
  70170. */
  70171. static Zero(): Vector2;
  70172. /**
  70173. * Gets a new Vector2(1, 1)
  70174. * @returns a new Vector2
  70175. */
  70176. static One(): Vector2;
  70177. /**
  70178. * Gets a new Vector2 set from the given index element of the given array
  70179. * @param array defines the data source
  70180. * @param offset defines the offset in the data source
  70181. * @returns a new Vector2
  70182. */
  70183. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70184. /**
  70185. * Sets "result" from the given index element of the given array
  70186. * @param array defines the data source
  70187. * @param offset defines the offset in the data source
  70188. * @param result defines the target vector
  70189. */
  70190. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70191. /**
  70192. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70193. * @param value1 defines 1st point of control
  70194. * @param value2 defines 2nd point of control
  70195. * @param value3 defines 3rd point of control
  70196. * @param value4 defines 4th point of control
  70197. * @param amount defines the interpolation factor
  70198. * @returns a new Vector2
  70199. */
  70200. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70201. /**
  70202. * 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".
  70203. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70204. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70205. * @param value defines the value to clamp
  70206. * @param min defines the lower limit
  70207. * @param max defines the upper limit
  70208. * @returns a new Vector2
  70209. */
  70210. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70211. /**
  70212. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70213. * @param value1 defines the 1st control point
  70214. * @param tangent1 defines the outgoing tangent
  70215. * @param value2 defines the 2nd control point
  70216. * @param tangent2 defines the incoming tangent
  70217. * @param amount defines the interpolation factor
  70218. * @returns a new Vector2
  70219. */
  70220. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70221. /**
  70222. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70223. * @param start defines the start vector
  70224. * @param end defines the end vector
  70225. * @param amount defines the interpolation factor
  70226. * @returns a new Vector2
  70227. */
  70228. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70229. /**
  70230. * Gets the dot product of the vector "left" and the vector "right"
  70231. * @param left defines first vector
  70232. * @param right defines second vector
  70233. * @returns the dot product (float)
  70234. */
  70235. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70236. /**
  70237. * Returns a new Vector2 equal to the normalized given vector
  70238. * @param vector defines the vector to normalize
  70239. * @returns a new Vector2
  70240. */
  70241. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70242. /**
  70243. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70244. * @param left defines 1st vector
  70245. * @param right defines 2nd vector
  70246. * @returns a new Vector2
  70247. */
  70248. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70249. /**
  70250. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70251. * @param left defines 1st vector
  70252. * @param right defines 2nd vector
  70253. * @returns a new Vector2
  70254. */
  70255. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70256. /**
  70257. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70258. * @param vector defines the vector to transform
  70259. * @param transformation defines the matrix to apply
  70260. * @returns a new Vector2
  70261. */
  70262. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70263. /**
  70264. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70265. * @param vector defines the vector to transform
  70266. * @param transformation defines the matrix to apply
  70267. * @param result defines the target vector
  70268. */
  70269. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70270. /**
  70271. * Determines if a given vector is included in a triangle
  70272. * @param p defines the vector to test
  70273. * @param p0 defines 1st triangle point
  70274. * @param p1 defines 2nd triangle point
  70275. * @param p2 defines 3rd triangle point
  70276. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70277. */
  70278. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70279. /**
  70280. * Gets the distance between the vectors "value1" and "value2"
  70281. * @param value1 defines first vector
  70282. * @param value2 defines second vector
  70283. * @returns the distance between vectors
  70284. */
  70285. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70286. /**
  70287. * Returns the squared distance between the vectors "value1" and "value2"
  70288. * @param value1 defines first vector
  70289. * @param value2 defines second vector
  70290. * @returns the squared distance between vectors
  70291. */
  70292. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70293. /**
  70294. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70295. * @param value1 defines first vector
  70296. * @param value2 defines second vector
  70297. * @returns a new Vector2
  70298. */
  70299. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70300. /**
  70301. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70302. * @param p defines the middle point
  70303. * @param segA defines one point of the segment
  70304. * @param segB defines the other point of the segment
  70305. * @returns the shortest distance
  70306. */
  70307. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70308. }
  70309. /**
  70310. * Classed used to store (x,y,z) vector representation
  70311. * A Vector3 is the main object used in 3D geometry
  70312. * It can represent etiher the coordinates of a point the space, either a direction
  70313. * Reminder: js uses a left handed forward facing system
  70314. */
  70315. export class Vector3 {
  70316. /**
  70317. * Defines the first coordinates (on X axis)
  70318. */
  70319. x: number;
  70320. /**
  70321. * Defines the second coordinates (on Y axis)
  70322. */
  70323. y: number;
  70324. /**
  70325. * Defines the third coordinates (on Z axis)
  70326. */
  70327. z: number;
  70328. private static _UpReadOnly;
  70329. private static _ZeroReadOnly;
  70330. /**
  70331. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70332. * @param x defines the first coordinates (on X axis)
  70333. * @param y defines the second coordinates (on Y axis)
  70334. * @param z defines the third coordinates (on Z axis)
  70335. */
  70336. constructor(
  70337. /**
  70338. * Defines the first coordinates (on X axis)
  70339. */
  70340. x?: number,
  70341. /**
  70342. * Defines the second coordinates (on Y axis)
  70343. */
  70344. y?: number,
  70345. /**
  70346. * Defines the third coordinates (on Z axis)
  70347. */
  70348. z?: number);
  70349. /**
  70350. * Creates a string representation of the Vector3
  70351. * @returns a string with the Vector3 coordinates.
  70352. */
  70353. toString(): string;
  70354. /**
  70355. * Gets the class name
  70356. * @returns the string "Vector3"
  70357. */
  70358. getClassName(): string;
  70359. /**
  70360. * Creates the Vector3 hash code
  70361. * @returns a number which tends to be unique between Vector3 instances
  70362. */
  70363. getHashCode(): number;
  70364. /**
  70365. * Creates an array containing three elements : the coordinates of the Vector3
  70366. * @returns a new array of numbers
  70367. */
  70368. asArray(): number[];
  70369. /**
  70370. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70371. * @param array defines the destination array
  70372. * @param index defines the offset in the destination array
  70373. * @returns the current Vector3
  70374. */
  70375. toArray(array: FloatArray, index?: number): Vector3;
  70376. /**
  70377. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70378. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70379. */
  70380. toQuaternion(): Quaternion;
  70381. /**
  70382. * Adds the given vector to the current Vector3
  70383. * @param otherVector defines the second operand
  70384. * @returns the current updated Vector3
  70385. */
  70386. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70387. /**
  70388. * Adds the given coordinates to the current Vector3
  70389. * @param x defines the x coordinate of the operand
  70390. * @param y defines the y coordinate of the operand
  70391. * @param z defines the z coordinate of the operand
  70392. * @returns the current updated Vector3
  70393. */
  70394. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70395. /**
  70396. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70397. * @param otherVector defines the second operand
  70398. * @returns the resulting Vector3
  70399. */
  70400. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70401. /**
  70402. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70403. * @param otherVector defines the second operand
  70404. * @param result defines the Vector3 object where to store the result
  70405. * @returns the current Vector3
  70406. */
  70407. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70408. /**
  70409. * Subtract the given vector from the current Vector3
  70410. * @param otherVector defines the second operand
  70411. * @returns the current updated Vector3
  70412. */
  70413. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70414. /**
  70415. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70416. * @param otherVector defines the second operand
  70417. * @returns the resulting Vector3
  70418. */
  70419. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70420. /**
  70421. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70422. * @param otherVector defines the second operand
  70423. * @param result defines the Vector3 object where to store the result
  70424. * @returns the current Vector3
  70425. */
  70426. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70427. /**
  70428. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70429. * @param x defines the x coordinate of the operand
  70430. * @param y defines the y coordinate of the operand
  70431. * @param z defines the z coordinate of the operand
  70432. * @returns the resulting Vector3
  70433. */
  70434. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70435. /**
  70436. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70437. * @param x defines the x coordinate of the operand
  70438. * @param y defines the y coordinate of the operand
  70439. * @param z defines the z coordinate of the operand
  70440. * @param result defines the Vector3 object where to store the result
  70441. * @returns the current Vector3
  70442. */
  70443. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70444. /**
  70445. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70446. * @returns a new Vector3
  70447. */
  70448. negate(): Vector3;
  70449. /**
  70450. * Multiplies the Vector3 coordinates by the float "scale"
  70451. * @param scale defines the multiplier factor
  70452. * @returns the current updated Vector3
  70453. */
  70454. scaleInPlace(scale: number): Vector3;
  70455. /**
  70456. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70457. * @param scale defines the multiplier factor
  70458. * @returns a new Vector3
  70459. */
  70460. scale(scale: number): Vector3;
  70461. /**
  70462. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70463. * @param scale defines the multiplier factor
  70464. * @param result defines the Vector3 object where to store the result
  70465. * @returns the current Vector3
  70466. */
  70467. scaleToRef(scale: number, result: Vector3): Vector3;
  70468. /**
  70469. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70470. * @param scale defines the scale factor
  70471. * @param result defines the Vector3 object where to store the result
  70472. * @returns the unmodified current Vector3
  70473. */
  70474. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70475. /**
  70476. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70477. * @param otherVector defines the second operand
  70478. * @returns true if both vectors are equals
  70479. */
  70480. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70481. /**
  70482. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70483. * @param otherVector defines the second operand
  70484. * @param epsilon defines the minimal distance to define values as equals
  70485. * @returns true if both vectors are distant less than epsilon
  70486. */
  70487. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70488. /**
  70489. * Returns true if the current Vector3 coordinates equals the given floats
  70490. * @param x defines the x coordinate of the operand
  70491. * @param y defines the y coordinate of the operand
  70492. * @param z defines the z coordinate of the operand
  70493. * @returns true if both vectors are equals
  70494. */
  70495. equalsToFloats(x: number, y: number, z: number): boolean;
  70496. /**
  70497. * Multiplies the current Vector3 coordinates by the given ones
  70498. * @param otherVector defines the second operand
  70499. * @returns the current updated Vector3
  70500. */
  70501. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70502. /**
  70503. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70504. * @param otherVector defines the second operand
  70505. * @returns the new Vector3
  70506. */
  70507. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70508. /**
  70509. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70510. * @param otherVector defines the second operand
  70511. * @param result defines the Vector3 object where to store the result
  70512. * @returns the current Vector3
  70513. */
  70514. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70515. /**
  70516. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70517. * @param x defines the x coordinate of the operand
  70518. * @param y defines the y coordinate of the operand
  70519. * @param z defines the z coordinate of the operand
  70520. * @returns the new Vector3
  70521. */
  70522. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70523. /**
  70524. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70525. * @param otherVector defines the second operand
  70526. * @returns the new Vector3
  70527. */
  70528. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70529. /**
  70530. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70531. * @param otherVector defines the second operand
  70532. * @param result defines the Vector3 object where to store the result
  70533. * @returns the current Vector3
  70534. */
  70535. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70536. /**
  70537. * Divides the current Vector3 coordinates by the given ones.
  70538. * @param otherVector defines the second operand
  70539. * @returns the current updated Vector3
  70540. */
  70541. divideInPlace(otherVector: Vector3): Vector3;
  70542. /**
  70543. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70544. * @param other defines the second operand
  70545. * @returns the current updated Vector3
  70546. */
  70547. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70548. /**
  70549. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70550. * @param other defines the second operand
  70551. * @returns the current updated Vector3
  70552. */
  70553. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70554. /**
  70555. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70556. * @param x defines the x coordinate of the operand
  70557. * @param y defines the y coordinate of the operand
  70558. * @param z defines the z coordinate of the operand
  70559. * @returns the current updated Vector3
  70560. */
  70561. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70562. /**
  70563. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70564. * @param x defines the x coordinate of the operand
  70565. * @param y defines the y coordinate of the operand
  70566. * @param z defines the z coordinate of the operand
  70567. * @returns the current updated Vector3
  70568. */
  70569. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70570. /**
  70571. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70572. * Check if is non uniform within a certain amount of decimal places to account for this
  70573. * @param epsilon the amount the values can differ
  70574. * @returns if the the vector is non uniform to a certain number of decimal places
  70575. */
  70576. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70577. /**
  70578. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70579. */
  70580. readonly isNonUniform: boolean;
  70581. /**
  70582. * Gets a new Vector3 from current Vector3 floored values
  70583. * @returns a new Vector3
  70584. */
  70585. floor(): Vector3;
  70586. /**
  70587. * Gets a new Vector3 from current Vector3 floored values
  70588. * @returns a new Vector3
  70589. */
  70590. fract(): Vector3;
  70591. /**
  70592. * Gets the length of the Vector3
  70593. * @returns the length of the Vector3
  70594. */
  70595. length(): number;
  70596. /**
  70597. * Gets the squared length of the Vector3
  70598. * @returns squared length of the Vector3
  70599. */
  70600. lengthSquared(): number;
  70601. /**
  70602. * Normalize the current Vector3.
  70603. * Please note that this is an in place operation.
  70604. * @returns the current updated Vector3
  70605. */
  70606. normalize(): Vector3;
  70607. /**
  70608. * Reorders the x y z properties of the vector in place
  70609. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70610. * @returns the current updated vector
  70611. */
  70612. reorderInPlace(order: string): this;
  70613. /**
  70614. * Rotates the vector around 0,0,0 by a quaternion
  70615. * @param quaternion the rotation quaternion
  70616. * @param result vector to store the result
  70617. * @returns the resulting vector
  70618. */
  70619. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70620. /**
  70621. * Rotates a vector around a given point
  70622. * @param quaternion the rotation quaternion
  70623. * @param point the point to rotate around
  70624. * @param result vector to store the result
  70625. * @returns the resulting vector
  70626. */
  70627. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70628. /**
  70629. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70630. * The cross product is then orthogonal to both current and "other"
  70631. * @param other defines the right operand
  70632. * @returns the cross product
  70633. */
  70634. cross(other: Vector3): Vector3;
  70635. /**
  70636. * Normalize the current Vector3 with the given input length.
  70637. * Please note that this is an in place operation.
  70638. * @param len the length of the vector
  70639. * @returns the current updated Vector3
  70640. */
  70641. normalizeFromLength(len: number): Vector3;
  70642. /**
  70643. * Normalize the current Vector3 to a new vector
  70644. * @returns the new Vector3
  70645. */
  70646. normalizeToNew(): Vector3;
  70647. /**
  70648. * Normalize the current Vector3 to the reference
  70649. * @param reference define the Vector3 to update
  70650. * @returns the updated Vector3
  70651. */
  70652. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70653. /**
  70654. * Creates a new Vector3 copied from the current Vector3
  70655. * @returns the new Vector3
  70656. */
  70657. clone(): Vector3;
  70658. /**
  70659. * Copies the given vector coordinates to the current Vector3 ones
  70660. * @param source defines the source Vector3
  70661. * @returns the current updated Vector3
  70662. */
  70663. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70664. /**
  70665. * Copies the given floats to the current Vector3 coordinates
  70666. * @param x defines the x coordinate of the operand
  70667. * @param y defines the y coordinate of the operand
  70668. * @param z defines the z coordinate of the operand
  70669. * @returns the current updated Vector3
  70670. */
  70671. copyFromFloats(x: number, y: number, z: number): Vector3;
  70672. /**
  70673. * Copies the given floats to the current Vector3 coordinates
  70674. * @param x defines the x coordinate of the operand
  70675. * @param y defines the y coordinate of the operand
  70676. * @param z defines the z coordinate of the operand
  70677. * @returns the current updated Vector3
  70678. */
  70679. set(x: number, y: number, z: number): Vector3;
  70680. /**
  70681. * Copies the given float to the current Vector3 coordinates
  70682. * @param v defines the x, y and z coordinates of the operand
  70683. * @returns the current updated Vector3
  70684. */
  70685. setAll(v: number): Vector3;
  70686. /**
  70687. * Get the clip factor between two vectors
  70688. * @param vector0 defines the first operand
  70689. * @param vector1 defines the second operand
  70690. * @param axis defines the axis to use
  70691. * @param size defines the size along the axis
  70692. * @returns the clip factor
  70693. */
  70694. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70695. /**
  70696. * Get angle between two vectors
  70697. * @param vector0 angle between vector0 and vector1
  70698. * @param vector1 angle between vector0 and vector1
  70699. * @param normal direction of the normal
  70700. * @return the angle between vector0 and vector1
  70701. */
  70702. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70703. /**
  70704. * Returns a new Vector3 set from the index "offset" of the given array
  70705. * @param array defines the source array
  70706. * @param offset defines the offset in the source array
  70707. * @returns the new Vector3
  70708. */
  70709. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70710. /**
  70711. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70712. * This function is deprecated. Use FromArray instead
  70713. * @param array defines the source array
  70714. * @param offset defines the offset in the source array
  70715. * @returns the new Vector3
  70716. */
  70717. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70718. /**
  70719. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70720. * @param array defines the source array
  70721. * @param offset defines the offset in the source array
  70722. * @param result defines the Vector3 where to store the result
  70723. */
  70724. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70725. /**
  70726. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70727. * This function is deprecated. Use FromArrayToRef instead.
  70728. * @param array defines the source array
  70729. * @param offset defines the offset in the source array
  70730. * @param result defines the Vector3 where to store the result
  70731. */
  70732. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70733. /**
  70734. * Sets the given vector "result" with the given floats.
  70735. * @param x defines the x coordinate of the source
  70736. * @param y defines the y coordinate of the source
  70737. * @param z defines the z coordinate of the source
  70738. * @param result defines the Vector3 where to store the result
  70739. */
  70740. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70741. /**
  70742. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70743. * @returns a new empty Vector3
  70744. */
  70745. static Zero(): Vector3;
  70746. /**
  70747. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70748. * @returns a new unit Vector3
  70749. */
  70750. static One(): Vector3;
  70751. /**
  70752. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70753. * @returns a new up Vector3
  70754. */
  70755. static Up(): Vector3;
  70756. /**
  70757. * Gets a up Vector3 that must not be updated
  70758. */
  70759. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70760. /**
  70761. * Gets a zero Vector3 that must not be updated
  70762. */
  70763. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70764. /**
  70765. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70766. * @returns a new down Vector3
  70767. */
  70768. static Down(): Vector3;
  70769. /**
  70770. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70771. * @returns a new forward Vector3
  70772. */
  70773. static Forward(): Vector3;
  70774. /**
  70775. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70776. * @returns a new forward Vector3
  70777. */
  70778. static Backward(): Vector3;
  70779. /**
  70780. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70781. * @returns a new right Vector3
  70782. */
  70783. static Right(): Vector3;
  70784. /**
  70785. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70786. * @returns a new left Vector3
  70787. */
  70788. static Left(): Vector3;
  70789. /**
  70790. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70791. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70792. * @param vector defines the Vector3 to transform
  70793. * @param transformation defines the transformation matrix
  70794. * @returns the transformed Vector3
  70795. */
  70796. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70797. /**
  70798. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70799. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70800. * @param vector defines the Vector3 to transform
  70801. * @param transformation defines the transformation matrix
  70802. * @param result defines the Vector3 where to store the result
  70803. */
  70804. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70805. /**
  70806. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70807. * This method computes tranformed coordinates only, not transformed direction vectors
  70808. * @param x define the x coordinate of the source vector
  70809. * @param y define the y coordinate of the source vector
  70810. * @param z define the z coordinate of the source vector
  70811. * @param transformation defines the transformation matrix
  70812. * @param result defines the Vector3 where to store the result
  70813. */
  70814. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70815. /**
  70816. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70817. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70818. * @param vector defines the Vector3 to transform
  70819. * @param transformation defines the transformation matrix
  70820. * @returns the new Vector3
  70821. */
  70822. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70823. /**
  70824. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70825. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70826. * @param vector defines the Vector3 to transform
  70827. * @param transformation defines the transformation matrix
  70828. * @param result defines the Vector3 where to store the result
  70829. */
  70830. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70831. /**
  70832. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70833. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70834. * @param x define the x coordinate of the source vector
  70835. * @param y define the y coordinate of the source vector
  70836. * @param z define the z coordinate of the source vector
  70837. * @param transformation defines the transformation matrix
  70838. * @param result defines the Vector3 where to store the result
  70839. */
  70840. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70841. /**
  70842. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70843. * @param value1 defines the first control point
  70844. * @param value2 defines the second control point
  70845. * @param value3 defines the third control point
  70846. * @param value4 defines the fourth control point
  70847. * @param amount defines the amount on the spline to use
  70848. * @returns the new Vector3
  70849. */
  70850. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70851. /**
  70852. * 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"
  70853. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70854. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70855. * @param value defines the current value
  70856. * @param min defines the lower range value
  70857. * @param max defines the upper range value
  70858. * @returns the new Vector3
  70859. */
  70860. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70861. /**
  70862. * 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"
  70863. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70864. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70865. * @param value defines the current value
  70866. * @param min defines the lower range value
  70867. * @param max defines the upper range value
  70868. * @param result defines the Vector3 where to store the result
  70869. */
  70870. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70871. /**
  70872. * Checks if a given vector is inside a specific range
  70873. * @param v defines the vector to test
  70874. * @param min defines the minimum range
  70875. * @param max defines the maximum range
  70876. */
  70877. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70878. /**
  70879. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70880. * @param value1 defines the first control point
  70881. * @param tangent1 defines the first tangent vector
  70882. * @param value2 defines the second control point
  70883. * @param tangent2 defines the second tangent vector
  70884. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70885. * @returns the new Vector3
  70886. */
  70887. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70888. /**
  70889. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70890. * @param start defines the start value
  70891. * @param end defines the end value
  70892. * @param amount max defines amount between both (between 0 and 1)
  70893. * @returns the new Vector3
  70894. */
  70895. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70896. /**
  70897. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70898. * @param start defines the start value
  70899. * @param end defines the end value
  70900. * @param amount max defines amount between both (between 0 and 1)
  70901. * @param result defines the Vector3 where to store the result
  70902. */
  70903. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70904. /**
  70905. * Returns the dot product (float) between the vectors "left" and "right"
  70906. * @param left defines the left operand
  70907. * @param right defines the right operand
  70908. * @returns the dot product
  70909. */
  70910. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70911. /**
  70912. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70913. * The cross product is then orthogonal to both "left" and "right"
  70914. * @param left defines the left operand
  70915. * @param right defines the right operand
  70916. * @returns the cross product
  70917. */
  70918. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70919. /**
  70920. * Sets the given vector "result" with the cross product of "left" and "right"
  70921. * The cross product is then orthogonal to both "left" and "right"
  70922. * @param left defines the left operand
  70923. * @param right defines the right operand
  70924. * @param result defines the Vector3 where to store the result
  70925. */
  70926. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70927. /**
  70928. * Returns a new Vector3 as the normalization of the given vector
  70929. * @param vector defines the Vector3 to normalize
  70930. * @returns the new Vector3
  70931. */
  70932. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70933. /**
  70934. * Sets the given vector "result" with the normalization of the given first vector
  70935. * @param vector defines the Vector3 to normalize
  70936. * @param result defines the Vector3 where to store the result
  70937. */
  70938. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70939. /**
  70940. * Project a Vector3 onto screen space
  70941. * @param vector defines the Vector3 to project
  70942. * @param world defines the world matrix to use
  70943. * @param transform defines the transform (view x projection) matrix to use
  70944. * @param viewport defines the screen viewport to use
  70945. * @returns the new Vector3
  70946. */
  70947. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70948. /** @hidden */
  70949. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70950. /**
  70951. * Unproject from screen space to object space
  70952. * @param source defines the screen space Vector3 to use
  70953. * @param viewportWidth defines the current width of the viewport
  70954. * @param viewportHeight defines the current height of the viewport
  70955. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70956. * @param transform defines the transform (view x projection) matrix to use
  70957. * @returns the new Vector3
  70958. */
  70959. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70960. /**
  70961. * Unproject from screen space to object space
  70962. * @param source defines the screen space Vector3 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. * @returns the new Vector3
  70969. */
  70970. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70971. /**
  70972. * Unproject from screen space to object space
  70973. * @param source defines the screen space Vector3 to use
  70974. * @param viewportWidth defines the current width of the viewport
  70975. * @param viewportHeight defines the current height of the viewport
  70976. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70977. * @param view defines the view matrix to use
  70978. * @param projection defines the projection matrix to use
  70979. * @param result defines the Vector3 where to store the result
  70980. */
  70981. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70982. /**
  70983. * Unproject from screen space to object space
  70984. * @param sourceX defines the screen space x coordinate to use
  70985. * @param sourceY defines the screen space y coordinate to use
  70986. * @param sourceZ defines the screen space z coordinate to use
  70987. * @param viewportWidth defines the current width of the viewport
  70988. * @param viewportHeight defines the current height of the viewport
  70989. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70990. * @param view defines the view matrix to use
  70991. * @param projection defines the projection matrix to use
  70992. * @param result defines the Vector3 where to store the result
  70993. */
  70994. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70995. /**
  70996. * Gets the minimal coordinate values between two Vector3
  70997. * @param left defines the first operand
  70998. * @param right defines the second operand
  70999. * @returns the new Vector3
  71000. */
  71001. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71002. /**
  71003. * Gets the maximal coordinate values between two Vector3
  71004. * @param left defines the first operand
  71005. * @param right defines the second operand
  71006. * @returns the new Vector3
  71007. */
  71008. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71009. /**
  71010. * Returns the distance between the vectors "value1" and "value2"
  71011. * @param value1 defines the first operand
  71012. * @param value2 defines the second operand
  71013. * @returns the distance
  71014. */
  71015. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71016. /**
  71017. * Returns the squared distance between the vectors "value1" and "value2"
  71018. * @param value1 defines the first operand
  71019. * @param value2 defines the second operand
  71020. * @returns the squared distance
  71021. */
  71022. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71023. /**
  71024. * Returns a new Vector3 located at the center between "value1" and "value2"
  71025. * @param value1 defines the first operand
  71026. * @param value2 defines the second operand
  71027. * @returns the new Vector3
  71028. */
  71029. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71030. /**
  71031. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71032. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71033. * to something in order to rotate it from its local system to the given target system
  71034. * Note: axis1, axis2 and axis3 are normalized during this operation
  71035. * @param axis1 defines the first axis
  71036. * @param axis2 defines the second axis
  71037. * @param axis3 defines the third axis
  71038. * @returns a new Vector3
  71039. */
  71040. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71041. /**
  71042. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71043. * @param axis1 defines the first axis
  71044. * @param axis2 defines the second axis
  71045. * @param axis3 defines the third axis
  71046. * @param ref defines the Vector3 where to store the result
  71047. */
  71048. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71049. }
  71050. /**
  71051. * Vector4 class created for EulerAngle class conversion to Quaternion
  71052. */
  71053. export class Vector4 {
  71054. /** x value of the vector */
  71055. x: number;
  71056. /** y value of the vector */
  71057. y: number;
  71058. /** z value of the vector */
  71059. z: number;
  71060. /** w value of the vector */
  71061. w: number;
  71062. /**
  71063. * Creates a Vector4 object from the given floats.
  71064. * @param x x value of the vector
  71065. * @param y y value of the vector
  71066. * @param z z value of the vector
  71067. * @param w w value of the vector
  71068. */
  71069. constructor(
  71070. /** x value of the vector */
  71071. x: number,
  71072. /** y value of the vector */
  71073. y: number,
  71074. /** z value of the vector */
  71075. z: number,
  71076. /** w value of the vector */
  71077. w: number);
  71078. /**
  71079. * Returns the string with the Vector4 coordinates.
  71080. * @returns a string containing all the vector values
  71081. */
  71082. toString(): string;
  71083. /**
  71084. * Returns the string "Vector4".
  71085. * @returns "Vector4"
  71086. */
  71087. getClassName(): string;
  71088. /**
  71089. * Returns the Vector4 hash code.
  71090. * @returns a unique hash code
  71091. */
  71092. getHashCode(): number;
  71093. /**
  71094. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71095. * @returns the resulting array
  71096. */
  71097. asArray(): number[];
  71098. /**
  71099. * Populates the given array from the given index with the Vector4 coordinates.
  71100. * @param array array to populate
  71101. * @param index index of the array to start at (default: 0)
  71102. * @returns the Vector4.
  71103. */
  71104. toArray(array: FloatArray, index?: number): Vector4;
  71105. /**
  71106. * Adds the given vector to the current Vector4.
  71107. * @param otherVector the vector to add
  71108. * @returns the updated Vector4.
  71109. */
  71110. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71111. /**
  71112. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71113. * @param otherVector the vector to add
  71114. * @returns the resulting vector
  71115. */
  71116. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71117. /**
  71118. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71119. * @param otherVector the vector to add
  71120. * @param result the vector to store the result
  71121. * @returns the current Vector4.
  71122. */
  71123. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71124. /**
  71125. * Subtract in place the given vector from the current Vector4.
  71126. * @param otherVector the vector to subtract
  71127. * @returns the updated Vector4.
  71128. */
  71129. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71130. /**
  71131. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71132. * @param otherVector the vector to add
  71133. * @returns the new vector with the result
  71134. */
  71135. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71136. /**
  71137. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71138. * @param otherVector the vector to subtract
  71139. * @param result the vector to store the result
  71140. * @returns the current Vector4.
  71141. */
  71142. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71143. /**
  71144. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71145. */
  71146. /**
  71147. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71148. * @param x value to subtract
  71149. * @param y value to subtract
  71150. * @param z value to subtract
  71151. * @param w value to subtract
  71152. * @returns new vector containing the result
  71153. */
  71154. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71155. /**
  71156. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71157. * @param x value to subtract
  71158. * @param y value to subtract
  71159. * @param z value to subtract
  71160. * @param w value to subtract
  71161. * @param result the vector to store the result in
  71162. * @returns the current Vector4.
  71163. */
  71164. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71165. /**
  71166. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71167. * @returns a new vector with the negated values
  71168. */
  71169. negate(): Vector4;
  71170. /**
  71171. * Multiplies the current Vector4 coordinates by scale (float).
  71172. * @param scale the number to scale with
  71173. * @returns the updated Vector4.
  71174. */
  71175. scaleInPlace(scale: number): Vector4;
  71176. /**
  71177. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71178. * @param scale the number to scale with
  71179. * @returns a new vector with the result
  71180. */
  71181. scale(scale: number): Vector4;
  71182. /**
  71183. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71184. * @param scale the number to scale with
  71185. * @param result a vector to store the result in
  71186. * @returns the current Vector4.
  71187. */
  71188. scaleToRef(scale: number, result: Vector4): Vector4;
  71189. /**
  71190. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71191. * @param scale defines the scale factor
  71192. * @param result defines the Vector4 object where to store the result
  71193. * @returns the unmodified current Vector4
  71194. */
  71195. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71196. /**
  71197. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71198. * @param otherVector the vector to compare against
  71199. * @returns true if they are equal
  71200. */
  71201. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71202. /**
  71203. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71204. * @param otherVector vector to compare against
  71205. * @param epsilon (Default: very small number)
  71206. * @returns true if they are equal
  71207. */
  71208. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71209. /**
  71210. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71211. * @param x x value to compare against
  71212. * @param y y value to compare against
  71213. * @param z z value to compare against
  71214. * @param w w value to compare against
  71215. * @returns true if equal
  71216. */
  71217. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71218. /**
  71219. * Multiplies in place the current Vector4 by the given one.
  71220. * @param otherVector vector to multiple with
  71221. * @returns the updated Vector4.
  71222. */
  71223. multiplyInPlace(otherVector: Vector4): Vector4;
  71224. /**
  71225. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71226. * @param otherVector vector to multiple with
  71227. * @returns resulting new vector
  71228. */
  71229. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71230. /**
  71231. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71232. * @param otherVector vector to multiple with
  71233. * @param result vector to store the result
  71234. * @returns the current Vector4.
  71235. */
  71236. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71237. /**
  71238. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71239. * @param x x value multiply with
  71240. * @param y y value multiply with
  71241. * @param z z value multiply with
  71242. * @param w w value multiply with
  71243. * @returns resulting new vector
  71244. */
  71245. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71246. /**
  71247. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71248. * @param otherVector vector to devide with
  71249. * @returns resulting new vector
  71250. */
  71251. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71252. /**
  71253. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71254. * @param otherVector vector to devide with
  71255. * @param result vector to store the result
  71256. * @returns the current Vector4.
  71257. */
  71258. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71259. /**
  71260. * Divides the current Vector3 coordinates by the given ones.
  71261. * @param otherVector vector to devide with
  71262. * @returns the updated Vector3.
  71263. */
  71264. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71265. /**
  71266. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71267. * @param other defines the second operand
  71268. * @returns the current updated Vector4
  71269. */
  71270. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71271. /**
  71272. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71273. * @param other defines the second operand
  71274. * @returns the current updated Vector4
  71275. */
  71276. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71277. /**
  71278. * Gets a new Vector4 from current Vector4 floored values
  71279. * @returns a new Vector4
  71280. */
  71281. floor(): Vector4;
  71282. /**
  71283. * Gets a new Vector4 from current Vector3 floored values
  71284. * @returns a new Vector4
  71285. */
  71286. fract(): Vector4;
  71287. /**
  71288. * Returns the Vector4 length (float).
  71289. * @returns the length
  71290. */
  71291. length(): number;
  71292. /**
  71293. * Returns the Vector4 squared length (float).
  71294. * @returns the length squared
  71295. */
  71296. lengthSquared(): number;
  71297. /**
  71298. * Normalizes in place the Vector4.
  71299. * @returns the updated Vector4.
  71300. */
  71301. normalize(): Vector4;
  71302. /**
  71303. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71304. * @returns this converted to a new vector3
  71305. */
  71306. toVector3(): Vector3;
  71307. /**
  71308. * Returns a new Vector4 copied from the current one.
  71309. * @returns the new cloned vector
  71310. */
  71311. clone(): Vector4;
  71312. /**
  71313. * Updates the current Vector4 with the given one coordinates.
  71314. * @param source the source vector to copy from
  71315. * @returns the updated Vector4.
  71316. */
  71317. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71318. /**
  71319. * Updates the current Vector4 coordinates with the given floats.
  71320. * @param x float to copy from
  71321. * @param y float to copy from
  71322. * @param z float to copy from
  71323. * @param w float to copy from
  71324. * @returns the updated Vector4.
  71325. */
  71326. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71327. /**
  71328. * Updates the current Vector4 coordinates with the given floats.
  71329. * @param x float to set from
  71330. * @param y float to set from
  71331. * @param z float to set from
  71332. * @param w float to set from
  71333. * @returns the updated Vector4.
  71334. */
  71335. set(x: number, y: number, z: number, w: number): Vector4;
  71336. /**
  71337. * Copies the given float to the current Vector3 coordinates
  71338. * @param v defines the x, y, z and w coordinates of the operand
  71339. * @returns the current updated Vector3
  71340. */
  71341. setAll(v: number): Vector4;
  71342. /**
  71343. * Returns a new Vector4 set from the starting index of the given array.
  71344. * @param array the array to pull values from
  71345. * @param offset the offset into the array to start at
  71346. * @returns the new vector
  71347. */
  71348. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71349. /**
  71350. * Updates the given vector "result" from the starting index of the given array.
  71351. * @param array the array to pull values from
  71352. * @param offset the offset into the array to start at
  71353. * @param result the vector to store the result in
  71354. */
  71355. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71356. /**
  71357. * Updates the given vector "result" from the starting index of the given Float32Array.
  71358. * @param array the array to pull values from
  71359. * @param offset the offset into the array to start at
  71360. * @param result the vector to store the result in
  71361. */
  71362. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71363. /**
  71364. * Updates the given vector "result" coordinates from the given floats.
  71365. * @param x float to set from
  71366. * @param y float to set from
  71367. * @param z float to set from
  71368. * @param w float to set from
  71369. * @param result the vector to the floats in
  71370. */
  71371. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71372. /**
  71373. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71374. * @returns the new vector
  71375. */
  71376. static Zero(): Vector4;
  71377. /**
  71378. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71379. * @returns the new vector
  71380. */
  71381. static One(): Vector4;
  71382. /**
  71383. * Returns a new normalized Vector4 from the given one.
  71384. * @param vector the vector to normalize
  71385. * @returns the vector
  71386. */
  71387. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71388. /**
  71389. * Updates the given vector "result" from the normalization of the given one.
  71390. * @param vector the vector to normalize
  71391. * @param result the vector to store the result in
  71392. */
  71393. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71394. /**
  71395. * Returns a vector with the minimum values from the left and right vectors
  71396. * @param left left vector to minimize
  71397. * @param right right vector to minimize
  71398. * @returns a new vector with the minimum of the left and right vector values
  71399. */
  71400. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71401. /**
  71402. * Returns a vector with the maximum values from the left and right vectors
  71403. * @param left left vector to maximize
  71404. * @param right right vector to maximize
  71405. * @returns a new vector with the maximum of the left and right vector values
  71406. */
  71407. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71408. /**
  71409. * Returns the distance (float) between the vectors "value1" and "value2".
  71410. * @param value1 value to calulate the distance between
  71411. * @param value2 value to calulate the distance between
  71412. * @return the distance between the two vectors
  71413. */
  71414. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71415. /**
  71416. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71417. * @param value1 value to calulate the distance between
  71418. * @param value2 value to calulate the distance between
  71419. * @return the distance between the two vectors squared
  71420. */
  71421. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71422. /**
  71423. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71424. * @param value1 value to calulate the center between
  71425. * @param value2 value to calulate the center between
  71426. * @return the center between the two vectors
  71427. */
  71428. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71429. /**
  71430. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71431. * This methods computes transformed normalized direction vectors only.
  71432. * @param vector the vector to transform
  71433. * @param transformation the transformation matrix to apply
  71434. * @returns the new vector
  71435. */
  71436. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71437. /**
  71438. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71439. * This methods computes transformed normalized direction vectors only.
  71440. * @param vector the vector to transform
  71441. * @param transformation the transformation matrix to apply
  71442. * @param result the vector to store the result in
  71443. */
  71444. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71445. /**
  71446. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71447. * This methods computes transformed normalized direction vectors only.
  71448. * @param x value to transform
  71449. * @param y value to transform
  71450. * @param z value to transform
  71451. * @param w value to transform
  71452. * @param transformation the transformation matrix to apply
  71453. * @param result the vector to store the results in
  71454. */
  71455. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71456. /**
  71457. * Creates a new Vector4 from a Vector3
  71458. * @param source defines the source data
  71459. * @param w defines the 4th component (default is 0)
  71460. * @returns a new Vector4
  71461. */
  71462. static FromVector3(source: Vector3, w?: number): Vector4;
  71463. }
  71464. /**
  71465. * Class used to store quaternion data
  71466. * @see https://en.wikipedia.org/wiki/Quaternion
  71467. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71468. */
  71469. export class Quaternion {
  71470. /** defines the first component (0 by default) */
  71471. x: number;
  71472. /** defines the second component (0 by default) */
  71473. y: number;
  71474. /** defines the third component (0 by default) */
  71475. z: number;
  71476. /** defines the fourth component (1.0 by default) */
  71477. w: number;
  71478. /**
  71479. * Creates a new Quaternion from the given floats
  71480. * @param x defines the first component (0 by default)
  71481. * @param y defines the second component (0 by default)
  71482. * @param z defines the third component (0 by default)
  71483. * @param w defines the fourth component (1.0 by default)
  71484. */
  71485. constructor(
  71486. /** defines the first component (0 by default) */
  71487. x?: number,
  71488. /** defines the second component (0 by default) */
  71489. y?: number,
  71490. /** defines the third component (0 by default) */
  71491. z?: number,
  71492. /** defines the fourth component (1.0 by default) */
  71493. w?: number);
  71494. /**
  71495. * Gets a string representation for the current quaternion
  71496. * @returns a string with the Quaternion coordinates
  71497. */
  71498. toString(): string;
  71499. /**
  71500. * Gets the class name of the quaternion
  71501. * @returns the string "Quaternion"
  71502. */
  71503. getClassName(): string;
  71504. /**
  71505. * Gets a hash code for this quaternion
  71506. * @returns the quaternion hash code
  71507. */
  71508. getHashCode(): number;
  71509. /**
  71510. * Copy the quaternion to an array
  71511. * @returns a new array populated with 4 elements from the quaternion coordinates
  71512. */
  71513. asArray(): number[];
  71514. /**
  71515. * Check if two quaternions are equals
  71516. * @param otherQuaternion defines the second operand
  71517. * @return true if the current quaternion and the given one coordinates are strictly equals
  71518. */
  71519. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71520. /**
  71521. * Clone the current quaternion
  71522. * @returns a new quaternion copied from the current one
  71523. */
  71524. clone(): Quaternion;
  71525. /**
  71526. * Copy a quaternion to the current one
  71527. * @param other defines the other quaternion
  71528. * @returns the updated current quaternion
  71529. */
  71530. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71531. /**
  71532. * Updates the current quaternion with the given float coordinates
  71533. * @param x defines the x coordinate
  71534. * @param y defines the y coordinate
  71535. * @param z defines the z coordinate
  71536. * @param w defines the w coordinate
  71537. * @returns the updated current quaternion
  71538. */
  71539. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71540. /**
  71541. * Updates the current quaternion from the given float coordinates
  71542. * @param x defines the x coordinate
  71543. * @param y defines the y coordinate
  71544. * @param z defines the z coordinate
  71545. * @param w defines the w coordinate
  71546. * @returns the updated current quaternion
  71547. */
  71548. set(x: number, y: number, z: number, w: number): Quaternion;
  71549. /**
  71550. * Adds two quaternions
  71551. * @param other defines the second operand
  71552. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71553. */
  71554. add(other: DeepImmutable<Quaternion>): Quaternion;
  71555. /**
  71556. * Add a quaternion to the current one
  71557. * @param other defines the quaternion to add
  71558. * @returns the current quaternion
  71559. */
  71560. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71561. /**
  71562. * Subtract two quaternions
  71563. * @param other defines the second operand
  71564. * @returns a new quaternion as the subtraction result of the given one from the current one
  71565. */
  71566. subtract(other: Quaternion): Quaternion;
  71567. /**
  71568. * Multiplies the current quaternion by a scale factor
  71569. * @param value defines the scale factor
  71570. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71571. */
  71572. scale(value: number): Quaternion;
  71573. /**
  71574. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71575. * @param scale defines the scale factor
  71576. * @param result defines the Quaternion object where to store the result
  71577. * @returns the unmodified current quaternion
  71578. */
  71579. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71580. /**
  71581. * Multiplies in place the current quaternion by a scale factor
  71582. * @param value defines the scale factor
  71583. * @returns the current modified quaternion
  71584. */
  71585. scaleInPlace(value: number): Quaternion;
  71586. /**
  71587. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71588. * @param scale defines the scale factor
  71589. * @param result defines the Quaternion object where to store the result
  71590. * @returns the unmodified current quaternion
  71591. */
  71592. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71593. /**
  71594. * Multiplies two quaternions
  71595. * @param q1 defines the second operand
  71596. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71597. */
  71598. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71599. /**
  71600. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71601. * @param q1 defines the second operand
  71602. * @param result defines the target quaternion
  71603. * @returns the current quaternion
  71604. */
  71605. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71606. /**
  71607. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71608. * @param q1 defines the second operand
  71609. * @returns the currentupdated quaternion
  71610. */
  71611. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71612. /**
  71613. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71614. * @param ref defines the target quaternion
  71615. * @returns the current quaternion
  71616. */
  71617. conjugateToRef(ref: Quaternion): Quaternion;
  71618. /**
  71619. * Conjugates in place (1-q) the current quaternion
  71620. * @returns the current updated quaternion
  71621. */
  71622. conjugateInPlace(): Quaternion;
  71623. /**
  71624. * Conjugates in place (1-q) the current quaternion
  71625. * @returns a new quaternion
  71626. */
  71627. conjugate(): Quaternion;
  71628. /**
  71629. * Gets length of current quaternion
  71630. * @returns the quaternion length (float)
  71631. */
  71632. length(): number;
  71633. /**
  71634. * Normalize in place the current quaternion
  71635. * @returns the current updated quaternion
  71636. */
  71637. normalize(): Quaternion;
  71638. /**
  71639. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71640. * @param order is a reserved parameter and is ignore for now
  71641. * @returns a new Vector3 containing the Euler angles
  71642. */
  71643. toEulerAngles(order?: string): Vector3;
  71644. /**
  71645. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71646. * @param result defines the vector which will be filled with the Euler angles
  71647. * @param order is a reserved parameter and is ignore for now
  71648. * @returns the current unchanged quaternion
  71649. */
  71650. toEulerAnglesToRef(result: Vector3): Quaternion;
  71651. /**
  71652. * Updates the given rotation matrix with the current quaternion values
  71653. * @param result defines the target matrix
  71654. * @returns the current unchanged quaternion
  71655. */
  71656. toRotationMatrix(result: Matrix): Quaternion;
  71657. /**
  71658. * Updates the current quaternion from the given rotation matrix values
  71659. * @param matrix defines the source matrix
  71660. * @returns the current updated quaternion
  71661. */
  71662. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71663. /**
  71664. * Creates a new quaternion from a rotation matrix
  71665. * @param matrix defines the source matrix
  71666. * @returns a new quaternion created from the given rotation matrix values
  71667. */
  71668. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71669. /**
  71670. * Updates the given quaternion with the given rotation matrix values
  71671. * @param matrix defines the source matrix
  71672. * @param result defines the target quaternion
  71673. */
  71674. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71675. /**
  71676. * Returns the dot product (float) between the quaternions "left" and "right"
  71677. * @param left defines the left operand
  71678. * @param right defines the right operand
  71679. * @returns the dot product
  71680. */
  71681. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71682. /**
  71683. * Checks if the two quaternions are close to each other
  71684. * @param quat0 defines the first quaternion to check
  71685. * @param quat1 defines the second quaternion to check
  71686. * @returns true if the two quaternions are close to each other
  71687. */
  71688. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71689. /**
  71690. * Creates an empty quaternion
  71691. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71692. */
  71693. static Zero(): Quaternion;
  71694. /**
  71695. * Inverse a given quaternion
  71696. * @param q defines the source quaternion
  71697. * @returns a new quaternion as the inverted current quaternion
  71698. */
  71699. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71700. /**
  71701. * Inverse a given quaternion
  71702. * @param q defines the source quaternion
  71703. * @param result the quaternion the result will be stored in
  71704. * @returns the result quaternion
  71705. */
  71706. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71707. /**
  71708. * Creates an identity quaternion
  71709. * @returns the identity quaternion
  71710. */
  71711. static Identity(): Quaternion;
  71712. /**
  71713. * Gets a boolean indicating if the given quaternion is identity
  71714. * @param quaternion defines the quaternion to check
  71715. * @returns true if the quaternion is identity
  71716. */
  71717. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71718. /**
  71719. * Creates a quaternion from a rotation around an axis
  71720. * @param axis defines the axis to use
  71721. * @param angle defines the angle to use
  71722. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71723. */
  71724. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71725. /**
  71726. * Creates a rotation around an axis and stores it into the given quaternion
  71727. * @param axis defines the axis to use
  71728. * @param angle defines the angle to use
  71729. * @param result defines the target quaternion
  71730. * @returns the target quaternion
  71731. */
  71732. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71733. /**
  71734. * Creates a new quaternion from data stored into an array
  71735. * @param array defines the data source
  71736. * @param offset defines the offset in the source array where the data starts
  71737. * @returns a new quaternion
  71738. */
  71739. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71740. /**
  71741. * Create a quaternion from Euler rotation angles
  71742. * @param x Pitch
  71743. * @param y Yaw
  71744. * @param z Roll
  71745. * @returns the new Quaternion
  71746. */
  71747. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71748. /**
  71749. * Updates a quaternion from Euler rotation angles
  71750. * @param x Pitch
  71751. * @param y Yaw
  71752. * @param z Roll
  71753. * @param result the quaternion to store the result
  71754. * @returns the updated quaternion
  71755. */
  71756. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71757. /**
  71758. * Create a quaternion from Euler rotation vector
  71759. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71760. * @returns the new Quaternion
  71761. */
  71762. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71763. /**
  71764. * Updates a quaternion from Euler rotation vector
  71765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71766. * @param result the quaternion to store the result
  71767. * @returns the updated quaternion
  71768. */
  71769. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71770. /**
  71771. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71772. * @param yaw defines the rotation around Y axis
  71773. * @param pitch defines the rotation around X axis
  71774. * @param roll defines the rotation around Z axis
  71775. * @returns the new quaternion
  71776. */
  71777. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71778. /**
  71779. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71780. * @param yaw defines the rotation around Y axis
  71781. * @param pitch defines the rotation around X axis
  71782. * @param roll defines the rotation around Z axis
  71783. * @param result defines the target quaternion
  71784. */
  71785. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71786. /**
  71787. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71788. * @param alpha defines the rotation around first axis
  71789. * @param beta defines the rotation around second axis
  71790. * @param gamma defines the rotation around third axis
  71791. * @returns the new quaternion
  71792. */
  71793. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71794. /**
  71795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71796. * @param alpha defines the rotation around first axis
  71797. * @param beta defines the rotation around second axis
  71798. * @param gamma defines the rotation around third axis
  71799. * @param result defines the target quaternion
  71800. */
  71801. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71802. /**
  71803. * 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)
  71804. * @param axis1 defines the first axis
  71805. * @param axis2 defines the second axis
  71806. * @param axis3 defines the third axis
  71807. * @returns the new quaternion
  71808. */
  71809. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71810. /**
  71811. * 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
  71812. * @param axis1 defines the first axis
  71813. * @param axis2 defines the second axis
  71814. * @param axis3 defines the third axis
  71815. * @param ref defines the target quaternion
  71816. */
  71817. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71818. /**
  71819. * Interpolates between two quaternions
  71820. * @param left defines first quaternion
  71821. * @param right defines second quaternion
  71822. * @param amount defines the gradient to use
  71823. * @returns the new interpolated quaternion
  71824. */
  71825. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71826. /**
  71827. * Interpolates between two quaternions and stores it into a target quaternion
  71828. * @param left defines first quaternion
  71829. * @param right defines second quaternion
  71830. * @param amount defines the gradient to use
  71831. * @param result defines the target quaternion
  71832. */
  71833. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71834. /**
  71835. * Interpolate between two quaternions using Hermite interpolation
  71836. * @param value1 defines first quaternion
  71837. * @param tangent1 defines the incoming tangent
  71838. * @param value2 defines second quaternion
  71839. * @param tangent2 defines the outgoing tangent
  71840. * @param amount defines the target quaternion
  71841. * @returns the new interpolated quaternion
  71842. */
  71843. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71844. }
  71845. /**
  71846. * Class used to store matrix data (4x4)
  71847. */
  71848. export class Matrix {
  71849. private static _updateFlagSeed;
  71850. private static _identityReadOnly;
  71851. private _isIdentity;
  71852. private _isIdentityDirty;
  71853. private _isIdentity3x2;
  71854. private _isIdentity3x2Dirty;
  71855. /**
  71856. * Gets the update flag of the matrix which is an unique number for the matrix.
  71857. * It will be incremented every time the matrix data change.
  71858. * You can use it to speed the comparison between two versions of the same matrix.
  71859. */
  71860. updateFlag: number;
  71861. private readonly _m;
  71862. /**
  71863. * Gets the internal data of the matrix
  71864. */
  71865. readonly m: DeepImmutable<Float32Array>;
  71866. /** @hidden */
  71867. _markAsUpdated(): void;
  71868. /** @hidden */
  71869. private _updateIdentityStatus;
  71870. /**
  71871. * Creates an empty matrix (filled with zeros)
  71872. */
  71873. constructor();
  71874. /**
  71875. * Check if the current matrix is identity
  71876. * @returns true is the matrix is the identity matrix
  71877. */
  71878. isIdentity(): boolean;
  71879. /**
  71880. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71881. * @returns true is the matrix is the identity matrix
  71882. */
  71883. isIdentityAs3x2(): boolean;
  71884. /**
  71885. * Gets the determinant of the matrix
  71886. * @returns the matrix determinant
  71887. */
  71888. determinant(): number;
  71889. /**
  71890. * Returns the matrix as a Float32Array
  71891. * @returns the matrix underlying array
  71892. */
  71893. toArray(): DeepImmutable<Float32Array>;
  71894. /**
  71895. * Returns the matrix as a Float32Array
  71896. * @returns the matrix underlying array.
  71897. */
  71898. asArray(): DeepImmutable<Float32Array>;
  71899. /**
  71900. * Inverts the current matrix in place
  71901. * @returns the current inverted matrix
  71902. */
  71903. invert(): Matrix;
  71904. /**
  71905. * Sets all the matrix elements to zero
  71906. * @returns the current matrix
  71907. */
  71908. reset(): Matrix;
  71909. /**
  71910. * Adds the current matrix with a second one
  71911. * @param other defines the matrix to add
  71912. * @returns a new matrix as the addition of the current matrix and the given one
  71913. */
  71914. add(other: DeepImmutable<Matrix>): Matrix;
  71915. /**
  71916. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71917. * @param other defines the matrix to add
  71918. * @param result defines the target matrix
  71919. * @returns the current matrix
  71920. */
  71921. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71922. /**
  71923. * Adds in place the given matrix to the current matrix
  71924. * @param other defines the second operand
  71925. * @returns the current updated matrix
  71926. */
  71927. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71928. /**
  71929. * Sets the given matrix to the current inverted Matrix
  71930. * @param other defines the target matrix
  71931. * @returns the unmodified current matrix
  71932. */
  71933. invertToRef(other: Matrix): Matrix;
  71934. /**
  71935. * add a value at the specified position in the current Matrix
  71936. * @param index the index of the value within the matrix. between 0 and 15.
  71937. * @param value the value to be added
  71938. * @returns the current updated matrix
  71939. */
  71940. addAtIndex(index: number, value: number): Matrix;
  71941. /**
  71942. * mutiply the specified position in the current Matrix by a value
  71943. * @param index the index of the value within the matrix. between 0 and 15.
  71944. * @param value the value to be added
  71945. * @returns the current updated matrix
  71946. */
  71947. multiplyAtIndex(index: number, value: number): Matrix;
  71948. /**
  71949. * Inserts the translation vector (using 3 floats) in the current matrix
  71950. * @param x defines the 1st component of the translation
  71951. * @param y defines the 2nd component of the translation
  71952. * @param z defines the 3rd component of the translation
  71953. * @returns the current updated matrix
  71954. */
  71955. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71956. /**
  71957. * Adds the translation vector (using 3 floats) in the current matrix
  71958. * @param x defines the 1st component of the translation
  71959. * @param y defines the 2nd component of the translation
  71960. * @param z defines the 3rd component of the translation
  71961. * @returns the current updated matrix
  71962. */
  71963. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71964. /**
  71965. * Inserts the translation vector in the current matrix
  71966. * @param vector3 defines the translation to insert
  71967. * @returns the current updated matrix
  71968. */
  71969. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71970. /**
  71971. * Gets the translation value of the current matrix
  71972. * @returns a new Vector3 as the extracted translation from the matrix
  71973. */
  71974. getTranslation(): Vector3;
  71975. /**
  71976. * Fill a Vector3 with the extracted translation from the matrix
  71977. * @param result defines the Vector3 where to store the translation
  71978. * @returns the current matrix
  71979. */
  71980. getTranslationToRef(result: Vector3): Matrix;
  71981. /**
  71982. * Remove rotation and scaling part from the matrix
  71983. * @returns the updated matrix
  71984. */
  71985. removeRotationAndScaling(): Matrix;
  71986. /**
  71987. * Multiply two matrices
  71988. * @param other defines the second operand
  71989. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71990. */
  71991. multiply(other: DeepImmutable<Matrix>): Matrix;
  71992. /**
  71993. * Copy the current matrix from the given one
  71994. * @param other defines the source matrix
  71995. * @returns the current updated matrix
  71996. */
  71997. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71998. /**
  71999. * Populates the given array from the starting index with the current matrix values
  72000. * @param array defines the target array
  72001. * @param offset defines the offset in the target array where to start storing values
  72002. * @returns the current matrix
  72003. */
  72004. copyToArray(array: Float32Array, offset?: number): Matrix;
  72005. /**
  72006. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72007. * @param other defines the second operand
  72008. * @param result defines the matrix where to store the multiplication
  72009. * @returns the current matrix
  72010. */
  72011. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72012. /**
  72013. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72014. * @param other defines the second operand
  72015. * @param result defines the array where to store the multiplication
  72016. * @param offset defines the offset in the target array where to start storing values
  72017. * @returns the current matrix
  72018. */
  72019. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72020. /**
  72021. * Check equality between this matrix and a second one
  72022. * @param value defines the second matrix to compare
  72023. * @returns true is the current matrix and the given one values are strictly equal
  72024. */
  72025. equals(value: DeepImmutable<Matrix>): boolean;
  72026. /**
  72027. * Clone the current matrix
  72028. * @returns a new matrix from the current matrix
  72029. */
  72030. clone(): Matrix;
  72031. /**
  72032. * Returns the name of the current matrix class
  72033. * @returns the string "Matrix"
  72034. */
  72035. getClassName(): string;
  72036. /**
  72037. * Gets the hash code of the current matrix
  72038. * @returns the hash code
  72039. */
  72040. getHashCode(): number;
  72041. /**
  72042. * Decomposes the current Matrix into a translation, rotation and scaling components
  72043. * @param scale defines the scale vector3 given as a reference to update
  72044. * @param rotation defines the rotation quaternion given as a reference to update
  72045. * @param translation defines the translation vector3 given as a reference to update
  72046. * @returns true if operation was successful
  72047. */
  72048. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72049. /**
  72050. * Gets specific row of the matrix
  72051. * @param index defines the number of the row to get
  72052. * @returns the index-th row of the current matrix as a new Vector4
  72053. */
  72054. getRow(index: number): Nullable<Vector4>;
  72055. /**
  72056. * Sets the index-th row of the current matrix to the vector4 values
  72057. * @param index defines the number of the row to set
  72058. * @param row defines the target vector4
  72059. * @returns the updated current matrix
  72060. */
  72061. setRow(index: number, row: Vector4): Matrix;
  72062. /**
  72063. * Compute the transpose of the matrix
  72064. * @returns the new transposed matrix
  72065. */
  72066. transpose(): Matrix;
  72067. /**
  72068. * Compute the transpose of the matrix and store it in a given matrix
  72069. * @param result defines the target matrix
  72070. * @returns the current matrix
  72071. */
  72072. transposeToRef(result: Matrix): Matrix;
  72073. /**
  72074. * Sets the index-th row of the current matrix with the given 4 x float values
  72075. * @param index defines the row index
  72076. * @param x defines the x component to set
  72077. * @param y defines the y component to set
  72078. * @param z defines the z component to set
  72079. * @param w defines the w component to set
  72080. * @returns the updated current matrix
  72081. */
  72082. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72083. /**
  72084. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72085. * @param scale defines the scale factor
  72086. * @returns a new matrix
  72087. */
  72088. scale(scale: number): Matrix;
  72089. /**
  72090. * Scale the current matrix values by a factor to a given result matrix
  72091. * @param scale defines the scale factor
  72092. * @param result defines the matrix to store the result
  72093. * @returns the current matrix
  72094. */
  72095. scaleToRef(scale: number, result: Matrix): Matrix;
  72096. /**
  72097. * Scale the current matrix values by a factor and add the result to a given matrix
  72098. * @param scale defines the scale factor
  72099. * @param result defines the Matrix to store the result
  72100. * @returns the current matrix
  72101. */
  72102. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72103. /**
  72104. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72105. * @param ref matrix to store the result
  72106. */
  72107. toNormalMatrix(ref: Matrix): void;
  72108. /**
  72109. * Gets only rotation part of the current matrix
  72110. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72111. */
  72112. getRotationMatrix(): Matrix;
  72113. /**
  72114. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72115. * @param result defines the target matrix to store data to
  72116. * @returns the current matrix
  72117. */
  72118. getRotationMatrixToRef(result: Matrix): Matrix;
  72119. /**
  72120. * Toggles model matrix from being right handed to left handed in place and vice versa
  72121. */
  72122. toggleModelMatrixHandInPlace(): void;
  72123. /**
  72124. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72125. */
  72126. toggleProjectionMatrixHandInPlace(): void;
  72127. /**
  72128. * Creates a matrix from an array
  72129. * @param array defines the source array
  72130. * @param offset defines an offset in the source array
  72131. * @returns a new Matrix set from the starting index of the given array
  72132. */
  72133. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72134. /**
  72135. * Copy the content of an array into a given matrix
  72136. * @param array defines the source array
  72137. * @param offset defines an offset in the source array
  72138. * @param result defines the target matrix
  72139. */
  72140. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72141. /**
  72142. * Stores an array into a matrix after having multiplied each component by a given factor
  72143. * @param array defines the source array
  72144. * @param offset defines the offset in the source array
  72145. * @param scale defines the scaling factor
  72146. * @param result defines the target matrix
  72147. */
  72148. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72149. /**
  72150. * Gets an identity matrix that must not be updated
  72151. */
  72152. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72153. /**
  72154. * Stores a list of values (16) inside a given matrix
  72155. * @param initialM11 defines 1st value of 1st row
  72156. * @param initialM12 defines 2nd value of 1st row
  72157. * @param initialM13 defines 3rd value of 1st row
  72158. * @param initialM14 defines 4th value of 1st row
  72159. * @param initialM21 defines 1st value of 2nd row
  72160. * @param initialM22 defines 2nd value of 2nd row
  72161. * @param initialM23 defines 3rd value of 2nd row
  72162. * @param initialM24 defines 4th value of 2nd row
  72163. * @param initialM31 defines 1st value of 3rd row
  72164. * @param initialM32 defines 2nd value of 3rd row
  72165. * @param initialM33 defines 3rd value of 3rd row
  72166. * @param initialM34 defines 4th value of 3rd row
  72167. * @param initialM41 defines 1st value of 4th row
  72168. * @param initialM42 defines 2nd value of 4th row
  72169. * @param initialM43 defines 3rd value of 4th row
  72170. * @param initialM44 defines 4th value of 4th row
  72171. * @param result defines the target matrix
  72172. */
  72173. 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;
  72174. /**
  72175. * Creates new matrix from a list of values (16)
  72176. * @param initialM11 defines 1st value of 1st row
  72177. * @param initialM12 defines 2nd value of 1st row
  72178. * @param initialM13 defines 3rd value of 1st row
  72179. * @param initialM14 defines 4th value of 1st row
  72180. * @param initialM21 defines 1st value of 2nd row
  72181. * @param initialM22 defines 2nd value of 2nd row
  72182. * @param initialM23 defines 3rd value of 2nd row
  72183. * @param initialM24 defines 4th value of 2nd row
  72184. * @param initialM31 defines 1st value of 3rd row
  72185. * @param initialM32 defines 2nd value of 3rd row
  72186. * @param initialM33 defines 3rd value of 3rd row
  72187. * @param initialM34 defines 4th value of 3rd row
  72188. * @param initialM41 defines 1st value of 4th row
  72189. * @param initialM42 defines 2nd value of 4th row
  72190. * @param initialM43 defines 3rd value of 4th row
  72191. * @param initialM44 defines 4th value of 4th row
  72192. * @returns the new matrix
  72193. */
  72194. 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;
  72195. /**
  72196. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72197. * @param scale defines the scale vector3
  72198. * @param rotation defines the rotation quaternion
  72199. * @param translation defines the translation vector3
  72200. * @returns a new matrix
  72201. */
  72202. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72203. /**
  72204. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72205. * @param scale defines the scale vector3
  72206. * @param rotation defines the rotation quaternion
  72207. * @param translation defines the translation vector3
  72208. * @param result defines the target matrix
  72209. */
  72210. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72211. /**
  72212. * Creates a new identity matrix
  72213. * @returns a new identity matrix
  72214. */
  72215. static Identity(): Matrix;
  72216. /**
  72217. * Creates a new identity matrix and stores the result in a given matrix
  72218. * @param result defines the target matrix
  72219. */
  72220. static IdentityToRef(result: Matrix): void;
  72221. /**
  72222. * Creates a new zero matrix
  72223. * @returns a new zero matrix
  72224. */
  72225. static Zero(): Matrix;
  72226. /**
  72227. * Creates a new rotation matrix for "angle" radians around the X axis
  72228. * @param angle defines the angle (in radians) to use
  72229. * @return the new matrix
  72230. */
  72231. static RotationX(angle: number): Matrix;
  72232. /**
  72233. * Creates a new matrix as the invert of a given matrix
  72234. * @param source defines the source matrix
  72235. * @returns the new matrix
  72236. */
  72237. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72238. /**
  72239. * Creates a new rotation matrix for "angle" radians around the X 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 RotationXToRef(angle: number, result: Matrix): void;
  72244. /**
  72245. * Creates a new rotation matrix for "angle" radians around the Y axis
  72246. * @param angle defines the angle (in radians) to use
  72247. * @return the new matrix
  72248. */
  72249. static RotationY(angle: number): Matrix;
  72250. /**
  72251. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72252. * @param angle defines the angle (in radians) to use
  72253. * @param result defines the target matrix
  72254. */
  72255. static RotationYToRef(angle: number, result: Matrix): void;
  72256. /**
  72257. * Creates a new rotation matrix for "angle" radians around the Z axis
  72258. * @param angle defines the angle (in radians) to use
  72259. * @return the new matrix
  72260. */
  72261. static RotationZ(angle: number): Matrix;
  72262. /**
  72263. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72264. * @param angle defines the angle (in radians) to use
  72265. * @param result defines the target matrix
  72266. */
  72267. static RotationZToRef(angle: number, result: Matrix): void;
  72268. /**
  72269. * Creates a new rotation matrix for "angle" radians around the given axis
  72270. * @param axis defines the axis to use
  72271. * @param angle defines the angle (in radians) to use
  72272. * @return the new matrix
  72273. */
  72274. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72275. /**
  72276. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72277. * @param axis defines the axis to use
  72278. * @param angle defines the angle (in radians) to use
  72279. * @param result defines the target matrix
  72280. */
  72281. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72282. /**
  72283. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72284. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72285. * @param from defines the vector to align
  72286. * @param to defines the vector to align to
  72287. * @param result defines the target matrix
  72288. */
  72289. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72290. /**
  72291. * Creates a rotation matrix
  72292. * @param yaw defines the yaw angle in radians (Y axis)
  72293. * @param pitch defines the pitch angle in radians (X axis)
  72294. * @param roll defines the roll angle in radians (X axis)
  72295. * @returns the new rotation matrix
  72296. */
  72297. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72298. /**
  72299. * Creates a rotation matrix and stores it in a given matrix
  72300. * @param yaw defines the yaw angle in radians (Y axis)
  72301. * @param pitch defines the pitch angle in radians (X axis)
  72302. * @param roll defines the roll angle in radians (X axis)
  72303. * @param result defines the target matrix
  72304. */
  72305. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72306. /**
  72307. * Creates a scaling matrix
  72308. * @param x defines the scale factor on X axis
  72309. * @param y defines the scale factor on Y axis
  72310. * @param z defines the scale factor on Z axis
  72311. * @returns the new matrix
  72312. */
  72313. static Scaling(x: number, y: number, z: number): Matrix;
  72314. /**
  72315. * Creates a scaling matrix and stores it in a given matrix
  72316. * @param x defines the scale factor on X axis
  72317. * @param y defines the scale factor on Y axis
  72318. * @param z defines the scale factor on Z axis
  72319. * @param result defines the target matrix
  72320. */
  72321. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72322. /**
  72323. * Creates a translation matrix
  72324. * @param x defines the translation on X axis
  72325. * @param y defines the translation on Y axis
  72326. * @param z defines the translationon Z axis
  72327. * @returns the new matrix
  72328. */
  72329. static Translation(x: number, y: number, z: number): Matrix;
  72330. /**
  72331. * Creates a translation matrix and stores it in a given matrix
  72332. * @param x defines the translation on X axis
  72333. * @param y defines the translation on Y axis
  72334. * @param z defines the translationon Z axis
  72335. * @param result defines the target matrix
  72336. */
  72337. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72338. /**
  72339. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72340. * @param startValue defines the start value
  72341. * @param endValue defines the end value
  72342. * @param gradient defines the gradient factor
  72343. * @returns the new matrix
  72344. */
  72345. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72346. /**
  72347. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72348. * @param startValue defines the start value
  72349. * @param endValue defines the end value
  72350. * @param gradient defines the gradient factor
  72351. * @param result defines the Matrix object where to store data
  72352. */
  72353. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72354. /**
  72355. * Builds a new matrix whose values are computed by:
  72356. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72357. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72358. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72359. * @param startValue defines the first matrix
  72360. * @param endValue defines the second matrix
  72361. * @param gradient defines the gradient between the two matrices
  72362. * @returns the new matrix
  72363. */
  72364. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72365. /**
  72366. * Update a matrix to values which are computed by:
  72367. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72368. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72369. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72370. * @param startValue defines the first matrix
  72371. * @param endValue defines the second matrix
  72372. * @param gradient defines the gradient between the two matrices
  72373. * @param result defines the target matrix
  72374. */
  72375. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72376. /**
  72377. * 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"
  72378. * This function works in left handed mode
  72379. * @param eye defines the final position of the entity
  72380. * @param target defines where the entity should look at
  72381. * @param up defines the up vector for the entity
  72382. * @returns the new matrix
  72383. */
  72384. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72385. /**
  72386. * 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".
  72387. * This function works in left handed mode
  72388. * @param eye defines the final position of the entity
  72389. * @param target defines where the entity should look at
  72390. * @param up defines the up vector for the entity
  72391. * @param result defines the target matrix
  72392. */
  72393. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72394. /**
  72395. * 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"
  72396. * This function works in right handed mode
  72397. * @param eye defines the final position of the entity
  72398. * @param target defines where the entity should look at
  72399. * @param up defines the up vector for the entity
  72400. * @returns the new matrix
  72401. */
  72402. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72403. /**
  72404. * 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".
  72405. * This function works in right handed mode
  72406. * @param eye defines the final position of the entity
  72407. * @param target defines where the entity should look at
  72408. * @param up defines the up vector for the entity
  72409. * @param result defines the target matrix
  72410. */
  72411. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72412. /**
  72413. * Create a left-handed orthographic projection matrix
  72414. * @param width defines the viewport width
  72415. * @param height defines the viewport height
  72416. * @param znear defines the near clip plane
  72417. * @param zfar defines the far clip plane
  72418. * @returns a new matrix as a left-handed orthographic projection matrix
  72419. */
  72420. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72421. /**
  72422. * Store a left-handed orthographic projection to a given matrix
  72423. * @param width defines the viewport width
  72424. * @param height defines the viewport height
  72425. * @param znear defines the near clip plane
  72426. * @param zfar defines the far clip plane
  72427. * @param result defines the target matrix
  72428. */
  72429. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72430. /**
  72431. * Create a left-handed orthographic projection matrix
  72432. * @param left defines the viewport left coordinate
  72433. * @param right defines the viewport right coordinate
  72434. * @param bottom defines the viewport bottom coordinate
  72435. * @param top defines the viewport top coordinate
  72436. * @param znear defines the near clip plane
  72437. * @param zfar defines the far clip plane
  72438. * @returns a new matrix as a left-handed orthographic projection matrix
  72439. */
  72440. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72441. /**
  72442. * Stores a left-handed orthographic projection into a given matrix
  72443. * @param left defines the viewport left coordinate
  72444. * @param right defines the viewport right coordinate
  72445. * @param bottom defines the viewport bottom coordinate
  72446. * @param top defines the viewport top coordinate
  72447. * @param znear defines the near clip plane
  72448. * @param zfar defines the far clip plane
  72449. * @param result defines the target matrix
  72450. */
  72451. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72452. /**
  72453. * Creates a right-handed orthographic projection matrix
  72454. * @param left defines the viewport left coordinate
  72455. * @param right defines the viewport right coordinate
  72456. * @param bottom defines the viewport bottom coordinate
  72457. * @param top defines the viewport top coordinate
  72458. * @param znear defines the near clip plane
  72459. * @param zfar defines the far clip plane
  72460. * @returns a new matrix as a right-handed orthographic projection matrix
  72461. */
  72462. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72463. /**
  72464. * Stores a right-handed orthographic projection into a given matrix
  72465. * @param left defines the viewport left coordinate
  72466. * @param right defines the viewport right coordinate
  72467. * @param bottom defines the viewport bottom coordinate
  72468. * @param top defines the viewport top coordinate
  72469. * @param znear defines the near clip plane
  72470. * @param zfar defines the far clip plane
  72471. * @param result defines the target matrix
  72472. */
  72473. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72474. /**
  72475. * Creates a left-handed perspective projection matrix
  72476. * @param width defines the viewport width
  72477. * @param height defines the viewport height
  72478. * @param znear defines the near clip plane
  72479. * @param zfar defines the far clip plane
  72480. * @returns a new matrix as a left-handed perspective projection matrix
  72481. */
  72482. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72483. /**
  72484. * Creates a left-handed perspective projection matrix
  72485. * @param fov defines the horizontal field of view
  72486. * @param aspect defines the aspect ratio
  72487. * @param znear defines the near clip plane
  72488. * @param zfar defines the far clip plane
  72489. * @returns a new matrix as a left-handed perspective projection matrix
  72490. */
  72491. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72492. /**
  72493. * Stores a left-handed perspective projection into a given matrix
  72494. * @param fov defines the horizontal field of view
  72495. * @param aspect defines the aspect ratio
  72496. * @param znear defines the near clip plane
  72497. * @param zfar defines the far clip plane
  72498. * @param result defines the target matrix
  72499. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72500. */
  72501. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72502. /**
  72503. * Creates a right-handed perspective projection matrix
  72504. * @param fov defines the horizontal field of view
  72505. * @param aspect defines the aspect ratio
  72506. * @param znear defines the near clip plane
  72507. * @param zfar defines the far clip plane
  72508. * @returns a new matrix as a right-handed perspective projection matrix
  72509. */
  72510. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72511. /**
  72512. * Stores a right-handed perspective projection into a given matrix
  72513. * @param fov defines the horizontal field of view
  72514. * @param aspect defines the aspect ratio
  72515. * @param znear defines the near clip plane
  72516. * @param zfar defines the far clip plane
  72517. * @param result defines the target matrix
  72518. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72519. */
  72520. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72521. /**
  72522. * Stores a perspective projection for WebVR info a given matrix
  72523. * @param fov defines the field of view
  72524. * @param znear defines the near clip plane
  72525. * @param zfar defines the far clip plane
  72526. * @param result defines the target matrix
  72527. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72528. */
  72529. static PerspectiveFovWebVRToRef(fov: {
  72530. upDegrees: number;
  72531. downDegrees: number;
  72532. leftDegrees: number;
  72533. rightDegrees: number;
  72534. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72535. /**
  72536. * Computes a complete transformation matrix
  72537. * @param viewport defines the viewport to use
  72538. * @param world defines the world matrix
  72539. * @param view defines the view matrix
  72540. * @param projection defines the projection matrix
  72541. * @param zmin defines the near clip plane
  72542. * @param zmax defines the far clip plane
  72543. * @returns the transformation matrix
  72544. */
  72545. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72546. /**
  72547. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72548. * @param matrix defines the matrix to use
  72549. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72550. */
  72551. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72552. /**
  72553. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72554. * @param matrix defines the matrix to use
  72555. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72556. */
  72557. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72558. /**
  72559. * Compute the transpose of a given matrix
  72560. * @param matrix defines the matrix to transpose
  72561. * @returns the new matrix
  72562. */
  72563. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72564. /**
  72565. * Compute the transpose of a matrix and store it in a target matrix
  72566. * @param matrix defines the matrix to transpose
  72567. * @param result defines the target matrix
  72568. */
  72569. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72570. /**
  72571. * Computes a reflection matrix from a plane
  72572. * @param plane defines the reflection plane
  72573. * @returns a new matrix
  72574. */
  72575. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72576. /**
  72577. * Computes a reflection matrix from a plane
  72578. * @param plane defines the reflection plane
  72579. * @param result defines the target matrix
  72580. */
  72581. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72582. /**
  72583. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72584. * @param xaxis defines the value of the 1st axis
  72585. * @param yaxis defines the value of the 2nd axis
  72586. * @param zaxis defines the value of the 3rd axis
  72587. * @param result defines the target matrix
  72588. */
  72589. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72590. /**
  72591. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72592. * @param quat defines the quaternion to use
  72593. * @param result defines the target matrix
  72594. */
  72595. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72596. }
  72597. /**
  72598. * @hidden
  72599. */
  72600. export class TmpVectors {
  72601. static Vector2: Vector2[];
  72602. static Vector3: Vector3[];
  72603. static Vector4: Vector4[];
  72604. static Quaternion: Quaternion[];
  72605. static Matrix: Matrix[];
  72606. }
  72607. }
  72608. declare module BABYLON {
  72609. /**
  72610. * Defines potential orientation for back face culling
  72611. */
  72612. export enum Orientation {
  72613. /**
  72614. * Clockwise
  72615. */
  72616. CW = 0,
  72617. /** Counter clockwise */
  72618. CCW = 1
  72619. }
  72620. /** Class used to represent a Bezier curve */
  72621. export class BezierCurve {
  72622. /**
  72623. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72624. * @param t defines the time
  72625. * @param x1 defines the left coordinate on X axis
  72626. * @param y1 defines the left coordinate on Y axis
  72627. * @param x2 defines the right coordinate on X axis
  72628. * @param y2 defines the right coordinate on Y axis
  72629. * @returns the interpolated value
  72630. */
  72631. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72632. }
  72633. /**
  72634. * Defines angle representation
  72635. */
  72636. export class Angle {
  72637. private _radians;
  72638. /**
  72639. * Creates an Angle object of "radians" radians (float).
  72640. * @param radians the angle in radians
  72641. */
  72642. constructor(radians: number);
  72643. /**
  72644. * Get value in degrees
  72645. * @returns the Angle value in degrees (float)
  72646. */
  72647. degrees(): number;
  72648. /**
  72649. * Get value in radians
  72650. * @returns the Angle value in radians (float)
  72651. */
  72652. radians(): number;
  72653. /**
  72654. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72655. * @param a defines first vector
  72656. * @param b defines second vector
  72657. * @returns a new Angle
  72658. */
  72659. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72660. /**
  72661. * Gets a new Angle object from the given float in radians
  72662. * @param radians defines the angle value in radians
  72663. * @returns a new Angle
  72664. */
  72665. static FromRadians(radians: number): Angle;
  72666. /**
  72667. * Gets a new Angle object from the given float in degrees
  72668. * @param degrees defines the angle value in degrees
  72669. * @returns a new Angle
  72670. */
  72671. static FromDegrees(degrees: number): Angle;
  72672. }
  72673. /**
  72674. * This represents an arc in a 2d space.
  72675. */
  72676. export class Arc2 {
  72677. /** Defines the start point of the arc */
  72678. startPoint: Vector2;
  72679. /** Defines the mid point of the arc */
  72680. midPoint: Vector2;
  72681. /** Defines the end point of the arc */
  72682. endPoint: Vector2;
  72683. /**
  72684. * Defines the center point of the arc.
  72685. */
  72686. centerPoint: Vector2;
  72687. /**
  72688. * Defines the radius of the arc.
  72689. */
  72690. radius: number;
  72691. /**
  72692. * Defines the angle of the arc (from mid point to end point).
  72693. */
  72694. angle: Angle;
  72695. /**
  72696. * Defines the start angle of the arc (from start point to middle point).
  72697. */
  72698. startAngle: Angle;
  72699. /**
  72700. * Defines the orientation of the arc (clock wise/counter clock wise).
  72701. */
  72702. orientation: Orientation;
  72703. /**
  72704. * Creates an Arc object from the three given points : start, middle and end.
  72705. * @param startPoint Defines the start point of the arc
  72706. * @param midPoint Defines the midlle point of the arc
  72707. * @param endPoint Defines the end point of the arc
  72708. */
  72709. constructor(
  72710. /** Defines the start point of the arc */
  72711. startPoint: Vector2,
  72712. /** Defines the mid point of the arc */
  72713. midPoint: Vector2,
  72714. /** Defines the end point of the arc */
  72715. endPoint: Vector2);
  72716. }
  72717. /**
  72718. * Represents a 2D path made up of multiple 2D points
  72719. */
  72720. export class Path2 {
  72721. private _points;
  72722. private _length;
  72723. /**
  72724. * If the path start and end point are the same
  72725. */
  72726. closed: boolean;
  72727. /**
  72728. * Creates a Path2 object from the starting 2D coordinates x and y.
  72729. * @param x the starting points x value
  72730. * @param y the starting points y value
  72731. */
  72732. constructor(x: number, y: number);
  72733. /**
  72734. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72735. * @param x the added points x value
  72736. * @param y the added points y value
  72737. * @returns the updated Path2.
  72738. */
  72739. addLineTo(x: number, y: number): Path2;
  72740. /**
  72741. * 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.
  72742. * @param midX middle point x value
  72743. * @param midY middle point y value
  72744. * @param endX end point x value
  72745. * @param endY end point y value
  72746. * @param numberOfSegments (default: 36)
  72747. * @returns the updated Path2.
  72748. */
  72749. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72750. /**
  72751. * Closes the Path2.
  72752. * @returns the Path2.
  72753. */
  72754. close(): Path2;
  72755. /**
  72756. * Gets the sum of the distance between each sequential point in the path
  72757. * @returns the Path2 total length (float).
  72758. */
  72759. length(): number;
  72760. /**
  72761. * Gets the points which construct the path
  72762. * @returns the Path2 internal array of points.
  72763. */
  72764. getPoints(): Vector2[];
  72765. /**
  72766. * Retreives the point at the distance aways from the starting point
  72767. * @param normalizedLengthPosition the length along the path to retreive the point from
  72768. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72769. */
  72770. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72771. /**
  72772. * Creates a new path starting from an x and y position
  72773. * @param x starting x value
  72774. * @param y starting y value
  72775. * @returns a new Path2 starting at the coordinates (x, y).
  72776. */
  72777. static StartingAt(x: number, y: number): Path2;
  72778. }
  72779. /**
  72780. * Represents a 3D path made up of multiple 3D points
  72781. */
  72782. export class Path3D {
  72783. /**
  72784. * an array of Vector3, the curve axis of the Path3D
  72785. */
  72786. path: Vector3[];
  72787. private _curve;
  72788. private _distances;
  72789. private _tangents;
  72790. private _normals;
  72791. private _binormals;
  72792. private _raw;
  72793. /**
  72794. * new Path3D(path, normal, raw)
  72795. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72796. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72797. * @param path an array of Vector3, the curve axis of the Path3D
  72798. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72799. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72800. */
  72801. constructor(
  72802. /**
  72803. * an array of Vector3, the curve axis of the Path3D
  72804. */
  72805. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72806. /**
  72807. * Returns the Path3D array of successive Vector3 designing its curve.
  72808. * @returns the Path3D array of successive Vector3 designing its curve.
  72809. */
  72810. getCurve(): Vector3[];
  72811. /**
  72812. * Returns an array populated with tangent vectors on each Path3D curve point.
  72813. * @returns an array populated with tangent vectors on each Path3D curve point.
  72814. */
  72815. getTangents(): Vector3[];
  72816. /**
  72817. * Returns an array populated with normal vectors on each Path3D curve point.
  72818. * @returns an array populated with normal vectors on each Path3D curve point.
  72819. */
  72820. getNormals(): Vector3[];
  72821. /**
  72822. * Returns an array populated with binormal vectors on each Path3D curve point.
  72823. * @returns an array populated with binormal vectors on each Path3D curve point.
  72824. */
  72825. getBinormals(): Vector3[];
  72826. /**
  72827. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72828. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72829. */
  72830. getDistances(): number[];
  72831. /**
  72832. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72833. * @param path path which all values are copied into the curves points
  72834. * @param firstNormal which should be projected onto the curve
  72835. * @returns the same object updated.
  72836. */
  72837. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72838. private _compute;
  72839. private _getFirstNonNullVector;
  72840. private _getLastNonNullVector;
  72841. private _normalVector;
  72842. }
  72843. /**
  72844. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72845. * A Curve3 is designed from a series of successive Vector3.
  72846. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72847. */
  72848. export class Curve3 {
  72849. private _points;
  72850. private _length;
  72851. /**
  72852. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72853. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72854. * @param v1 (Vector3) the control point
  72855. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72856. * @param nbPoints (integer) the wanted number of points in the curve
  72857. * @returns the created Curve3
  72858. */
  72859. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72860. /**
  72861. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72862. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72863. * @param v1 (Vector3) the first control point
  72864. * @param v2 (Vector3) the second control point
  72865. * @param v3 (Vector3) the end point of the Cubic Bezier
  72866. * @param nbPoints (integer) the wanted number of points in the curve
  72867. * @returns the created Curve3
  72868. */
  72869. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72870. /**
  72871. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72872. * @param p1 (Vector3) the origin point of the Hermite Spline
  72873. * @param t1 (Vector3) the tangent vector at the origin point
  72874. * @param p2 (Vector3) the end point of the Hermite Spline
  72875. * @param t2 (Vector3) the tangent vector at the end point
  72876. * @param nbPoints (integer) the wanted number of points in the curve
  72877. * @returns the created Curve3
  72878. */
  72879. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72880. /**
  72881. * Returns a Curve3 object along a CatmullRom Spline curve :
  72882. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72883. * @param nbPoints (integer) the wanted number of points between each curve control points
  72884. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72885. * @returns the created Curve3
  72886. */
  72887. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72888. /**
  72889. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72890. * A Curve3 is designed from a series of successive Vector3.
  72891. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72892. * @param points points which make up the curve
  72893. */
  72894. constructor(points: Vector3[]);
  72895. /**
  72896. * @returns the Curve3 stored array of successive Vector3
  72897. */
  72898. getPoints(): Vector3[];
  72899. /**
  72900. * @returns the computed length (float) of the curve.
  72901. */
  72902. length(): number;
  72903. /**
  72904. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72905. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72906. * curveA and curveB keep unchanged.
  72907. * @param curve the curve to continue from this curve
  72908. * @returns the newly constructed curve
  72909. */
  72910. continue(curve: DeepImmutable<Curve3>): Curve3;
  72911. private _computeLength;
  72912. }
  72913. }
  72914. declare module BABYLON {
  72915. /**
  72916. * This represents the main contract an easing function should follow.
  72917. * Easing functions are used throughout the animation system.
  72918. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72919. */
  72920. export interface IEasingFunction {
  72921. /**
  72922. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72923. * of the easing function.
  72924. * The link below provides some of the most common examples of easing functions.
  72925. * @see https://easings.net/
  72926. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72927. * @returns the corresponding value on the curve defined by the easing function
  72928. */
  72929. ease(gradient: number): number;
  72930. }
  72931. /**
  72932. * Base class used for every default easing function.
  72933. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72934. */
  72935. export class EasingFunction implements IEasingFunction {
  72936. /**
  72937. * Interpolation follows the mathematical formula associated with the easing function.
  72938. */
  72939. static readonly EASINGMODE_EASEIN: number;
  72940. /**
  72941. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72942. */
  72943. static readonly EASINGMODE_EASEOUT: number;
  72944. /**
  72945. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72946. */
  72947. static readonly EASINGMODE_EASEINOUT: number;
  72948. private _easingMode;
  72949. /**
  72950. * Sets the easing mode of the current function.
  72951. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72952. */
  72953. setEasingMode(easingMode: number): void;
  72954. /**
  72955. * Gets the current easing mode.
  72956. * @returns the easing mode
  72957. */
  72958. getEasingMode(): number;
  72959. /**
  72960. * @hidden
  72961. */
  72962. easeInCore(gradient: number): number;
  72963. /**
  72964. * Given an input gradient between 0 and 1, this returns the corresponding value
  72965. * of the easing function.
  72966. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72967. * @returns the corresponding value on the curve defined by the easing function
  72968. */
  72969. ease(gradient: number): number;
  72970. }
  72971. /**
  72972. * Easing function with a circle shape (see link below).
  72973. * @see https://easings.net/#easeInCirc
  72974. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72975. */
  72976. export class CircleEase extends EasingFunction implements IEasingFunction {
  72977. /** @hidden */
  72978. easeInCore(gradient: number): number;
  72979. }
  72980. /**
  72981. * Easing function with a ease back shape (see link below).
  72982. * @see https://easings.net/#easeInBack
  72983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72984. */
  72985. export class BackEase extends EasingFunction implements IEasingFunction {
  72986. /** Defines the amplitude of the function */
  72987. amplitude: number;
  72988. /**
  72989. * Instantiates a back ease easing
  72990. * @see https://easings.net/#easeInBack
  72991. * @param amplitude Defines the amplitude of the function
  72992. */
  72993. constructor(
  72994. /** Defines the amplitude of the function */
  72995. amplitude?: number);
  72996. /** @hidden */
  72997. easeInCore(gradient: number): number;
  72998. }
  72999. /**
  73000. * Easing function with a bouncing shape (see link below).
  73001. * @see https://easings.net/#easeInBounce
  73002. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73003. */
  73004. export class BounceEase extends EasingFunction implements IEasingFunction {
  73005. /** Defines the number of bounces */
  73006. bounces: number;
  73007. /** Defines the amplitude of the bounce */
  73008. bounciness: number;
  73009. /**
  73010. * Instantiates a bounce easing
  73011. * @see https://easings.net/#easeInBounce
  73012. * @param bounces Defines the number of bounces
  73013. * @param bounciness Defines the amplitude of the bounce
  73014. */
  73015. constructor(
  73016. /** Defines the number of bounces */
  73017. bounces?: number,
  73018. /** Defines the amplitude of the bounce */
  73019. bounciness?: number);
  73020. /** @hidden */
  73021. easeInCore(gradient: number): number;
  73022. }
  73023. /**
  73024. * Easing function with a power of 3 shape (see link below).
  73025. * @see https://easings.net/#easeInCubic
  73026. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73027. */
  73028. export class CubicEase extends EasingFunction implements IEasingFunction {
  73029. /** @hidden */
  73030. easeInCore(gradient: number): number;
  73031. }
  73032. /**
  73033. * Easing function with an elastic shape (see link below).
  73034. * @see https://easings.net/#easeInElastic
  73035. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73036. */
  73037. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73038. /** Defines the number of oscillations*/
  73039. oscillations: number;
  73040. /** Defines the amplitude of the oscillations*/
  73041. springiness: number;
  73042. /**
  73043. * Instantiates an elastic easing function
  73044. * @see https://easings.net/#easeInElastic
  73045. * @param oscillations Defines the number of oscillations
  73046. * @param springiness Defines the amplitude of the oscillations
  73047. */
  73048. constructor(
  73049. /** Defines the number of oscillations*/
  73050. oscillations?: number,
  73051. /** Defines the amplitude of the oscillations*/
  73052. springiness?: number);
  73053. /** @hidden */
  73054. easeInCore(gradient: number): number;
  73055. }
  73056. /**
  73057. * Easing function with an exponential shape (see link below).
  73058. * @see https://easings.net/#easeInExpo
  73059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73060. */
  73061. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73062. /** Defines the exponent of the function */
  73063. exponent: number;
  73064. /**
  73065. * Instantiates an exponential easing function
  73066. * @see https://easings.net/#easeInExpo
  73067. * @param exponent Defines the exponent of the function
  73068. */
  73069. constructor(
  73070. /** Defines the exponent of the function */
  73071. exponent?: number);
  73072. /** @hidden */
  73073. easeInCore(gradient: number): number;
  73074. }
  73075. /**
  73076. * Easing function with a power shape (see link below).
  73077. * @see https://easings.net/#easeInQuad
  73078. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73079. */
  73080. export class PowerEase extends EasingFunction implements IEasingFunction {
  73081. /** Defines the power of the function */
  73082. power: number;
  73083. /**
  73084. * Instantiates an power base easing function
  73085. * @see https://easings.net/#easeInQuad
  73086. * @param power Defines the power of the function
  73087. */
  73088. constructor(
  73089. /** Defines the power of the function */
  73090. power?: number);
  73091. /** @hidden */
  73092. easeInCore(gradient: number): number;
  73093. }
  73094. /**
  73095. * Easing function with a power of 2 shape (see link below).
  73096. * @see https://easings.net/#easeInQuad
  73097. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73098. */
  73099. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73100. /** @hidden */
  73101. easeInCore(gradient: number): number;
  73102. }
  73103. /**
  73104. * Easing function with a power of 4 shape (see link below).
  73105. * @see https://easings.net/#easeInQuart
  73106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73107. */
  73108. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73109. /** @hidden */
  73110. easeInCore(gradient: number): number;
  73111. }
  73112. /**
  73113. * Easing function with a power of 5 shape (see link below).
  73114. * @see https://easings.net/#easeInQuint
  73115. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73116. */
  73117. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73118. /** @hidden */
  73119. easeInCore(gradient: number): number;
  73120. }
  73121. /**
  73122. * Easing function with a sin shape (see link below).
  73123. * @see https://easings.net/#easeInSine
  73124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73125. */
  73126. export class SineEase extends EasingFunction implements IEasingFunction {
  73127. /** @hidden */
  73128. easeInCore(gradient: number): number;
  73129. }
  73130. /**
  73131. * Easing function with a bezier shape (see link below).
  73132. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73134. */
  73135. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73136. /** Defines the x component of the start tangent in the bezier curve */
  73137. x1: number;
  73138. /** Defines the y component of the start tangent in the bezier curve */
  73139. y1: number;
  73140. /** Defines the x component of the end tangent in the bezier curve */
  73141. x2: number;
  73142. /** Defines the y component of the end tangent in the bezier curve */
  73143. y2: number;
  73144. /**
  73145. * Instantiates a bezier function
  73146. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73147. * @param x1 Defines the x component of the start tangent in the bezier curve
  73148. * @param y1 Defines the y component of the start tangent in the bezier curve
  73149. * @param x2 Defines the x component of the end tangent in the bezier curve
  73150. * @param y2 Defines the y component of the end tangent in the bezier curve
  73151. */
  73152. constructor(
  73153. /** Defines the x component of the start tangent in the bezier curve */
  73154. x1?: number,
  73155. /** Defines the y component of the start tangent in the bezier curve */
  73156. y1?: number,
  73157. /** Defines the x component of the end tangent in the bezier curve */
  73158. x2?: number,
  73159. /** Defines the y component of the end tangent in the bezier curve */
  73160. y2?: number);
  73161. /** @hidden */
  73162. easeInCore(gradient: number): number;
  73163. }
  73164. }
  73165. declare module BABYLON {
  73166. /**
  73167. * Class used to hold a RBG color
  73168. */
  73169. export class Color3 {
  73170. /**
  73171. * Defines the red component (between 0 and 1, default is 0)
  73172. */
  73173. r: number;
  73174. /**
  73175. * Defines the green component (between 0 and 1, default is 0)
  73176. */
  73177. g: number;
  73178. /**
  73179. * Defines the blue component (between 0 and 1, default is 0)
  73180. */
  73181. b: number;
  73182. /**
  73183. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73184. * @param r defines the red component (between 0 and 1, default is 0)
  73185. * @param g defines the green component (between 0 and 1, default is 0)
  73186. * @param b defines the blue component (between 0 and 1, default is 0)
  73187. */
  73188. constructor(
  73189. /**
  73190. * Defines the red component (between 0 and 1, default is 0)
  73191. */
  73192. r?: number,
  73193. /**
  73194. * Defines the green component (between 0 and 1, default is 0)
  73195. */
  73196. g?: number,
  73197. /**
  73198. * Defines the blue component (between 0 and 1, default is 0)
  73199. */
  73200. b?: number);
  73201. /**
  73202. * Creates a string with the Color3 current values
  73203. * @returns the string representation of the Color3 object
  73204. */
  73205. toString(): string;
  73206. /**
  73207. * Returns the string "Color3"
  73208. * @returns "Color3"
  73209. */
  73210. getClassName(): string;
  73211. /**
  73212. * Compute the Color3 hash code
  73213. * @returns an unique number that can be used to hash Color3 objects
  73214. */
  73215. getHashCode(): number;
  73216. /**
  73217. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73218. * @param array defines the array where to store the r,g,b components
  73219. * @param index defines an optional index in the target array to define where to start storing values
  73220. * @returns the current Color3 object
  73221. */
  73222. toArray(array: FloatArray, index?: number): Color3;
  73223. /**
  73224. * Returns a new Color4 object from the current Color3 and the given alpha
  73225. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73226. * @returns a new Color4 object
  73227. */
  73228. toColor4(alpha?: number): Color4;
  73229. /**
  73230. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73231. * @returns the new array
  73232. */
  73233. asArray(): number[];
  73234. /**
  73235. * Returns the luminance value
  73236. * @returns a float value
  73237. */
  73238. toLuminance(): number;
  73239. /**
  73240. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73241. * @param otherColor defines the second operand
  73242. * @returns the new Color3 object
  73243. */
  73244. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73245. /**
  73246. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73247. * @param otherColor defines the second operand
  73248. * @param result defines the Color3 object where to store the result
  73249. * @returns the current Color3
  73250. */
  73251. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73252. /**
  73253. * Determines equality between Color3 objects
  73254. * @param otherColor defines the second operand
  73255. * @returns true if the rgb values are equal to the given ones
  73256. */
  73257. equals(otherColor: DeepImmutable<Color3>): boolean;
  73258. /**
  73259. * Determines equality between the current Color3 object and a set of r,b,g values
  73260. * @param r defines the red component to check
  73261. * @param g defines the green component to check
  73262. * @param b defines the blue component to check
  73263. * @returns true if the rgb values are equal to the given ones
  73264. */
  73265. equalsFloats(r: number, g: number, b: number): boolean;
  73266. /**
  73267. * Multiplies in place each rgb value by scale
  73268. * @param scale defines the scaling factor
  73269. * @returns the updated Color3
  73270. */
  73271. scale(scale: number): Color3;
  73272. /**
  73273. * Multiplies the rgb values by scale and stores the result into "result"
  73274. * @param scale defines the scaling factor
  73275. * @param result defines the Color3 object where to store the result
  73276. * @returns the unmodified current Color3
  73277. */
  73278. scaleToRef(scale: number, result: Color3): Color3;
  73279. /**
  73280. * Scale the current Color3 values by a factor and add the result to a given Color3
  73281. * @param scale defines the scale factor
  73282. * @param result defines color to store the result into
  73283. * @returns the unmodified current Color3
  73284. */
  73285. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73286. /**
  73287. * Clamps the rgb values by the min and max values and stores the result into "result"
  73288. * @param min defines minimum clamping value (default is 0)
  73289. * @param max defines maximum clamping value (default is 1)
  73290. * @param result defines color to store the result into
  73291. * @returns the original Color3
  73292. */
  73293. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73294. /**
  73295. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73296. * @param otherColor defines the second operand
  73297. * @returns the new Color3
  73298. */
  73299. add(otherColor: DeepImmutable<Color3>): Color3;
  73300. /**
  73301. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73302. * @param otherColor defines the second operand
  73303. * @param result defines Color3 object to store the result into
  73304. * @returns the unmodified current Color3
  73305. */
  73306. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73307. /**
  73308. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73309. * @param otherColor defines the second operand
  73310. * @returns the new Color3
  73311. */
  73312. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73313. /**
  73314. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73315. * @param otherColor defines the second operand
  73316. * @param result defines Color3 object to store the result into
  73317. * @returns the unmodified current Color3
  73318. */
  73319. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73320. /**
  73321. * Copy the current object
  73322. * @returns a new Color3 copied the current one
  73323. */
  73324. clone(): Color3;
  73325. /**
  73326. * Copies the rgb values from the source in the current Color3
  73327. * @param source defines the source Color3 object
  73328. * @returns the updated Color3 object
  73329. */
  73330. copyFrom(source: DeepImmutable<Color3>): Color3;
  73331. /**
  73332. * Updates the Color3 rgb values from the given floats
  73333. * @param r defines the red component to read from
  73334. * @param g defines the green component to read from
  73335. * @param b defines the blue component to read from
  73336. * @returns the current Color3 object
  73337. */
  73338. copyFromFloats(r: number, g: number, b: number): Color3;
  73339. /**
  73340. * Updates the Color3 rgb values from the given floats
  73341. * @param r defines the red component to read from
  73342. * @param g defines the green component to read from
  73343. * @param b defines the blue component to read from
  73344. * @returns the current Color3 object
  73345. */
  73346. set(r: number, g: number, b: number): Color3;
  73347. /**
  73348. * Compute the Color3 hexadecimal code as a string
  73349. * @returns a string containing the hexadecimal representation of the Color3 object
  73350. */
  73351. toHexString(): string;
  73352. /**
  73353. * Computes a new Color3 converted from the current one to linear space
  73354. * @returns a new Color3 object
  73355. */
  73356. toLinearSpace(): Color3;
  73357. /**
  73358. * Converts current color in rgb space to HSV values
  73359. * @returns a new color3 representing the HSV values
  73360. */
  73361. toHSV(): Color3;
  73362. /**
  73363. * Converts current color in rgb space to HSV values
  73364. * @param result defines the Color3 where to store the HSV values
  73365. */
  73366. toHSVToRef(result: Color3): void;
  73367. /**
  73368. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73369. * @param convertedColor defines the Color3 object where to store the linear space version
  73370. * @returns the unmodified Color3
  73371. */
  73372. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73373. /**
  73374. * Computes a new Color3 converted from the current one to gamma space
  73375. * @returns a new Color3 object
  73376. */
  73377. toGammaSpace(): Color3;
  73378. /**
  73379. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73380. * @param convertedColor defines the Color3 object where to store the gamma space version
  73381. * @returns the unmodified Color3
  73382. */
  73383. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73384. private static _BlackReadOnly;
  73385. /**
  73386. * Convert Hue, saturation and value to a Color3 (RGB)
  73387. * @param hue defines the hue
  73388. * @param saturation defines the saturation
  73389. * @param value defines the value
  73390. * @param result defines the Color3 where to store the RGB values
  73391. */
  73392. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73393. /**
  73394. * Creates a new Color3 from the string containing valid hexadecimal values
  73395. * @param hex defines a string containing valid hexadecimal values
  73396. * @returns a new Color3 object
  73397. */
  73398. static FromHexString(hex: string): Color3;
  73399. /**
  73400. * Creates a new Color3 from the starting index of the given array
  73401. * @param array defines the source array
  73402. * @param offset defines an offset in the source array
  73403. * @returns a new Color3 object
  73404. */
  73405. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73406. /**
  73407. * Creates a new Color3 from integer values (< 256)
  73408. * @param r defines the red component to read from (value between 0 and 255)
  73409. * @param g defines the green component to read from (value between 0 and 255)
  73410. * @param b defines the blue component to read from (value between 0 and 255)
  73411. * @returns a new Color3 object
  73412. */
  73413. static FromInts(r: number, g: number, b: number): Color3;
  73414. /**
  73415. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73416. * @param start defines the start Color3 value
  73417. * @param end defines the end Color3 value
  73418. * @param amount defines the gradient value between start and end
  73419. * @returns a new Color3 object
  73420. */
  73421. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73422. /**
  73423. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73424. * @param left defines the start value
  73425. * @param right defines the end value
  73426. * @param amount defines the gradient factor
  73427. * @param result defines the Color3 object where to store the result
  73428. */
  73429. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73430. /**
  73431. * Returns a Color3 value containing a red color
  73432. * @returns a new Color3 object
  73433. */
  73434. static Red(): Color3;
  73435. /**
  73436. * Returns a Color3 value containing a green color
  73437. * @returns a new Color3 object
  73438. */
  73439. static Green(): Color3;
  73440. /**
  73441. * Returns a Color3 value containing a blue color
  73442. * @returns a new Color3 object
  73443. */
  73444. static Blue(): Color3;
  73445. /**
  73446. * Returns a Color3 value containing a black color
  73447. * @returns a new Color3 object
  73448. */
  73449. static Black(): Color3;
  73450. /**
  73451. * Gets a Color3 value containing a black color that must not be updated
  73452. */
  73453. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73454. /**
  73455. * Returns a Color3 value containing a white color
  73456. * @returns a new Color3 object
  73457. */
  73458. static White(): Color3;
  73459. /**
  73460. * Returns a Color3 value containing a purple color
  73461. * @returns a new Color3 object
  73462. */
  73463. static Purple(): Color3;
  73464. /**
  73465. * Returns a Color3 value containing a magenta color
  73466. * @returns a new Color3 object
  73467. */
  73468. static Magenta(): Color3;
  73469. /**
  73470. * Returns a Color3 value containing a yellow color
  73471. * @returns a new Color3 object
  73472. */
  73473. static Yellow(): Color3;
  73474. /**
  73475. * Returns a Color3 value containing a gray color
  73476. * @returns a new Color3 object
  73477. */
  73478. static Gray(): Color3;
  73479. /**
  73480. * Returns a Color3 value containing a teal color
  73481. * @returns a new Color3 object
  73482. */
  73483. static Teal(): Color3;
  73484. /**
  73485. * Returns a Color3 value containing a random color
  73486. * @returns a new Color3 object
  73487. */
  73488. static Random(): Color3;
  73489. }
  73490. /**
  73491. * Class used to hold a RBGA color
  73492. */
  73493. export class Color4 {
  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. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73512. * @param r defines the red component (between 0 and 1, default is 0)
  73513. * @param g defines the green component (between 0 and 1, default is 0)
  73514. * @param b defines the blue component (between 0 and 1, default is 0)
  73515. * @param a defines the alpha component (between 0 and 1, default is 1)
  73516. */
  73517. constructor(
  73518. /**
  73519. * Defines the red component (between 0 and 1, default is 0)
  73520. */
  73521. r?: number,
  73522. /**
  73523. * Defines the green component (between 0 and 1, default is 0)
  73524. */
  73525. g?: number,
  73526. /**
  73527. * Defines the blue component (between 0 and 1, default is 0)
  73528. */
  73529. b?: number,
  73530. /**
  73531. * Defines the alpha component (between 0 and 1, default is 1)
  73532. */
  73533. a?: number);
  73534. /**
  73535. * Adds in place the given Color4 values to the current Color4 object
  73536. * @param right defines the second operand
  73537. * @returns the current updated Color4 object
  73538. */
  73539. addInPlace(right: DeepImmutable<Color4>): Color4;
  73540. /**
  73541. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73542. * @returns the new array
  73543. */
  73544. asArray(): number[];
  73545. /**
  73546. * Stores from the starting index in the given array the Color4 successive values
  73547. * @param array defines the array where to store the r,g,b components
  73548. * @param index defines an optional index in the target array to define where to start storing values
  73549. * @returns the current Color4 object
  73550. */
  73551. toArray(array: number[], index?: number): Color4;
  73552. /**
  73553. * Determines equality between Color4 objects
  73554. * @param otherColor defines the second operand
  73555. * @returns true if the rgba values are equal to the given ones
  73556. */
  73557. equals(otherColor: DeepImmutable<Color4>): boolean;
  73558. /**
  73559. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73560. * @param right defines the second operand
  73561. * @returns a new Color4 object
  73562. */
  73563. add(right: DeepImmutable<Color4>): Color4;
  73564. /**
  73565. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73566. * @param right defines the second operand
  73567. * @returns a new Color4 object
  73568. */
  73569. subtract(right: DeepImmutable<Color4>): Color4;
  73570. /**
  73571. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73572. * @param right defines the second operand
  73573. * @param result defines the Color4 object where to store the result
  73574. * @returns the current Color4 object
  73575. */
  73576. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73577. /**
  73578. * Creates a new Color4 with the current Color4 values multiplied by scale
  73579. * @param scale defines the scaling factor to apply
  73580. * @returns a new Color4 object
  73581. */
  73582. scale(scale: number): Color4;
  73583. /**
  73584. * Multiplies the current Color4 values by scale and stores the result in "result"
  73585. * @param scale defines the scaling factor to apply
  73586. * @param result defines the Color4 object where to store the result
  73587. * @returns the current unmodified Color4
  73588. */
  73589. scaleToRef(scale: number, result: Color4): Color4;
  73590. /**
  73591. * Scale the current Color4 values by a factor and add the result to a given Color4
  73592. * @param scale defines the scale factor
  73593. * @param result defines the Color4 object where to store the result
  73594. * @returns the unmodified current Color4
  73595. */
  73596. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73597. /**
  73598. * Clamps the rgb values by the min and max values and stores the result into "result"
  73599. * @param min defines minimum clamping value (default is 0)
  73600. * @param max defines maximum clamping value (default is 1)
  73601. * @param result defines color to store the result into.
  73602. * @returns the cuurent Color4
  73603. */
  73604. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73605. /**
  73606. * Multipy an Color4 value by another and return a new Color4 object
  73607. * @param color defines the Color4 value to multiply by
  73608. * @returns a new Color4 object
  73609. */
  73610. multiply(color: Color4): Color4;
  73611. /**
  73612. * Multipy a Color4 value by another and push the result in a reference value
  73613. * @param color defines the Color4 value to multiply by
  73614. * @param result defines the Color4 to fill the result in
  73615. * @returns the result Color4
  73616. */
  73617. multiplyToRef(color: Color4, result: Color4): Color4;
  73618. /**
  73619. * Creates a string with the Color4 current values
  73620. * @returns the string representation of the Color4 object
  73621. */
  73622. toString(): string;
  73623. /**
  73624. * Returns the string "Color4"
  73625. * @returns "Color4"
  73626. */
  73627. getClassName(): string;
  73628. /**
  73629. * Compute the Color4 hash code
  73630. * @returns an unique number that can be used to hash Color4 objects
  73631. */
  73632. getHashCode(): number;
  73633. /**
  73634. * Creates a new Color4 copied from the current one
  73635. * @returns a new Color4 object
  73636. */
  73637. clone(): Color4;
  73638. /**
  73639. * Copies the given Color4 values into the current one
  73640. * @param source defines the source Color4 object
  73641. * @returns the current updated Color4 object
  73642. */
  73643. copyFrom(source: Color4): Color4;
  73644. /**
  73645. * Copies the given float values into the current one
  73646. * @param r defines the red component to read from
  73647. * @param g defines the green component to read from
  73648. * @param b defines the blue component to read from
  73649. * @param a defines the alpha component to read from
  73650. * @returns the current updated Color4 object
  73651. */
  73652. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73653. /**
  73654. * Copies the given float values into the current one
  73655. * @param r defines the red component to read from
  73656. * @param g defines the green component to read from
  73657. * @param b defines the blue component to read from
  73658. * @param a defines the alpha component to read from
  73659. * @returns the current updated Color4 object
  73660. */
  73661. set(r: number, g: number, b: number, a: number): Color4;
  73662. /**
  73663. * Compute the Color4 hexadecimal code as a string
  73664. * @returns a string containing the hexadecimal representation of the Color4 object
  73665. */
  73666. toHexString(): string;
  73667. /**
  73668. * Computes a new Color4 converted from the current one to linear space
  73669. * @returns a new Color4 object
  73670. */
  73671. toLinearSpace(): Color4;
  73672. /**
  73673. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73674. * @param convertedColor defines the Color4 object where to store the linear space version
  73675. * @returns the unmodified Color4
  73676. */
  73677. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73678. /**
  73679. * Computes a new Color4 converted from the current one to gamma space
  73680. * @returns a new Color4 object
  73681. */
  73682. toGammaSpace(): Color4;
  73683. /**
  73684. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73685. * @param convertedColor defines the Color4 object where to store the gamma space version
  73686. * @returns the unmodified Color4
  73687. */
  73688. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73689. /**
  73690. * Creates a new Color4 from the string containing valid hexadecimal values
  73691. * @param hex defines a string containing valid hexadecimal values
  73692. * @returns a new Color4 object
  73693. */
  73694. static FromHexString(hex: string): Color4;
  73695. /**
  73696. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73697. * @param left defines the start value
  73698. * @param right defines the end value
  73699. * @param amount defines the gradient factor
  73700. * @returns a new Color4 object
  73701. */
  73702. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73703. /**
  73704. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73705. * @param left defines the start value
  73706. * @param right defines the end value
  73707. * @param amount defines the gradient factor
  73708. * @param result defines the Color4 object where to store data
  73709. */
  73710. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73711. /**
  73712. * Creates a new Color4 from a Color3 and an alpha value
  73713. * @param color3 defines the source Color3 to read from
  73714. * @param alpha defines the alpha component (1.0 by default)
  73715. * @returns a new Color4 object
  73716. */
  73717. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73718. /**
  73719. * Creates a new Color4 from the starting index element of the given array
  73720. * @param array defines the source array to read from
  73721. * @param offset defines the offset in the source array
  73722. * @returns a new Color4 object
  73723. */
  73724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73725. /**
  73726. * Creates a new Color3 from integer values (< 256)
  73727. * @param r defines the red component to read from (value between 0 and 255)
  73728. * @param g defines the green component to read from (value between 0 and 255)
  73729. * @param b defines the blue component to read from (value between 0 and 255)
  73730. * @param a defines the alpha component to read from (value between 0 and 255)
  73731. * @returns a new Color3 object
  73732. */
  73733. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73734. /**
  73735. * Check the content of a given array and convert it to an array containing RGBA data
  73736. * If the original array was already containing count * 4 values then it is returned directly
  73737. * @param colors defines the array to check
  73738. * @param count defines the number of RGBA data to expect
  73739. * @returns an array containing count * 4 values (RGBA)
  73740. */
  73741. static CheckColors4(colors: number[], count: number): number[];
  73742. }
  73743. /**
  73744. * @hidden
  73745. */
  73746. export class TmpColors {
  73747. static Color3: Color3[];
  73748. static Color4: Color4[];
  73749. }
  73750. }
  73751. declare module BABYLON {
  73752. /**
  73753. * Defines an interface which represents an animation key frame
  73754. */
  73755. export interface IAnimationKey {
  73756. /**
  73757. * Frame of the key frame
  73758. */
  73759. frame: number;
  73760. /**
  73761. * Value at the specifies key frame
  73762. */
  73763. value: any;
  73764. /**
  73765. * The input tangent for the cubic hermite spline
  73766. */
  73767. inTangent?: any;
  73768. /**
  73769. * The output tangent for the cubic hermite spline
  73770. */
  73771. outTangent?: any;
  73772. /**
  73773. * The animation interpolation type
  73774. */
  73775. interpolation?: AnimationKeyInterpolation;
  73776. }
  73777. /**
  73778. * Enum for the animation key frame interpolation type
  73779. */
  73780. export enum AnimationKeyInterpolation {
  73781. /**
  73782. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73783. */
  73784. STEP = 1
  73785. }
  73786. }
  73787. declare module BABYLON {
  73788. /**
  73789. * Represents the range of an animation
  73790. */
  73791. export class AnimationRange {
  73792. /**The name of the animation range**/
  73793. name: string;
  73794. /**The starting frame of the animation */
  73795. from: number;
  73796. /**The ending frame of the animation*/
  73797. to: number;
  73798. /**
  73799. * Initializes the range of an animation
  73800. * @param name The name of the animation range
  73801. * @param from The starting frame of the animation
  73802. * @param to The ending frame of the animation
  73803. */
  73804. constructor(
  73805. /**The name of the animation range**/
  73806. name: string,
  73807. /**The starting frame of the animation */
  73808. from: number,
  73809. /**The ending frame of the animation*/
  73810. to: number);
  73811. /**
  73812. * Makes a copy of the animation range
  73813. * @returns A copy of the animation range
  73814. */
  73815. clone(): AnimationRange;
  73816. }
  73817. }
  73818. declare module BABYLON {
  73819. /**
  73820. * Composed of a frame, and an action function
  73821. */
  73822. export class AnimationEvent {
  73823. /** The frame for which the event is triggered **/
  73824. frame: number;
  73825. /** The event to perform when triggered **/
  73826. action: (currentFrame: number) => void;
  73827. /** Specifies if the event should be triggered only once**/
  73828. onlyOnce?: boolean | undefined;
  73829. /**
  73830. * Specifies if the animation event is done
  73831. */
  73832. isDone: boolean;
  73833. /**
  73834. * Initializes the animation event
  73835. * @param frame The frame for which the event is triggered
  73836. * @param action The event to perform when triggered
  73837. * @param onlyOnce Specifies if the event should be triggered only once
  73838. */
  73839. constructor(
  73840. /** The frame for which the event is triggered **/
  73841. frame: number,
  73842. /** The event to perform when triggered **/
  73843. action: (currentFrame: number) => void,
  73844. /** Specifies if the event should be triggered only once**/
  73845. onlyOnce?: boolean | undefined);
  73846. /** @hidden */
  73847. _clone(): AnimationEvent;
  73848. }
  73849. }
  73850. declare module BABYLON {
  73851. /**
  73852. * Interface used to define a behavior
  73853. */
  73854. export interface Behavior<T> {
  73855. /** gets or sets behavior's name */
  73856. name: string;
  73857. /**
  73858. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73859. */
  73860. init(): void;
  73861. /**
  73862. * Called when the behavior is attached to a target
  73863. * @param target defines the target where the behavior is attached to
  73864. */
  73865. attach(target: T): void;
  73866. /**
  73867. * Called when the behavior is detached from its target
  73868. */
  73869. detach(): void;
  73870. }
  73871. /**
  73872. * Interface implemented by classes supporting behaviors
  73873. */
  73874. export interface IBehaviorAware<T> {
  73875. /**
  73876. * Attach a behavior
  73877. * @param behavior defines the behavior to attach
  73878. * @returns the current host
  73879. */
  73880. addBehavior(behavior: Behavior<T>): T;
  73881. /**
  73882. * Remove a behavior from the current object
  73883. * @param behavior defines the behavior to detach
  73884. * @returns the current host
  73885. */
  73886. removeBehavior(behavior: Behavior<T>): T;
  73887. /**
  73888. * Gets a behavior using its name to search
  73889. * @param name defines the name to search
  73890. * @returns the behavior or null if not found
  73891. */
  73892. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73893. }
  73894. }
  73895. declare module BABYLON {
  73896. /**
  73897. * Defines an array and its length.
  73898. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73899. */
  73900. export interface ISmartArrayLike<T> {
  73901. /**
  73902. * The data of the array.
  73903. */
  73904. data: Array<T>;
  73905. /**
  73906. * The active length of the array.
  73907. */
  73908. length: number;
  73909. }
  73910. /**
  73911. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73912. */
  73913. export class SmartArray<T> implements ISmartArrayLike<T> {
  73914. /**
  73915. * The full set of data from the array.
  73916. */
  73917. data: Array<T>;
  73918. /**
  73919. * The active length of the array.
  73920. */
  73921. length: number;
  73922. protected _id: number;
  73923. /**
  73924. * Instantiates a Smart Array.
  73925. * @param capacity defines the default capacity of the array.
  73926. */
  73927. constructor(capacity: number);
  73928. /**
  73929. * Pushes a value at the end of the active data.
  73930. * @param value defines the object to push in the array.
  73931. */
  73932. push(value: T): void;
  73933. /**
  73934. * Iterates over the active data and apply the lambda to them.
  73935. * @param func defines the action to apply on each value.
  73936. */
  73937. forEach(func: (content: T) => void): void;
  73938. /**
  73939. * Sorts the full sets of data.
  73940. * @param compareFn defines the comparison function to apply.
  73941. */
  73942. sort(compareFn: (a: T, b: T) => number): void;
  73943. /**
  73944. * Resets the active data to an empty array.
  73945. */
  73946. reset(): void;
  73947. /**
  73948. * Releases all the data from the array as well as the array.
  73949. */
  73950. dispose(): void;
  73951. /**
  73952. * Concats the active data with a given array.
  73953. * @param array defines the data to concatenate with.
  73954. */
  73955. concat(array: any): void;
  73956. /**
  73957. * Returns the position of a value in the active data.
  73958. * @param value defines the value to find the index for
  73959. * @returns the index if found in the active data otherwise -1
  73960. */
  73961. indexOf(value: T): number;
  73962. /**
  73963. * Returns whether an element is part of the active data.
  73964. * @param value defines the value to look for
  73965. * @returns true if found in the active data otherwise false
  73966. */
  73967. contains(value: T): boolean;
  73968. private static _GlobalId;
  73969. }
  73970. /**
  73971. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73972. * The data in this array can only be present once
  73973. */
  73974. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73975. private _duplicateId;
  73976. /**
  73977. * Pushes a value at the end of the active data.
  73978. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73979. * @param value defines the object to push in the array.
  73980. */
  73981. push(value: T): void;
  73982. /**
  73983. * Pushes a value at the end of the active data.
  73984. * If the data is already present, it won t be added again
  73985. * @param value defines the object to push in the array.
  73986. * @returns true if added false if it was already present
  73987. */
  73988. pushNoDuplicate(value: T): boolean;
  73989. /**
  73990. * Resets the active data to an empty array.
  73991. */
  73992. reset(): void;
  73993. /**
  73994. * Concats the active data with a given array.
  73995. * This ensures no dupplicate will be present in the result.
  73996. * @param array defines the data to concatenate with.
  73997. */
  73998. concatWithNoDuplicate(array: any): void;
  73999. }
  74000. }
  74001. declare module BABYLON {
  74002. /**
  74003. * @ignore
  74004. * This is a list of all the different input types that are available in the application.
  74005. * Fo instance: ArcRotateCameraGamepadInput...
  74006. */
  74007. export var CameraInputTypes: {};
  74008. /**
  74009. * This is the contract to implement in order to create a new input class.
  74010. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74011. */
  74012. export interface ICameraInput<TCamera extends Camera> {
  74013. /**
  74014. * Defines the camera the input is attached to.
  74015. */
  74016. camera: Nullable<TCamera>;
  74017. /**
  74018. * Gets the class name of the current intput.
  74019. * @returns the class name
  74020. */
  74021. getClassName(): string;
  74022. /**
  74023. * Get the friendly name associated with the input class.
  74024. * @returns the input friendly name
  74025. */
  74026. getSimpleName(): string;
  74027. /**
  74028. * Attach the input controls to a specific dom element to get the input from.
  74029. * @param element Defines the element the controls should be listened from
  74030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74031. */
  74032. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74033. /**
  74034. * Detach the current controls from the specified dom element.
  74035. * @param element Defines the element to stop listening the inputs from
  74036. */
  74037. detachControl(element: Nullable<HTMLElement>): void;
  74038. /**
  74039. * Update the current camera state depending on the inputs that have been used this frame.
  74040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74041. */
  74042. checkInputs?: () => void;
  74043. }
  74044. /**
  74045. * Represents a map of input types to input instance or input index to input instance.
  74046. */
  74047. export interface CameraInputsMap<TCamera extends Camera> {
  74048. /**
  74049. * Accessor to the input by input type.
  74050. */
  74051. [name: string]: ICameraInput<TCamera>;
  74052. /**
  74053. * Accessor to the input by input index.
  74054. */
  74055. [idx: number]: ICameraInput<TCamera>;
  74056. }
  74057. /**
  74058. * This represents the input manager used within a camera.
  74059. * It helps dealing with all the different kind of input attached to a camera.
  74060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74061. */
  74062. export class CameraInputsManager<TCamera extends Camera> {
  74063. /**
  74064. * Defines the list of inputs attahed to the camera.
  74065. */
  74066. attached: CameraInputsMap<TCamera>;
  74067. /**
  74068. * Defines the dom element the camera is collecting inputs from.
  74069. * This is null if the controls have not been attached.
  74070. */
  74071. attachedElement: Nullable<HTMLElement>;
  74072. /**
  74073. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74074. */
  74075. noPreventDefault: boolean;
  74076. /**
  74077. * Defined the camera the input manager belongs to.
  74078. */
  74079. camera: TCamera;
  74080. /**
  74081. * Update the current camera state depending on the inputs that have been used this frame.
  74082. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74083. */
  74084. checkInputs: () => void;
  74085. /**
  74086. * Instantiate a new Camera Input Manager.
  74087. * @param camera Defines the camera the input manager blongs to
  74088. */
  74089. constructor(camera: TCamera);
  74090. /**
  74091. * Add an input method to a camera
  74092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74093. * @param input camera input method
  74094. */
  74095. add(input: ICameraInput<TCamera>): void;
  74096. /**
  74097. * Remove a specific input method from a camera
  74098. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74099. * @param inputToRemove camera input method
  74100. */
  74101. remove(inputToRemove: ICameraInput<TCamera>): void;
  74102. /**
  74103. * Remove a specific input type from a camera
  74104. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74105. * @param inputType the type of the input to remove
  74106. */
  74107. removeByType(inputType: string): void;
  74108. private _addCheckInputs;
  74109. /**
  74110. * Attach the input controls to the currently attached dom element to listen the events from.
  74111. * @param input Defines the input to attach
  74112. */
  74113. attachInput(input: ICameraInput<TCamera>): void;
  74114. /**
  74115. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74116. * @param element Defines the dom element to collect the events from
  74117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74118. */
  74119. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74120. /**
  74121. * Detach the current manager inputs controls from a specific dom element.
  74122. * @param element Defines the dom element to collect the events from
  74123. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74124. */
  74125. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74126. /**
  74127. * Rebuild the dynamic inputCheck function from the current list of
  74128. * defined inputs in the manager.
  74129. */
  74130. rebuildInputCheck(): void;
  74131. /**
  74132. * Remove all attached input methods from a camera
  74133. */
  74134. clear(): void;
  74135. /**
  74136. * Serialize the current input manager attached to a camera.
  74137. * This ensures than once parsed,
  74138. * the input associated to the camera will be identical to the current ones
  74139. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74140. */
  74141. serialize(serializedCamera: any): void;
  74142. /**
  74143. * Parses an input manager serialized JSON to restore the previous list of inputs
  74144. * and states associated to a camera.
  74145. * @param parsedCamera Defines the JSON to parse
  74146. */
  74147. parse(parsedCamera: any): void;
  74148. }
  74149. }
  74150. declare module BABYLON {
  74151. /**
  74152. * Class used to store data that will be store in GPU memory
  74153. */
  74154. export class Buffer {
  74155. private _engine;
  74156. private _buffer;
  74157. /** @hidden */
  74158. _data: Nullable<DataArray>;
  74159. private _updatable;
  74160. private _instanced;
  74161. private _divisor;
  74162. /**
  74163. * Gets the byte stride.
  74164. */
  74165. readonly byteStride: number;
  74166. /**
  74167. * Constructor
  74168. * @param engine the engine
  74169. * @param data the data to use for this buffer
  74170. * @param updatable whether the data is updatable
  74171. * @param stride the stride (optional)
  74172. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74173. * @param instanced whether the buffer is instanced (optional)
  74174. * @param useBytes set to true if the stride in in bytes (optional)
  74175. * @param divisor sets an optional divisor for instances (1 by default)
  74176. */
  74177. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74178. /**
  74179. * Create a new VertexBuffer based on the current buffer
  74180. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74181. * @param offset defines offset in the buffer (0 by default)
  74182. * @param size defines the size in floats of attributes (position is 3 for instance)
  74183. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74184. * @param instanced defines if the vertex buffer contains indexed data
  74185. * @param useBytes defines if the offset and stride are in bytes *
  74186. * @param divisor sets an optional divisor for instances (1 by default)
  74187. * @returns the new vertex buffer
  74188. */
  74189. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74190. /**
  74191. * Gets a boolean indicating if the Buffer is updatable?
  74192. * @returns true if the buffer is updatable
  74193. */
  74194. isUpdatable(): boolean;
  74195. /**
  74196. * Gets current buffer's data
  74197. * @returns a DataArray or null
  74198. */
  74199. getData(): Nullable<DataArray>;
  74200. /**
  74201. * Gets underlying native buffer
  74202. * @returns underlying native buffer
  74203. */
  74204. getBuffer(): Nullable<DataBuffer>;
  74205. /**
  74206. * Gets the stride in float32 units (i.e. byte stride / 4).
  74207. * May not be an integer if the byte stride is not divisible by 4.
  74208. * DEPRECATED. Use byteStride instead.
  74209. * @returns the stride in float32 units
  74210. */
  74211. getStrideSize(): number;
  74212. /**
  74213. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74214. * @param data defines the data to store
  74215. */
  74216. create(data?: Nullable<DataArray>): void;
  74217. /** @hidden */
  74218. _rebuild(): void;
  74219. /**
  74220. * Update current buffer data
  74221. * @param data defines the data to store
  74222. */
  74223. update(data: DataArray): void;
  74224. /**
  74225. * Updates the data directly.
  74226. * @param data the new data
  74227. * @param offset the new offset
  74228. * @param vertexCount the vertex count (optional)
  74229. * @param useBytes set to true if the offset is in bytes
  74230. */
  74231. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74232. /**
  74233. * Release all resources
  74234. */
  74235. dispose(): void;
  74236. }
  74237. /**
  74238. * Specialized buffer used to store vertex data
  74239. */
  74240. export class VertexBuffer {
  74241. /** @hidden */
  74242. _buffer: Buffer;
  74243. private _kind;
  74244. private _size;
  74245. private _ownsBuffer;
  74246. private _instanced;
  74247. private _instanceDivisor;
  74248. /**
  74249. * The byte type.
  74250. */
  74251. static readonly BYTE: number;
  74252. /**
  74253. * The unsigned byte type.
  74254. */
  74255. static readonly UNSIGNED_BYTE: number;
  74256. /**
  74257. * The short type.
  74258. */
  74259. static readonly SHORT: number;
  74260. /**
  74261. * The unsigned short type.
  74262. */
  74263. static readonly UNSIGNED_SHORT: number;
  74264. /**
  74265. * The integer type.
  74266. */
  74267. static readonly INT: number;
  74268. /**
  74269. * The unsigned integer type.
  74270. */
  74271. static readonly UNSIGNED_INT: number;
  74272. /**
  74273. * The float type.
  74274. */
  74275. static readonly FLOAT: number;
  74276. /**
  74277. * Gets or sets the instance divisor when in instanced mode
  74278. */
  74279. instanceDivisor: number;
  74280. /**
  74281. * Gets the byte stride.
  74282. */
  74283. readonly byteStride: number;
  74284. /**
  74285. * Gets the byte offset.
  74286. */
  74287. readonly byteOffset: number;
  74288. /**
  74289. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74290. */
  74291. readonly normalized: boolean;
  74292. /**
  74293. * Gets the data type of each component in the array.
  74294. */
  74295. readonly type: number;
  74296. /**
  74297. * Constructor
  74298. * @param engine the engine
  74299. * @param data the data to use for this vertex buffer
  74300. * @param kind the vertex buffer kind
  74301. * @param updatable whether the data is updatable
  74302. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74303. * @param stride the stride (optional)
  74304. * @param instanced whether the buffer is instanced (optional)
  74305. * @param offset the offset of the data (optional)
  74306. * @param size the number of components (optional)
  74307. * @param type the type of the component (optional)
  74308. * @param normalized whether the data contains normalized data (optional)
  74309. * @param useBytes set to true if stride and offset are in bytes (optional)
  74310. * @param divisor defines the instance divisor to use (1 by default)
  74311. */
  74312. 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);
  74313. /** @hidden */
  74314. _rebuild(): void;
  74315. /**
  74316. * Returns the kind of the VertexBuffer (string)
  74317. * @returns a string
  74318. */
  74319. getKind(): string;
  74320. /**
  74321. * Gets a boolean indicating if the VertexBuffer is updatable?
  74322. * @returns true if the buffer is updatable
  74323. */
  74324. isUpdatable(): boolean;
  74325. /**
  74326. * Gets current buffer's data
  74327. * @returns a DataArray or null
  74328. */
  74329. getData(): Nullable<DataArray>;
  74330. /**
  74331. * Gets underlying native buffer
  74332. * @returns underlying native buffer
  74333. */
  74334. getBuffer(): Nullable<DataBuffer>;
  74335. /**
  74336. * Gets the stride in float32 units (i.e. byte stride / 4).
  74337. * May not be an integer if the byte stride is not divisible by 4.
  74338. * DEPRECATED. Use byteStride instead.
  74339. * @returns the stride in float32 units
  74340. */
  74341. getStrideSize(): number;
  74342. /**
  74343. * Returns the offset as a multiple of the type byte length.
  74344. * DEPRECATED. Use byteOffset instead.
  74345. * @returns the offset in bytes
  74346. */
  74347. getOffset(): number;
  74348. /**
  74349. * Returns the number of components per vertex attribute (integer)
  74350. * @returns the size in float
  74351. */
  74352. getSize(): number;
  74353. /**
  74354. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74355. * @returns true if this buffer is instanced
  74356. */
  74357. getIsInstanced(): boolean;
  74358. /**
  74359. * Returns the instancing divisor, zero for non-instanced (integer).
  74360. * @returns a number
  74361. */
  74362. getInstanceDivisor(): number;
  74363. /**
  74364. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74365. * @param data defines the data to store
  74366. */
  74367. create(data?: DataArray): void;
  74368. /**
  74369. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74370. * This function will create a new buffer if the current one is not updatable
  74371. * @param data defines the data to store
  74372. */
  74373. update(data: DataArray): void;
  74374. /**
  74375. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74376. * Returns the directly updated WebGLBuffer.
  74377. * @param data the new data
  74378. * @param offset the new offset
  74379. * @param useBytes set to true if the offset is in bytes
  74380. */
  74381. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74382. /**
  74383. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74384. */
  74385. dispose(): void;
  74386. /**
  74387. * Enumerates each value of this vertex buffer as numbers.
  74388. * @param count the number of values to enumerate
  74389. * @param callback the callback function called for each value
  74390. */
  74391. forEach(count: number, callback: (value: number, index: number) => void): void;
  74392. /**
  74393. * Positions
  74394. */
  74395. static readonly PositionKind: string;
  74396. /**
  74397. * Normals
  74398. */
  74399. static readonly NormalKind: string;
  74400. /**
  74401. * Tangents
  74402. */
  74403. static readonly TangentKind: string;
  74404. /**
  74405. * Texture coordinates
  74406. */
  74407. static readonly UVKind: string;
  74408. /**
  74409. * Texture coordinates 2
  74410. */
  74411. static readonly UV2Kind: string;
  74412. /**
  74413. * Texture coordinates 3
  74414. */
  74415. static readonly UV3Kind: string;
  74416. /**
  74417. * Texture coordinates 4
  74418. */
  74419. static readonly UV4Kind: string;
  74420. /**
  74421. * Texture coordinates 5
  74422. */
  74423. static readonly UV5Kind: string;
  74424. /**
  74425. * Texture coordinates 6
  74426. */
  74427. static readonly UV6Kind: string;
  74428. /**
  74429. * Colors
  74430. */
  74431. static readonly ColorKind: string;
  74432. /**
  74433. * Matrix indices (for bones)
  74434. */
  74435. static readonly MatricesIndicesKind: string;
  74436. /**
  74437. * Matrix weights (for bones)
  74438. */
  74439. static readonly MatricesWeightsKind: string;
  74440. /**
  74441. * Additional matrix indices (for bones)
  74442. */
  74443. static readonly MatricesIndicesExtraKind: string;
  74444. /**
  74445. * Additional matrix weights (for bones)
  74446. */
  74447. static readonly MatricesWeightsExtraKind: string;
  74448. /**
  74449. * Deduces the stride given a kind.
  74450. * @param kind The kind string to deduce
  74451. * @returns The deduced stride
  74452. */
  74453. static DeduceStride(kind: string): number;
  74454. /**
  74455. * Gets the byte length of the given type.
  74456. * @param type the type
  74457. * @returns the number of bytes
  74458. */
  74459. static GetTypeByteLength(type: number): number;
  74460. /**
  74461. * Enumerates each value of the given parameters as numbers.
  74462. * @param data the data to enumerate
  74463. * @param byteOffset the byte offset of the data
  74464. * @param byteStride the byte stride of the data
  74465. * @param componentCount the number of components per element
  74466. * @param componentType the type of the component
  74467. * @param count the number of values to enumerate
  74468. * @param normalized whether the data is normalized
  74469. * @param callback the callback function called for each value
  74470. */
  74471. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74472. private static _GetFloatValue;
  74473. }
  74474. }
  74475. declare module BABYLON {
  74476. /**
  74477. * @hidden
  74478. */
  74479. export class IntersectionInfo {
  74480. bu: Nullable<number>;
  74481. bv: Nullable<number>;
  74482. distance: number;
  74483. faceId: number;
  74484. subMeshId: number;
  74485. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74486. }
  74487. }
  74488. declare module BABYLON {
  74489. /**
  74490. * Represens a plane by the equation ax + by + cz + d = 0
  74491. */
  74492. export class Plane {
  74493. private static _TmpMatrix;
  74494. /**
  74495. * Normal of the plane (a,b,c)
  74496. */
  74497. normal: Vector3;
  74498. /**
  74499. * d component of the plane
  74500. */
  74501. d: number;
  74502. /**
  74503. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74504. * @param a a component of the plane
  74505. * @param b b component of the plane
  74506. * @param c c component of the plane
  74507. * @param d d component of the plane
  74508. */
  74509. constructor(a: number, b: number, c: number, d: number);
  74510. /**
  74511. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74512. */
  74513. asArray(): number[];
  74514. /**
  74515. * @returns a new plane copied from the current Plane.
  74516. */
  74517. clone(): Plane;
  74518. /**
  74519. * @returns the string "Plane".
  74520. */
  74521. getClassName(): string;
  74522. /**
  74523. * @returns the Plane hash code.
  74524. */
  74525. getHashCode(): number;
  74526. /**
  74527. * Normalize the current Plane in place.
  74528. * @returns the updated Plane.
  74529. */
  74530. normalize(): Plane;
  74531. /**
  74532. * Applies a transformation the plane and returns the result
  74533. * @param transformation the transformation matrix to be applied to the plane
  74534. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74535. */
  74536. transform(transformation: DeepImmutable<Matrix>): Plane;
  74537. /**
  74538. * Calcualtte the dot product between the point and the plane normal
  74539. * @param point point to calculate the dot product with
  74540. * @returns the dot product (float) of the point coordinates and the plane normal.
  74541. */
  74542. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74543. /**
  74544. * Updates the current Plane from the plane defined by the three given points.
  74545. * @param point1 one of the points used to contruct the plane
  74546. * @param point2 one of the points used to contruct the plane
  74547. * @param point3 one of the points used to contruct the plane
  74548. * @returns the updated Plane.
  74549. */
  74550. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74551. /**
  74552. * Checks if the plane is facing a given direction
  74553. * @param direction the direction to check if the plane is facing
  74554. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74555. * @returns True is the vector "direction" is the same side than the plane normal.
  74556. */
  74557. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74558. /**
  74559. * Calculates the distance to a point
  74560. * @param point point to calculate distance to
  74561. * @returns the signed distance (float) from the given point to the Plane.
  74562. */
  74563. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74564. /**
  74565. * Creates a plane from an array
  74566. * @param array the array to create a plane from
  74567. * @returns a new Plane from the given array.
  74568. */
  74569. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74570. /**
  74571. * Creates a plane from three points
  74572. * @param point1 point used to create the plane
  74573. * @param point2 point used to create the plane
  74574. * @param point3 point used to create the plane
  74575. * @returns a new Plane defined by the three given points.
  74576. */
  74577. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74578. /**
  74579. * Creates a plane from an origin point and a normal
  74580. * @param origin origin of the plane to be constructed
  74581. * @param normal normal of the plane to be constructed
  74582. * @returns a new Plane the normal vector to this plane at the given origin point.
  74583. * Note : the vector "normal" is updated because normalized.
  74584. */
  74585. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74586. /**
  74587. * Calculates the distance from a plane and a point
  74588. * @param origin origin of the plane to be constructed
  74589. * @param normal normal of the plane to be constructed
  74590. * @param point point to calculate distance to
  74591. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74592. */
  74593. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74594. }
  74595. }
  74596. declare module BABYLON {
  74597. /**
  74598. * Class used to store bounding sphere information
  74599. */
  74600. export class BoundingSphere {
  74601. /**
  74602. * Gets the center of the bounding sphere in local space
  74603. */
  74604. readonly center: Vector3;
  74605. /**
  74606. * Radius of the bounding sphere in local space
  74607. */
  74608. radius: number;
  74609. /**
  74610. * Gets the center of the bounding sphere in world space
  74611. */
  74612. readonly centerWorld: Vector3;
  74613. /**
  74614. * Radius of the bounding sphere in world space
  74615. */
  74616. radiusWorld: number;
  74617. /**
  74618. * Gets the minimum vector in local space
  74619. */
  74620. readonly minimum: Vector3;
  74621. /**
  74622. * Gets the maximum vector in local space
  74623. */
  74624. readonly maximum: Vector3;
  74625. private _worldMatrix;
  74626. private static readonly TmpVector3;
  74627. /**
  74628. * Creates a new bounding sphere
  74629. * @param min defines the minimum vector (in local space)
  74630. * @param max defines the maximum vector (in local space)
  74631. * @param worldMatrix defines the new world matrix
  74632. */
  74633. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74634. /**
  74635. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74636. * @param min defines the new minimum vector (in local space)
  74637. * @param max defines the new maximum vector (in local space)
  74638. * @param worldMatrix defines the new world matrix
  74639. */
  74640. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74641. /**
  74642. * Scale the current bounding sphere by applying a scale factor
  74643. * @param factor defines the scale factor to apply
  74644. * @returns the current bounding box
  74645. */
  74646. scale(factor: number): BoundingSphere;
  74647. /**
  74648. * Gets the world matrix of the bounding box
  74649. * @returns a matrix
  74650. */
  74651. getWorldMatrix(): DeepImmutable<Matrix>;
  74652. /** @hidden */
  74653. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74654. /**
  74655. * Tests if the bounding sphere is intersecting the frustum planes
  74656. * @param frustumPlanes defines the frustum planes to test
  74657. * @returns true if there is an intersection
  74658. */
  74659. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74660. /**
  74661. * Tests if the bounding sphere center is in between the frustum planes.
  74662. * Used for optimistic fast inclusion.
  74663. * @param frustumPlanes defines the frustum planes to test
  74664. * @returns true if the sphere center is in between the frustum planes
  74665. */
  74666. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74667. /**
  74668. * Tests if a point is inside the bounding sphere
  74669. * @param point defines the point to test
  74670. * @returns true if the point is inside the bounding sphere
  74671. */
  74672. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74673. /**
  74674. * Checks if two sphere intersct
  74675. * @param sphere0 sphere 0
  74676. * @param sphere1 sphere 1
  74677. * @returns true if the speres intersect
  74678. */
  74679. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74680. }
  74681. }
  74682. declare module BABYLON {
  74683. /**
  74684. * Class used to store bounding box information
  74685. */
  74686. export class BoundingBox implements ICullable {
  74687. /**
  74688. * Gets the 8 vectors representing the bounding box in local space
  74689. */
  74690. readonly vectors: Vector3[];
  74691. /**
  74692. * Gets the center of the bounding box in local space
  74693. */
  74694. readonly center: Vector3;
  74695. /**
  74696. * Gets the center of the bounding box in world space
  74697. */
  74698. readonly centerWorld: Vector3;
  74699. /**
  74700. * Gets the extend size in local space
  74701. */
  74702. readonly extendSize: Vector3;
  74703. /**
  74704. * Gets the extend size in world space
  74705. */
  74706. readonly extendSizeWorld: Vector3;
  74707. /**
  74708. * Gets the OBB (object bounding box) directions
  74709. */
  74710. readonly directions: Vector3[];
  74711. /**
  74712. * Gets the 8 vectors representing the bounding box in world space
  74713. */
  74714. readonly vectorsWorld: Vector3[];
  74715. /**
  74716. * Gets the minimum vector in world space
  74717. */
  74718. readonly minimumWorld: Vector3;
  74719. /**
  74720. * Gets the maximum vector in world space
  74721. */
  74722. readonly maximumWorld: Vector3;
  74723. /**
  74724. * Gets the minimum vector in local space
  74725. */
  74726. readonly minimum: Vector3;
  74727. /**
  74728. * Gets the maximum vector in local space
  74729. */
  74730. readonly maximum: Vector3;
  74731. private _worldMatrix;
  74732. private static readonly TmpVector3;
  74733. /**
  74734. * @hidden
  74735. */
  74736. _tag: number;
  74737. /**
  74738. * Creates a new bounding box
  74739. * @param min defines the minimum vector (in local space)
  74740. * @param max defines the maximum vector (in local space)
  74741. * @param worldMatrix defines the new world matrix
  74742. */
  74743. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74744. /**
  74745. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74746. * @param min defines the new minimum vector (in local space)
  74747. * @param max defines the new maximum vector (in local space)
  74748. * @param worldMatrix defines the new world matrix
  74749. */
  74750. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74751. /**
  74752. * Scale the current bounding box by applying a scale factor
  74753. * @param factor defines the scale factor to apply
  74754. * @returns the current bounding box
  74755. */
  74756. scale(factor: number): BoundingBox;
  74757. /**
  74758. * Gets the world matrix of the bounding box
  74759. * @returns a matrix
  74760. */
  74761. getWorldMatrix(): DeepImmutable<Matrix>;
  74762. /** @hidden */
  74763. _update(world: DeepImmutable<Matrix>): void;
  74764. /**
  74765. * Tests if the bounding box is intersecting the frustum planes
  74766. * @param frustumPlanes defines the frustum planes to test
  74767. * @returns true if there is an intersection
  74768. */
  74769. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74770. /**
  74771. * Tests if the bounding box is entirely inside the frustum planes
  74772. * @param frustumPlanes defines the frustum planes to test
  74773. * @returns true if there is an inclusion
  74774. */
  74775. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74776. /**
  74777. * Tests if a point is inside the bounding box
  74778. * @param point defines the point to test
  74779. * @returns true if the point is inside the bounding box
  74780. */
  74781. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74782. /**
  74783. * Tests if the bounding box intersects with a bounding sphere
  74784. * @param sphere defines the sphere to test
  74785. * @returns true if there is an intersection
  74786. */
  74787. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74788. /**
  74789. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74790. * @param min defines the min vector to use
  74791. * @param max defines the max vector to use
  74792. * @returns true if there is an intersection
  74793. */
  74794. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74795. /**
  74796. * Tests if two bounding boxes are intersections
  74797. * @param box0 defines the first box to test
  74798. * @param box1 defines the second box to test
  74799. * @returns true if there is an intersection
  74800. */
  74801. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74802. /**
  74803. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74804. * @param minPoint defines the minimum vector of the bounding box
  74805. * @param maxPoint defines the maximum vector of the bounding box
  74806. * @param sphereCenter defines the sphere center
  74807. * @param sphereRadius defines the sphere radius
  74808. * @returns true if there is an intersection
  74809. */
  74810. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74811. /**
  74812. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74813. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74814. * @param frustumPlanes defines the frustum planes to test
  74815. * @return true if there is an inclusion
  74816. */
  74817. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74818. /**
  74819. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74821. * @param frustumPlanes defines the frustum planes to test
  74822. * @return true if there is an intersection
  74823. */
  74824. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74825. }
  74826. }
  74827. declare module BABYLON {
  74828. /** @hidden */
  74829. export class Collider {
  74830. /** Define if a collision was found */
  74831. collisionFound: boolean;
  74832. /**
  74833. * Define last intersection point in local space
  74834. */
  74835. intersectionPoint: Vector3;
  74836. /**
  74837. * Define last collided mesh
  74838. */
  74839. collidedMesh: Nullable<AbstractMesh>;
  74840. private _collisionPoint;
  74841. private _planeIntersectionPoint;
  74842. private _tempVector;
  74843. private _tempVector2;
  74844. private _tempVector3;
  74845. private _tempVector4;
  74846. private _edge;
  74847. private _baseToVertex;
  74848. private _destinationPoint;
  74849. private _slidePlaneNormal;
  74850. private _displacementVector;
  74851. /** @hidden */
  74852. _radius: Vector3;
  74853. /** @hidden */
  74854. _retry: number;
  74855. private _velocity;
  74856. private _basePoint;
  74857. private _epsilon;
  74858. /** @hidden */
  74859. _velocityWorldLength: number;
  74860. /** @hidden */
  74861. _basePointWorld: Vector3;
  74862. private _velocityWorld;
  74863. private _normalizedVelocity;
  74864. /** @hidden */
  74865. _initialVelocity: Vector3;
  74866. /** @hidden */
  74867. _initialPosition: Vector3;
  74868. private _nearestDistance;
  74869. private _collisionMask;
  74870. collisionMask: number;
  74871. /**
  74872. * Gets the plane normal used to compute the sliding response (in local space)
  74873. */
  74874. readonly slidePlaneNormal: Vector3;
  74875. /** @hidden */
  74876. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74877. /** @hidden */
  74878. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74879. /** @hidden */
  74880. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74881. /** @hidden */
  74882. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74883. /** @hidden */
  74884. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74885. /** @hidden */
  74886. _getResponse(pos: Vector3, vel: Vector3): void;
  74887. }
  74888. }
  74889. declare module BABYLON {
  74890. /**
  74891. * Interface for cullable objects
  74892. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74893. */
  74894. export interface ICullable {
  74895. /**
  74896. * Checks if the object or part of the object is in the frustum
  74897. * @param frustumPlanes Camera near/planes
  74898. * @returns true if the object is in frustum otherwise false
  74899. */
  74900. isInFrustum(frustumPlanes: Plane[]): boolean;
  74901. /**
  74902. * Checks if a cullable object (mesh...) is in the camera frustum
  74903. * Unlike isInFrustum this cheks the full bounding box
  74904. * @param frustumPlanes Camera near/planes
  74905. * @returns true if the object is in frustum otherwise false
  74906. */
  74907. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74908. }
  74909. /**
  74910. * Info for a bounding data of a mesh
  74911. */
  74912. export class BoundingInfo implements ICullable {
  74913. /**
  74914. * Bounding box for the mesh
  74915. */
  74916. readonly boundingBox: BoundingBox;
  74917. /**
  74918. * Bounding sphere for the mesh
  74919. */
  74920. readonly boundingSphere: BoundingSphere;
  74921. private _isLocked;
  74922. private static readonly TmpVector3;
  74923. /**
  74924. * Constructs bounding info
  74925. * @param minimum min vector of the bounding box/sphere
  74926. * @param maximum max vector of the bounding box/sphere
  74927. * @param worldMatrix defines the new world matrix
  74928. */
  74929. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74930. /**
  74931. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74932. * @param min defines the new minimum vector (in local space)
  74933. * @param max defines the new maximum vector (in local space)
  74934. * @param worldMatrix defines the new world matrix
  74935. */
  74936. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74937. /**
  74938. * min vector of the bounding box/sphere
  74939. */
  74940. readonly minimum: Vector3;
  74941. /**
  74942. * max vector of the bounding box/sphere
  74943. */
  74944. readonly maximum: Vector3;
  74945. /**
  74946. * If the info is locked and won't be updated to avoid perf overhead
  74947. */
  74948. isLocked: boolean;
  74949. /**
  74950. * Updates the bounding sphere and box
  74951. * @param world world matrix to be used to update
  74952. */
  74953. update(world: DeepImmutable<Matrix>): void;
  74954. /**
  74955. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74956. * @param center New center of the bounding info
  74957. * @param extend New extend of the bounding info
  74958. * @returns the current bounding info
  74959. */
  74960. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74961. /**
  74962. * Scale the current bounding info by applying a scale factor
  74963. * @param factor defines the scale factor to apply
  74964. * @returns the current bounding info
  74965. */
  74966. scale(factor: number): BoundingInfo;
  74967. /**
  74968. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74969. * @param frustumPlanes defines the frustum to test
  74970. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74971. * @returns true if the bounding info is in the frustum planes
  74972. */
  74973. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74974. /**
  74975. * Gets the world distance between the min and max points of the bounding box
  74976. */
  74977. readonly diagonalLength: number;
  74978. /**
  74979. * Checks if a cullable object (mesh...) is in the camera frustum
  74980. * Unlike isInFrustum this cheks the full bounding box
  74981. * @param frustumPlanes Camera near/planes
  74982. * @returns true if the object is in frustum otherwise false
  74983. */
  74984. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74985. /** @hidden */
  74986. _checkCollision(collider: Collider): boolean;
  74987. /**
  74988. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74989. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74990. * @param point the point to check intersection with
  74991. * @returns if the point intersects
  74992. */
  74993. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74994. /**
  74995. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74996. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74997. * @param boundingInfo the bounding info to check intersection with
  74998. * @param precise if the intersection should be done using OBB
  74999. * @returns if the bounding info intersects
  75000. */
  75001. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75002. }
  75003. }
  75004. declare module BABYLON {
  75005. /**
  75006. * Extracts minimum and maximum values from a list of indexed positions
  75007. * @param positions defines the positions to use
  75008. * @param indices defines the indices to the positions
  75009. * @param indexStart defines the start index
  75010. * @param indexCount defines the end index
  75011. * @param bias defines bias value to add to the result
  75012. * @return minimum and maximum values
  75013. */
  75014. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75015. minimum: Vector3;
  75016. maximum: Vector3;
  75017. };
  75018. /**
  75019. * Extracts minimum and maximum values from a list of positions
  75020. * @param positions defines the positions to use
  75021. * @param start defines the start index in the positions array
  75022. * @param count defines the number of positions to handle
  75023. * @param bias defines bias value to add to the result
  75024. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75025. * @return minimum and maximum values
  75026. */
  75027. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75028. minimum: Vector3;
  75029. maximum: Vector3;
  75030. };
  75031. }
  75032. declare module BABYLON {
  75033. /** @hidden */
  75034. export class WebGLDataBuffer extends DataBuffer {
  75035. private _buffer;
  75036. constructor(resource: WebGLBuffer);
  75037. readonly underlyingResource: any;
  75038. }
  75039. }
  75040. declare module BABYLON {
  75041. /** @hidden */
  75042. export class WebGLPipelineContext implements IPipelineContext {
  75043. engine: ThinEngine;
  75044. program: Nullable<WebGLProgram>;
  75045. context?: WebGLRenderingContext;
  75046. vertexShader?: WebGLShader;
  75047. fragmentShader?: WebGLShader;
  75048. isParallelCompiled: boolean;
  75049. onCompiled?: () => void;
  75050. transformFeedback?: WebGLTransformFeedback | null;
  75051. readonly isAsync: boolean;
  75052. readonly isReady: boolean;
  75053. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75054. }
  75055. }
  75056. declare module BABYLON {
  75057. interface ThinEngine {
  75058. /**
  75059. * Create an uniform buffer
  75060. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75061. * @param elements defines the content of the uniform buffer
  75062. * @returns the webGL uniform buffer
  75063. */
  75064. createUniformBuffer(elements: FloatArray): DataBuffer;
  75065. /**
  75066. * Create a dynamic uniform buffer
  75067. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75068. * @param elements defines the content of the uniform buffer
  75069. * @returns the webGL uniform buffer
  75070. */
  75071. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75072. /**
  75073. * Update an existing uniform buffer
  75074. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75075. * @param uniformBuffer defines the target uniform buffer
  75076. * @param elements defines the content to update
  75077. * @param offset defines the offset in the uniform buffer where update should start
  75078. * @param count defines the size of the data to update
  75079. */
  75080. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75081. /**
  75082. * Bind an uniform buffer to the current webGL context
  75083. * @param buffer defines the buffer to bind
  75084. */
  75085. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75086. /**
  75087. * Bind a buffer to the current webGL context at a given location
  75088. * @param buffer defines the buffer to bind
  75089. * @param location defines the index where to bind the buffer
  75090. */
  75091. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75092. /**
  75093. * Bind a specific block at a given index in a specific shader program
  75094. * @param pipelineContext defines the pipeline context to use
  75095. * @param blockName defines the block name
  75096. * @param index defines the index where to bind the block
  75097. */
  75098. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75099. }
  75100. }
  75101. declare module BABYLON {
  75102. /**
  75103. * Uniform buffer objects.
  75104. *
  75105. * Handles blocks of uniform on the GPU.
  75106. *
  75107. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75108. *
  75109. * For more information, please refer to :
  75110. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75111. */
  75112. export class UniformBuffer {
  75113. private _engine;
  75114. private _buffer;
  75115. private _data;
  75116. private _bufferData;
  75117. private _dynamic?;
  75118. private _uniformLocations;
  75119. private _uniformSizes;
  75120. private _uniformLocationPointer;
  75121. private _needSync;
  75122. private _noUBO;
  75123. private _currentEffect;
  75124. /** @hidden */
  75125. _alreadyBound: boolean;
  75126. private static _MAX_UNIFORM_SIZE;
  75127. private static _tempBuffer;
  75128. /**
  75129. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75134. /**
  75135. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75140. /**
  75141. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  75146. /**
  75147. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75152. /**
  75153. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75158. /**
  75159. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75164. /**
  75165. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  75170. /**
  75171. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75172. * This is dynamic to allow compat with webgl 1 and 2.
  75173. * You will need to pass the name of the uniform as well as the value.
  75174. */
  75175. updateVector3: (name: string, vector: Vector3) => void;
  75176. /**
  75177. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75178. * This is dynamic to allow compat with webgl 1 and 2.
  75179. * You will need to pass the name of the uniform as well as the value.
  75180. */
  75181. updateVector4: (name: string, vector: Vector4) => void;
  75182. /**
  75183. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75184. * This is dynamic to allow compat with webgl 1 and 2.
  75185. * You will need to pass the name of the uniform as well as the value.
  75186. */
  75187. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75188. /**
  75189. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75190. * This is dynamic to allow compat with webgl 1 and 2.
  75191. * You will need to pass the name of the uniform as well as the value.
  75192. */
  75193. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75194. /**
  75195. * Instantiates a new Uniform buffer objects.
  75196. *
  75197. * Handles blocks of uniform on the GPU.
  75198. *
  75199. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75200. *
  75201. * For more information, please refer to :
  75202. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75203. * @param engine Define the engine the buffer is associated with
  75204. * @param data Define the data contained in the buffer
  75205. * @param dynamic Define if the buffer is updatable
  75206. */
  75207. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75208. /**
  75209. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75210. * or just falling back on setUniformXXX calls.
  75211. */
  75212. readonly useUbo: boolean;
  75213. /**
  75214. * Indicates if the WebGL underlying uniform buffer is in sync
  75215. * with the javascript cache data.
  75216. */
  75217. readonly isSync: boolean;
  75218. /**
  75219. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75220. * Also, a dynamic UniformBuffer will disable cache verification and always
  75221. * update the underlying WebGL uniform buffer to the GPU.
  75222. * @returns if Dynamic, otherwise false
  75223. */
  75224. isDynamic(): boolean;
  75225. /**
  75226. * The data cache on JS side.
  75227. * @returns the underlying data as a float array
  75228. */
  75229. getData(): Float32Array;
  75230. /**
  75231. * The underlying WebGL Uniform buffer.
  75232. * @returns the webgl buffer
  75233. */
  75234. getBuffer(): Nullable<DataBuffer>;
  75235. /**
  75236. * std140 layout specifies how to align data within an UBO structure.
  75237. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75238. * for specs.
  75239. */
  75240. private _fillAlignment;
  75241. /**
  75242. * Adds an uniform in the buffer.
  75243. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75244. * for the layout to be correct !
  75245. * @param name Name of the uniform, as used in the uniform block in the shader.
  75246. * @param size Data size, or data directly.
  75247. */
  75248. addUniform(name: string, size: number | number[]): void;
  75249. /**
  75250. * Adds a Matrix 4x4 to the uniform buffer.
  75251. * @param name Name of the uniform, as used in the uniform block in the shader.
  75252. * @param mat A 4x4 matrix.
  75253. */
  75254. addMatrix(name: string, mat: Matrix): void;
  75255. /**
  75256. * Adds a vec2 to the uniform buffer.
  75257. * @param name Name of the uniform, as used in the uniform block in the shader.
  75258. * @param x Define the x component value of the vec2
  75259. * @param y Define the y component value of the vec2
  75260. */
  75261. addFloat2(name: string, x: number, y: number): void;
  75262. /**
  75263. * Adds a vec3 to the uniform buffer.
  75264. * @param name Name of the uniform, as used in the uniform block in the shader.
  75265. * @param x Define the x component value of the vec3
  75266. * @param y Define the y component value of the vec3
  75267. * @param z Define the z component value of the vec3
  75268. */
  75269. addFloat3(name: string, x: number, y: number, z: number): void;
  75270. /**
  75271. * Adds a vec3 to the uniform buffer.
  75272. * @param name Name of the uniform, as used in the uniform block in the shader.
  75273. * @param color Define the vec3 from a Color
  75274. */
  75275. addColor3(name: string, color: Color3): void;
  75276. /**
  75277. * Adds a vec4 to the uniform buffer.
  75278. * @param name Name of the uniform, as used in the uniform block in the shader.
  75279. * @param color Define the rgb components from a Color
  75280. * @param alpha Define the a component of the vec4
  75281. */
  75282. addColor4(name: string, color: Color3, alpha: number): void;
  75283. /**
  75284. * Adds a vec3 to the uniform buffer.
  75285. * @param name Name of the uniform, as used in the uniform block in the shader.
  75286. * @param vector Define the vec3 components from a Vector
  75287. */
  75288. addVector3(name: string, vector: Vector3): void;
  75289. /**
  75290. * Adds a Matrix 3x3 to the uniform buffer.
  75291. * @param name Name of the uniform, as used in the uniform block in the shader.
  75292. */
  75293. addMatrix3x3(name: string): void;
  75294. /**
  75295. * Adds a Matrix 2x2 to the uniform buffer.
  75296. * @param name Name of the uniform, as used in the uniform block in the shader.
  75297. */
  75298. addMatrix2x2(name: string): void;
  75299. /**
  75300. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75301. */
  75302. create(): void;
  75303. /** @hidden */
  75304. _rebuild(): void;
  75305. /**
  75306. * Updates the WebGL Uniform Buffer on the GPU.
  75307. * If the `dynamic` flag is set to true, no cache comparison is done.
  75308. * Otherwise, the buffer will be updated only if the cache differs.
  75309. */
  75310. update(): void;
  75311. /**
  75312. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75313. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75314. * @param data Define the flattened data
  75315. * @param size Define the size of the data.
  75316. */
  75317. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75318. private _valueCache;
  75319. private _cacheMatrix;
  75320. private _updateMatrix3x3ForUniform;
  75321. private _updateMatrix3x3ForEffect;
  75322. private _updateMatrix2x2ForEffect;
  75323. private _updateMatrix2x2ForUniform;
  75324. private _updateFloatForEffect;
  75325. private _updateFloatForUniform;
  75326. private _updateFloat2ForEffect;
  75327. private _updateFloat2ForUniform;
  75328. private _updateFloat3ForEffect;
  75329. private _updateFloat3ForUniform;
  75330. private _updateFloat4ForEffect;
  75331. private _updateFloat4ForUniform;
  75332. private _updateMatrixForEffect;
  75333. private _updateMatrixForUniform;
  75334. private _updateVector3ForEffect;
  75335. private _updateVector3ForUniform;
  75336. private _updateVector4ForEffect;
  75337. private _updateVector4ForUniform;
  75338. private _updateColor3ForEffect;
  75339. private _updateColor3ForUniform;
  75340. private _updateColor4ForEffect;
  75341. private _updateColor4ForUniform;
  75342. /**
  75343. * Sets a sampler uniform on the effect.
  75344. * @param name Define the name of the sampler.
  75345. * @param texture Define the texture to set in the sampler
  75346. */
  75347. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75348. /**
  75349. * Directly updates the value of the uniform in the cache AND on the GPU.
  75350. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75351. * @param data Define the flattened data
  75352. */
  75353. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75354. /**
  75355. * Binds this uniform buffer to an effect.
  75356. * @param effect Define the effect to bind the buffer to
  75357. * @param name Name of the uniform block in the shader.
  75358. */
  75359. bindToEffect(effect: Effect, name: string): void;
  75360. /**
  75361. * Disposes the uniform buffer.
  75362. */
  75363. dispose(): void;
  75364. }
  75365. }
  75366. declare module BABYLON {
  75367. /**
  75368. * Enum that determines the text-wrapping mode to use.
  75369. */
  75370. export enum InspectableType {
  75371. /**
  75372. * Checkbox for booleans
  75373. */
  75374. Checkbox = 0,
  75375. /**
  75376. * Sliders for numbers
  75377. */
  75378. Slider = 1,
  75379. /**
  75380. * Vector3
  75381. */
  75382. Vector3 = 2,
  75383. /**
  75384. * Quaternions
  75385. */
  75386. Quaternion = 3,
  75387. /**
  75388. * Color3
  75389. */
  75390. Color3 = 4,
  75391. /**
  75392. * String
  75393. */
  75394. String = 5
  75395. }
  75396. /**
  75397. * Interface used to define custom inspectable properties.
  75398. * This interface is used by the inspector to display custom property grids
  75399. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75400. */
  75401. export interface IInspectable {
  75402. /**
  75403. * Gets the label to display
  75404. */
  75405. label: string;
  75406. /**
  75407. * Gets the name of the property to edit
  75408. */
  75409. propertyName: string;
  75410. /**
  75411. * Gets the type of the editor to use
  75412. */
  75413. type: InspectableType;
  75414. /**
  75415. * Gets the minimum value of the property when using in "slider" mode
  75416. */
  75417. min?: number;
  75418. /**
  75419. * Gets the maximum value of the property when using in "slider" mode
  75420. */
  75421. max?: number;
  75422. /**
  75423. * Gets the setp to use when using in "slider" mode
  75424. */
  75425. step?: number;
  75426. }
  75427. }
  75428. declare module BABYLON {
  75429. /**
  75430. * Class used to provide helper for timing
  75431. */
  75432. export class TimingTools {
  75433. /**
  75434. * Polyfill for setImmediate
  75435. * @param action defines the action to execute after the current execution block
  75436. */
  75437. static SetImmediate(action: () => void): void;
  75438. }
  75439. }
  75440. declare module BABYLON {
  75441. /**
  75442. * Class used to enable instatition of objects by class name
  75443. */
  75444. export class InstantiationTools {
  75445. /**
  75446. * Use this object to register external classes like custom textures or material
  75447. * to allow the laoders to instantiate them
  75448. */
  75449. static RegisteredExternalClasses: {
  75450. [key: string]: Object;
  75451. };
  75452. /**
  75453. * Tries to instantiate a new object from a given class name
  75454. * @param className defines the class name to instantiate
  75455. * @returns the new object or null if the system was not able to do the instantiation
  75456. */
  75457. static Instantiate(className: string): any;
  75458. }
  75459. }
  75460. declare module BABYLON {
  75461. /**
  75462. * Define options used to create a depth texture
  75463. */
  75464. export class DepthTextureCreationOptions {
  75465. /** Specifies whether or not a stencil should be allocated in the texture */
  75466. generateStencil?: boolean;
  75467. /** Specifies whether or not bilinear filtering is enable on the texture */
  75468. bilinearFiltering?: boolean;
  75469. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75470. comparisonFunction?: number;
  75471. /** Specifies if the created texture is a cube texture */
  75472. isCube?: boolean;
  75473. }
  75474. }
  75475. declare module BABYLON {
  75476. interface ThinEngine {
  75477. /**
  75478. * Creates a depth stencil cube texture.
  75479. * This is only available in WebGL 2.
  75480. * @param size The size of face edge in the cube texture.
  75481. * @param options The options defining the cube texture.
  75482. * @returns The cube texture
  75483. */
  75484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75485. /**
  75486. * Creates a cube texture
  75487. * @param rootUrl defines the url where the files to load is located
  75488. * @param scene defines the current scene
  75489. * @param files defines the list of files to load (1 per face)
  75490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75491. * @param onLoad defines an optional callback raised when the texture is loaded
  75492. * @param onError defines an optional callback raised if there is an issue to load the texture
  75493. * @param format defines the format of the data
  75494. * @param forcedExtension defines the extension to use to pick the right loader
  75495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75500. * @returns the cube texture as an InternalTexture
  75501. */
  75502. 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;
  75503. /**
  75504. * Creates a cube texture
  75505. * @param rootUrl defines the url where the files to load is located
  75506. * @param scene defines the current scene
  75507. * @param files defines the list of files to load (1 per face)
  75508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75509. * @param onLoad defines an optional callback raised when the texture is loaded
  75510. * @param onError defines an optional callback raised if there is an issue to load the texture
  75511. * @param format defines the format of the data
  75512. * @param forcedExtension defines the extension to use to pick the right loader
  75513. * @returns the cube texture as an InternalTexture
  75514. */
  75515. 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;
  75516. /**
  75517. * Creates a cube texture
  75518. * @param rootUrl defines the url where the files to load is located
  75519. * @param scene defines the current scene
  75520. * @param files defines the list of files to load (1 per face)
  75521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75522. * @param onLoad defines an optional callback raised when the texture is loaded
  75523. * @param onError defines an optional callback raised if there is an issue to load the texture
  75524. * @param format defines the format of the data
  75525. * @param forcedExtension defines the extension to use to pick the right loader
  75526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75529. * @returns the cube texture as an InternalTexture
  75530. */
  75531. 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;
  75532. /** @hidden */
  75533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75534. /** @hidden */
  75535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75536. /** @hidden */
  75537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75538. /** @hidden */
  75539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75540. /**
  75541. * @hidden
  75542. */
  75543. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75544. }
  75545. }
  75546. declare module BABYLON {
  75547. /**
  75548. * Class for creating a cube texture
  75549. */
  75550. export class CubeTexture extends BaseTexture {
  75551. private _delayedOnLoad;
  75552. /**
  75553. * The url of the texture
  75554. */
  75555. url: string;
  75556. /**
  75557. * Gets or sets the center of the bounding box associated with the cube texture.
  75558. * It must define where the camera used to render the texture was set
  75559. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75560. */
  75561. boundingBoxPosition: Vector3;
  75562. private _boundingBoxSize;
  75563. /**
  75564. * Gets or sets the size of the bounding box associated with the cube texture
  75565. * When defined, the cubemap will switch to local mode
  75566. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75567. * @example https://www.babylonjs-playground.com/#RNASML
  75568. */
  75569. /**
  75570. * Returns the bounding box size
  75571. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75572. */
  75573. boundingBoxSize: Vector3;
  75574. protected _rotationY: number;
  75575. /**
  75576. * Sets texture matrix rotation angle around Y axis in radians.
  75577. */
  75578. /**
  75579. * Gets texture matrix rotation angle around Y axis radians.
  75580. */
  75581. rotationY: number;
  75582. /**
  75583. * Are mip maps generated for this texture or not.
  75584. */
  75585. readonly noMipmap: boolean;
  75586. private _noMipmap;
  75587. private _files;
  75588. protected _forcedExtension: Nullable<string>;
  75589. private _extensions;
  75590. private _textureMatrix;
  75591. private _format;
  75592. private _createPolynomials;
  75593. /** @hidden */
  75594. _prefiltered: boolean;
  75595. /**
  75596. * Creates a cube texture from an array of image urls
  75597. * @param files defines an array of image urls
  75598. * @param scene defines the hosting scene
  75599. * @param noMipmap specifies if mip maps are not used
  75600. * @returns a cube texture
  75601. */
  75602. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75603. /**
  75604. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75605. * @param url defines the url of the prefiltered texture
  75606. * @param scene defines the scene the texture is attached to
  75607. * @param forcedExtension defines the extension of the file if different from the url
  75608. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75609. * @return the prefiltered texture
  75610. */
  75611. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75612. /**
  75613. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75614. * as prefiltered data.
  75615. * @param rootUrl defines the url of the texture or the root name of the six images
  75616. * @param scene defines the scene the texture is attached to
  75617. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75618. * @param noMipmap defines if mipmaps should be created or not
  75619. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75620. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75621. * @param onError defines a callback triggered in case of error during load
  75622. * @param format defines the internal format to use for the texture once loaded
  75623. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75624. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75625. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75626. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75627. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75628. * @return the cube texture
  75629. */
  75630. 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);
  75631. /**
  75632. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75633. */
  75634. readonly isPrefiltered: boolean;
  75635. /**
  75636. * Get the current class name of the texture useful for serialization or dynamic coding.
  75637. * @returns "CubeTexture"
  75638. */
  75639. getClassName(): string;
  75640. /**
  75641. * Update the url (and optional buffer) of this texture if url was null during construction.
  75642. * @param url the url of the texture
  75643. * @param forcedExtension defines the extension to use
  75644. * @param onLoad callback called when the texture is loaded (defaults to null)
  75645. */
  75646. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75647. /**
  75648. * Delays loading of the cube texture
  75649. * @param forcedExtension defines the extension to use
  75650. */
  75651. delayLoad(forcedExtension?: string): void;
  75652. /**
  75653. * Returns the reflection texture matrix
  75654. * @returns the reflection texture matrix
  75655. */
  75656. getReflectionTextureMatrix(): Matrix;
  75657. /**
  75658. * Sets the reflection texture matrix
  75659. * @param value Reflection texture matrix
  75660. */
  75661. setReflectionTextureMatrix(value: Matrix): void;
  75662. /**
  75663. * Parses text to create a cube texture
  75664. * @param parsedTexture define the serialized text to read from
  75665. * @param scene defines the hosting scene
  75666. * @param rootUrl defines the root url of the cube texture
  75667. * @returns a cube texture
  75668. */
  75669. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75670. /**
  75671. * Makes a clone, or deep copy, of the cube texture
  75672. * @returns a new cube texture
  75673. */
  75674. clone(): CubeTexture;
  75675. }
  75676. }
  75677. declare module BABYLON {
  75678. /**
  75679. * Manages the defines for the Material
  75680. */
  75681. export class MaterialDefines {
  75682. /** @hidden */
  75683. protected _keys: string[];
  75684. private _isDirty;
  75685. /** @hidden */
  75686. _renderId: number;
  75687. /** @hidden */
  75688. _areLightsDirty: boolean;
  75689. /** @hidden */
  75690. _areLightsDisposed: boolean;
  75691. /** @hidden */
  75692. _areAttributesDirty: boolean;
  75693. /** @hidden */
  75694. _areTexturesDirty: boolean;
  75695. /** @hidden */
  75696. _areFresnelDirty: boolean;
  75697. /** @hidden */
  75698. _areMiscDirty: boolean;
  75699. /** @hidden */
  75700. _areImageProcessingDirty: boolean;
  75701. /** @hidden */
  75702. _normals: boolean;
  75703. /** @hidden */
  75704. _uvs: boolean;
  75705. /** @hidden */
  75706. _needNormals: boolean;
  75707. /** @hidden */
  75708. _needUVs: boolean;
  75709. [id: string]: any;
  75710. /**
  75711. * Specifies if the material needs to be re-calculated
  75712. */
  75713. readonly isDirty: boolean;
  75714. /**
  75715. * Marks the material to indicate that it has been re-calculated
  75716. */
  75717. markAsProcessed(): void;
  75718. /**
  75719. * Marks the material to indicate that it needs to be re-calculated
  75720. */
  75721. markAsUnprocessed(): void;
  75722. /**
  75723. * Marks the material to indicate all of its defines need to be re-calculated
  75724. */
  75725. markAllAsDirty(): void;
  75726. /**
  75727. * Marks the material to indicate that image processing needs to be re-calculated
  75728. */
  75729. markAsImageProcessingDirty(): void;
  75730. /**
  75731. * Marks the material to indicate the lights need to be re-calculated
  75732. * @param disposed Defines whether the light is dirty due to dispose or not
  75733. */
  75734. markAsLightDirty(disposed?: boolean): void;
  75735. /**
  75736. * Marks the attribute state as changed
  75737. */
  75738. markAsAttributesDirty(): void;
  75739. /**
  75740. * Marks the texture state as changed
  75741. */
  75742. markAsTexturesDirty(): void;
  75743. /**
  75744. * Marks the fresnel state as changed
  75745. */
  75746. markAsFresnelDirty(): void;
  75747. /**
  75748. * Marks the misc state as changed
  75749. */
  75750. markAsMiscDirty(): void;
  75751. /**
  75752. * Rebuilds the material defines
  75753. */
  75754. rebuild(): void;
  75755. /**
  75756. * Specifies if two material defines are equal
  75757. * @param other - A material define instance to compare to
  75758. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75759. */
  75760. isEqual(other: MaterialDefines): boolean;
  75761. /**
  75762. * Clones this instance's defines to another instance
  75763. * @param other - material defines to clone values to
  75764. */
  75765. cloneTo(other: MaterialDefines): void;
  75766. /**
  75767. * Resets the material define values
  75768. */
  75769. reset(): void;
  75770. /**
  75771. * Converts the material define values to a string
  75772. * @returns - String of material define information
  75773. */
  75774. toString(): string;
  75775. }
  75776. }
  75777. declare module BABYLON {
  75778. /**
  75779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75781. * 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;
  75782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75783. */
  75784. export class ColorCurves {
  75785. private _dirty;
  75786. private _tempColor;
  75787. private _globalCurve;
  75788. private _highlightsCurve;
  75789. private _midtonesCurve;
  75790. private _shadowsCurve;
  75791. private _positiveCurve;
  75792. private _negativeCurve;
  75793. private _globalHue;
  75794. private _globalDensity;
  75795. private _globalSaturation;
  75796. private _globalExposure;
  75797. /**
  75798. * Gets the global Hue value.
  75799. * 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).
  75800. */
  75801. /**
  75802. * Sets the global Hue value.
  75803. * 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).
  75804. */
  75805. globalHue: number;
  75806. /**
  75807. * Gets the global Density value.
  75808. * 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.
  75809. * Values less than zero provide a filter of opposite hue.
  75810. */
  75811. /**
  75812. * Sets the global Density value.
  75813. * 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.
  75814. * Values less than zero provide a filter of opposite hue.
  75815. */
  75816. globalDensity: number;
  75817. /**
  75818. * Gets the global Saturation value.
  75819. * 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.
  75820. */
  75821. /**
  75822. * Sets the global Saturation value.
  75823. * 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.
  75824. */
  75825. globalSaturation: number;
  75826. /**
  75827. * Gets the global Exposure value.
  75828. * 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.
  75829. */
  75830. /**
  75831. * Sets the global Exposure value.
  75832. * 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.
  75833. */
  75834. globalExposure: number;
  75835. private _highlightsHue;
  75836. private _highlightsDensity;
  75837. private _highlightsSaturation;
  75838. private _highlightsExposure;
  75839. /**
  75840. * Gets the highlights Hue value.
  75841. * 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).
  75842. */
  75843. /**
  75844. * Sets the highlights Hue value.
  75845. * 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).
  75846. */
  75847. highlightsHue: number;
  75848. /**
  75849. * Gets the highlights Density value.
  75850. * 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.
  75851. * Values less than zero provide a filter of opposite hue.
  75852. */
  75853. /**
  75854. * Sets the highlights Density value.
  75855. * 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.
  75856. * Values less than zero provide a filter of opposite hue.
  75857. */
  75858. highlightsDensity: number;
  75859. /**
  75860. * Gets the highlights Saturation value.
  75861. * 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.
  75862. */
  75863. /**
  75864. * Sets the highlights Saturation value.
  75865. * 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.
  75866. */
  75867. highlightsSaturation: number;
  75868. /**
  75869. * Gets the highlights Exposure value.
  75870. * 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.
  75871. */
  75872. /**
  75873. * Sets the highlights Exposure value.
  75874. * 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.
  75875. */
  75876. highlightsExposure: number;
  75877. private _midtonesHue;
  75878. private _midtonesDensity;
  75879. private _midtonesSaturation;
  75880. private _midtonesExposure;
  75881. /**
  75882. * Gets the midtones Hue value.
  75883. * 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).
  75884. */
  75885. /**
  75886. * Sets the midtones Hue value.
  75887. * 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).
  75888. */
  75889. midtonesHue: number;
  75890. /**
  75891. * Gets the midtones Density value.
  75892. * 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.
  75893. * Values less than zero provide a filter of opposite hue.
  75894. */
  75895. /**
  75896. * Sets the midtones Density value.
  75897. * 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.
  75898. * Values less than zero provide a filter of opposite hue.
  75899. */
  75900. midtonesDensity: number;
  75901. /**
  75902. * Gets the midtones Saturation value.
  75903. * 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.
  75904. */
  75905. /**
  75906. * Sets the midtones Saturation value.
  75907. * 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.
  75908. */
  75909. midtonesSaturation: number;
  75910. /**
  75911. * Gets the midtones Exposure value.
  75912. * 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.
  75913. */
  75914. /**
  75915. * Sets the midtones Exposure value.
  75916. * 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.
  75917. */
  75918. midtonesExposure: number;
  75919. private _shadowsHue;
  75920. private _shadowsDensity;
  75921. private _shadowsSaturation;
  75922. private _shadowsExposure;
  75923. /**
  75924. * Gets the shadows Hue value.
  75925. * 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).
  75926. */
  75927. /**
  75928. * Sets the shadows Hue value.
  75929. * 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).
  75930. */
  75931. shadowsHue: number;
  75932. /**
  75933. * Gets the shadows Density value.
  75934. * 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.
  75935. * Values less than zero provide a filter of opposite hue.
  75936. */
  75937. /**
  75938. * Sets the shadows Density value.
  75939. * 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.
  75940. * Values less than zero provide a filter of opposite hue.
  75941. */
  75942. shadowsDensity: number;
  75943. /**
  75944. * Gets the shadows Saturation value.
  75945. * 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.
  75946. */
  75947. /**
  75948. * Sets the shadows Saturation value.
  75949. * 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.
  75950. */
  75951. shadowsSaturation: number;
  75952. /**
  75953. * Gets the shadows Exposure value.
  75954. * 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.
  75955. */
  75956. /**
  75957. * Sets the shadows Exposure value.
  75958. * 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.
  75959. */
  75960. shadowsExposure: number;
  75961. /**
  75962. * Returns the class name
  75963. * @returns The class name
  75964. */
  75965. getClassName(): string;
  75966. /**
  75967. * Binds the color curves to the shader.
  75968. * @param colorCurves The color curve to bind
  75969. * @param effect The effect to bind to
  75970. * @param positiveUniform The positive uniform shader parameter
  75971. * @param neutralUniform The neutral uniform shader parameter
  75972. * @param negativeUniform The negative uniform shader parameter
  75973. */
  75974. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75975. /**
  75976. * Prepare the list of uniforms associated with the ColorCurves effects.
  75977. * @param uniformsList The list of uniforms used in the effect
  75978. */
  75979. static PrepareUniforms(uniformsList: string[]): void;
  75980. /**
  75981. * Returns color grading data based on a hue, density, saturation and exposure value.
  75982. * @param filterHue The hue of the color filter.
  75983. * @param filterDensity The density of the color filter.
  75984. * @param saturation The saturation.
  75985. * @param exposure The exposure.
  75986. * @param result The result data container.
  75987. */
  75988. private getColorGradingDataToRef;
  75989. /**
  75990. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75991. * @param value The input slider value in range [-100,100].
  75992. * @returns Adjusted value.
  75993. */
  75994. private static applyColorGradingSliderNonlinear;
  75995. /**
  75996. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75997. * @param hue The hue (H) input.
  75998. * @param saturation The saturation (S) input.
  75999. * @param brightness The brightness (B) input.
  76000. * @result An RGBA color represented as Vector4.
  76001. */
  76002. private static fromHSBToRef;
  76003. /**
  76004. * Returns a value clamped between min and max
  76005. * @param value The value to clamp
  76006. * @param min The minimum of value
  76007. * @param max The maximum of value
  76008. * @returns The clamped value.
  76009. */
  76010. private static clamp;
  76011. /**
  76012. * Clones the current color curve instance.
  76013. * @return The cloned curves
  76014. */
  76015. clone(): ColorCurves;
  76016. /**
  76017. * Serializes the current color curve instance to a json representation.
  76018. * @return a JSON representation
  76019. */
  76020. serialize(): any;
  76021. /**
  76022. * Parses the color curve from a json representation.
  76023. * @param source the JSON source to parse
  76024. * @return The parsed curves
  76025. */
  76026. static Parse(source: any): ColorCurves;
  76027. }
  76028. }
  76029. declare module BABYLON {
  76030. /**
  76031. * Interface to follow in your material defines to integrate easily the
  76032. * Image proccessing functions.
  76033. * @hidden
  76034. */
  76035. export interface IImageProcessingConfigurationDefines {
  76036. IMAGEPROCESSING: boolean;
  76037. VIGNETTE: boolean;
  76038. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76039. VIGNETTEBLENDMODEOPAQUE: boolean;
  76040. TONEMAPPING: boolean;
  76041. TONEMAPPING_ACES: boolean;
  76042. CONTRAST: boolean;
  76043. EXPOSURE: boolean;
  76044. COLORCURVES: boolean;
  76045. COLORGRADING: boolean;
  76046. COLORGRADING3D: boolean;
  76047. SAMPLER3DGREENDEPTH: boolean;
  76048. SAMPLER3DBGRMAP: boolean;
  76049. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76050. }
  76051. /**
  76052. * @hidden
  76053. */
  76054. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76055. IMAGEPROCESSING: boolean;
  76056. VIGNETTE: boolean;
  76057. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76058. VIGNETTEBLENDMODEOPAQUE: boolean;
  76059. TONEMAPPING: boolean;
  76060. TONEMAPPING_ACES: boolean;
  76061. CONTRAST: boolean;
  76062. COLORCURVES: boolean;
  76063. COLORGRADING: boolean;
  76064. COLORGRADING3D: boolean;
  76065. SAMPLER3DGREENDEPTH: boolean;
  76066. SAMPLER3DBGRMAP: boolean;
  76067. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76068. EXPOSURE: boolean;
  76069. constructor();
  76070. }
  76071. /**
  76072. * This groups together the common properties used for image processing either in direct forward pass
  76073. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76074. * or not.
  76075. */
  76076. export class ImageProcessingConfiguration {
  76077. /**
  76078. * Default tone mapping applied in BabylonJS.
  76079. */
  76080. static readonly TONEMAPPING_STANDARD: number;
  76081. /**
  76082. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76083. * to other engines rendering to increase portability.
  76084. */
  76085. static readonly TONEMAPPING_ACES: number;
  76086. /**
  76087. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76088. */
  76089. colorCurves: Nullable<ColorCurves>;
  76090. private _colorCurvesEnabled;
  76091. /**
  76092. * Gets wether the color curves effect is enabled.
  76093. */
  76094. /**
  76095. * Sets wether the color curves effect is enabled.
  76096. */
  76097. colorCurvesEnabled: boolean;
  76098. private _colorGradingTexture;
  76099. /**
  76100. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76101. */
  76102. /**
  76103. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76104. */
  76105. colorGradingTexture: Nullable<BaseTexture>;
  76106. private _colorGradingEnabled;
  76107. /**
  76108. * Gets wether the color grading effect is enabled.
  76109. */
  76110. /**
  76111. * Sets wether the color grading effect is enabled.
  76112. */
  76113. colorGradingEnabled: boolean;
  76114. private _colorGradingWithGreenDepth;
  76115. /**
  76116. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76117. */
  76118. /**
  76119. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76120. */
  76121. colorGradingWithGreenDepth: boolean;
  76122. private _colorGradingBGR;
  76123. /**
  76124. * Gets wether the color grading texture contains BGR values.
  76125. */
  76126. /**
  76127. * Sets wether the color grading texture contains BGR values.
  76128. */
  76129. colorGradingBGR: boolean;
  76130. /** @hidden */
  76131. _exposure: number;
  76132. /**
  76133. * Gets the Exposure used in the effect.
  76134. */
  76135. /**
  76136. * Sets the Exposure used in the effect.
  76137. */
  76138. exposure: number;
  76139. private _toneMappingEnabled;
  76140. /**
  76141. * Gets wether the tone mapping effect is enabled.
  76142. */
  76143. /**
  76144. * Sets wether the tone mapping effect is enabled.
  76145. */
  76146. toneMappingEnabled: boolean;
  76147. private _toneMappingType;
  76148. /**
  76149. * Gets the type of tone mapping effect.
  76150. */
  76151. /**
  76152. * Sets the type of tone mapping effect used in BabylonJS.
  76153. */
  76154. toneMappingType: number;
  76155. protected _contrast: number;
  76156. /**
  76157. * Gets the contrast used in the effect.
  76158. */
  76159. /**
  76160. * Sets the contrast used in the effect.
  76161. */
  76162. contrast: number;
  76163. /**
  76164. * Vignette stretch size.
  76165. */
  76166. vignetteStretch: number;
  76167. /**
  76168. * Vignette centre X Offset.
  76169. */
  76170. vignetteCentreX: number;
  76171. /**
  76172. * Vignette centre Y Offset.
  76173. */
  76174. vignetteCentreY: number;
  76175. /**
  76176. * Vignette weight or intensity of the vignette effect.
  76177. */
  76178. vignetteWeight: number;
  76179. /**
  76180. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76181. * if vignetteEnabled is set to true.
  76182. */
  76183. vignetteColor: Color4;
  76184. /**
  76185. * Camera field of view used by the Vignette effect.
  76186. */
  76187. vignetteCameraFov: number;
  76188. private _vignetteBlendMode;
  76189. /**
  76190. * Gets the vignette blend mode allowing different kind of effect.
  76191. */
  76192. /**
  76193. * Sets the vignette blend mode allowing different kind of effect.
  76194. */
  76195. vignetteBlendMode: number;
  76196. private _vignetteEnabled;
  76197. /**
  76198. * Gets wether the vignette effect is enabled.
  76199. */
  76200. /**
  76201. * Sets wether the vignette effect is enabled.
  76202. */
  76203. vignetteEnabled: boolean;
  76204. private _applyByPostProcess;
  76205. /**
  76206. * Gets wether the image processing is applied through a post process or not.
  76207. */
  76208. /**
  76209. * Sets wether the image processing is applied through a post process or not.
  76210. */
  76211. applyByPostProcess: boolean;
  76212. private _isEnabled;
  76213. /**
  76214. * Gets wether the image processing is enabled or not.
  76215. */
  76216. /**
  76217. * Sets wether the image processing is enabled or not.
  76218. */
  76219. isEnabled: boolean;
  76220. /**
  76221. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76222. */
  76223. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76224. /**
  76225. * Method called each time the image processing information changes requires to recompile the effect.
  76226. */
  76227. protected _updateParameters(): void;
  76228. /**
  76229. * Gets the current class name.
  76230. * @return "ImageProcessingConfiguration"
  76231. */
  76232. getClassName(): string;
  76233. /**
  76234. * Prepare the list of uniforms associated with the Image Processing effects.
  76235. * @param uniforms The list of uniforms used in the effect
  76236. * @param defines the list of defines currently in use
  76237. */
  76238. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76239. /**
  76240. * Prepare the list of samplers associated with the Image Processing effects.
  76241. * @param samplersList The list of uniforms used in the effect
  76242. * @param defines the list of defines currently in use
  76243. */
  76244. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76245. /**
  76246. * Prepare the list of defines associated to the shader.
  76247. * @param defines the list of defines to complete
  76248. * @param forPostProcess Define if we are currently in post process mode or not
  76249. */
  76250. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76251. /**
  76252. * Returns true if all the image processing information are ready.
  76253. * @returns True if ready, otherwise, false
  76254. */
  76255. isReady(): boolean;
  76256. /**
  76257. * Binds the image processing to the shader.
  76258. * @param effect The effect to bind to
  76259. * @param overrideAspectRatio Override the aspect ratio of the effect
  76260. */
  76261. bind(effect: Effect, overrideAspectRatio?: number): void;
  76262. /**
  76263. * Clones the current image processing instance.
  76264. * @return The cloned image processing
  76265. */
  76266. clone(): ImageProcessingConfiguration;
  76267. /**
  76268. * Serializes the current image processing instance to a json representation.
  76269. * @return a JSON representation
  76270. */
  76271. serialize(): any;
  76272. /**
  76273. * Parses the image processing from a json representation.
  76274. * @param source the JSON source to parse
  76275. * @return The parsed image processing
  76276. */
  76277. static Parse(source: any): ImageProcessingConfiguration;
  76278. private static _VIGNETTEMODE_MULTIPLY;
  76279. private static _VIGNETTEMODE_OPAQUE;
  76280. /**
  76281. * Used to apply the vignette as a mix with the pixel color.
  76282. */
  76283. static readonly VIGNETTEMODE_MULTIPLY: number;
  76284. /**
  76285. * Used to apply the vignette as a replacement of the pixel color.
  76286. */
  76287. static readonly VIGNETTEMODE_OPAQUE: number;
  76288. }
  76289. }
  76290. declare module BABYLON {
  76291. /** @hidden */
  76292. export var postprocessVertexShader: {
  76293. name: string;
  76294. shader: string;
  76295. };
  76296. }
  76297. declare module BABYLON {
  76298. interface ThinEngine {
  76299. /**
  76300. * Creates a new render target texture
  76301. * @param size defines the size of the texture
  76302. * @param options defines the options used to create the texture
  76303. * @returns a new render target texture stored in an InternalTexture
  76304. */
  76305. createRenderTargetTexture(size: number | {
  76306. width: number;
  76307. height: number;
  76308. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76309. /**
  76310. * Creates a depth stencil texture.
  76311. * This is only available in WebGL 2 or with the depth texture extension available.
  76312. * @param size The size of face edge in the texture.
  76313. * @param options The options defining the texture.
  76314. * @returns The texture
  76315. */
  76316. createDepthStencilTexture(size: number | {
  76317. width: number;
  76318. height: number;
  76319. }, options: DepthTextureCreationOptions): InternalTexture;
  76320. /** @hidden */
  76321. _createDepthStencilTexture(size: number | {
  76322. width: number;
  76323. height: number;
  76324. }, options: DepthTextureCreationOptions): InternalTexture;
  76325. }
  76326. }
  76327. declare module BABYLON {
  76328. /** Defines supported spaces */
  76329. export enum Space {
  76330. /** Local (object) space */
  76331. LOCAL = 0,
  76332. /** World space */
  76333. WORLD = 1,
  76334. /** Bone space */
  76335. BONE = 2
  76336. }
  76337. /** Defines the 3 main axes */
  76338. export class Axis {
  76339. /** X axis */
  76340. static X: Vector3;
  76341. /** Y axis */
  76342. static Y: Vector3;
  76343. /** Z axis */
  76344. static Z: Vector3;
  76345. }
  76346. }
  76347. declare module BABYLON {
  76348. /**
  76349. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76350. * This is the base of the follow, arc rotate cameras and Free camera
  76351. * @see http://doc.babylonjs.com/features/cameras
  76352. */
  76353. export class TargetCamera extends Camera {
  76354. private static _RigCamTransformMatrix;
  76355. private static _TargetTransformMatrix;
  76356. private static _TargetFocalPoint;
  76357. /**
  76358. * Define the current direction the camera is moving to
  76359. */
  76360. cameraDirection: Vector3;
  76361. /**
  76362. * Define the current rotation the camera is rotating to
  76363. */
  76364. cameraRotation: Vector2;
  76365. /**
  76366. * When set, the up vector of the camera will be updated by the rotation of the camera
  76367. */
  76368. updateUpVectorFromRotation: boolean;
  76369. private _tmpQuaternion;
  76370. /**
  76371. * Define the current rotation of the camera
  76372. */
  76373. rotation: Vector3;
  76374. /**
  76375. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76376. */
  76377. rotationQuaternion: Quaternion;
  76378. /**
  76379. * Define the current speed of the camera
  76380. */
  76381. speed: number;
  76382. /**
  76383. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76384. * around all axis.
  76385. */
  76386. noRotationConstraint: boolean;
  76387. /**
  76388. * Define the current target of the camera as an object or a position.
  76389. */
  76390. lockedTarget: any;
  76391. /** @hidden */
  76392. _currentTarget: Vector3;
  76393. /** @hidden */
  76394. _initialFocalDistance: number;
  76395. /** @hidden */
  76396. _viewMatrix: Matrix;
  76397. /** @hidden */
  76398. _camMatrix: Matrix;
  76399. /** @hidden */
  76400. _cameraTransformMatrix: Matrix;
  76401. /** @hidden */
  76402. _cameraRotationMatrix: Matrix;
  76403. /** @hidden */
  76404. _referencePoint: Vector3;
  76405. /** @hidden */
  76406. _transformedReferencePoint: Vector3;
  76407. protected _globalCurrentTarget: Vector3;
  76408. protected _globalCurrentUpVector: Vector3;
  76409. /** @hidden */
  76410. _reset: () => void;
  76411. private _defaultUp;
  76412. /**
  76413. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76414. * This is the base of the follow, arc rotate cameras and Free camera
  76415. * @see http://doc.babylonjs.com/features/cameras
  76416. * @param name Defines the name of the camera in the scene
  76417. * @param position Defines the start position of the camera in the scene
  76418. * @param scene Defines the scene the camera belongs to
  76419. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76420. */
  76421. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76422. /**
  76423. * Gets the position in front of the camera at a given distance.
  76424. * @param distance The distance from the camera we want the position to be
  76425. * @returns the position
  76426. */
  76427. getFrontPosition(distance: number): Vector3;
  76428. /** @hidden */
  76429. _getLockedTargetPosition(): Nullable<Vector3>;
  76430. private _storedPosition;
  76431. private _storedRotation;
  76432. private _storedRotationQuaternion;
  76433. /**
  76434. * Store current camera state of the camera (fov, position, rotation, etc..)
  76435. * @returns the camera
  76436. */
  76437. storeState(): Camera;
  76438. /**
  76439. * Restored camera state. You must call storeState() first
  76440. * @returns whether it was successful or not
  76441. * @hidden
  76442. */
  76443. _restoreStateValues(): boolean;
  76444. /** @hidden */
  76445. _initCache(): void;
  76446. /** @hidden */
  76447. _updateCache(ignoreParentClass?: boolean): void;
  76448. /** @hidden */
  76449. _isSynchronizedViewMatrix(): boolean;
  76450. /** @hidden */
  76451. _computeLocalCameraSpeed(): number;
  76452. /**
  76453. * Defines the target the camera should look at.
  76454. * @param target Defines the new target as a Vector or a mesh
  76455. */
  76456. setTarget(target: Vector3): void;
  76457. /**
  76458. * Return the current target position of the camera. This value is expressed in local space.
  76459. * @returns the target position
  76460. */
  76461. getTarget(): Vector3;
  76462. /** @hidden */
  76463. _decideIfNeedsToMove(): boolean;
  76464. /** @hidden */
  76465. _updatePosition(): void;
  76466. /** @hidden */
  76467. _checkInputs(): void;
  76468. protected _updateCameraRotationMatrix(): void;
  76469. /**
  76470. * 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)
  76471. * @returns the current camera
  76472. */
  76473. private _rotateUpVectorWithCameraRotationMatrix;
  76474. private _cachedRotationZ;
  76475. private _cachedQuaternionRotationZ;
  76476. /** @hidden */
  76477. _getViewMatrix(): Matrix;
  76478. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76479. /**
  76480. * @hidden
  76481. */
  76482. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76483. /**
  76484. * @hidden
  76485. */
  76486. _updateRigCameras(): void;
  76487. private _getRigCamPositionAndTarget;
  76488. /**
  76489. * Gets the current object class name.
  76490. * @return the class name
  76491. */
  76492. getClassName(): string;
  76493. }
  76494. }
  76495. declare module BABYLON {
  76496. /**
  76497. * Gather the list of keyboard event types as constants.
  76498. */
  76499. export class KeyboardEventTypes {
  76500. /**
  76501. * The keydown event is fired when a key becomes active (pressed).
  76502. */
  76503. static readonly KEYDOWN: number;
  76504. /**
  76505. * The keyup event is fired when a key has been released.
  76506. */
  76507. static readonly KEYUP: number;
  76508. }
  76509. /**
  76510. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76511. */
  76512. export class KeyboardInfo {
  76513. /**
  76514. * Defines the type of event (KeyboardEventTypes)
  76515. */
  76516. type: number;
  76517. /**
  76518. * Defines the related dom event
  76519. */
  76520. event: KeyboardEvent;
  76521. /**
  76522. * Instantiates a new keyboard info.
  76523. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76524. * @param type Defines the type of event (KeyboardEventTypes)
  76525. * @param event Defines the related dom event
  76526. */
  76527. constructor(
  76528. /**
  76529. * Defines the type of event (KeyboardEventTypes)
  76530. */
  76531. type: number,
  76532. /**
  76533. * Defines the related dom event
  76534. */
  76535. event: KeyboardEvent);
  76536. }
  76537. /**
  76538. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76539. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76540. */
  76541. export class KeyboardInfoPre extends KeyboardInfo {
  76542. /**
  76543. * Defines the type of event (KeyboardEventTypes)
  76544. */
  76545. type: number;
  76546. /**
  76547. * Defines the related dom event
  76548. */
  76549. event: KeyboardEvent;
  76550. /**
  76551. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76552. */
  76553. skipOnPointerObservable: boolean;
  76554. /**
  76555. * Instantiates a new keyboard pre info.
  76556. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76557. * @param type Defines the type of event (KeyboardEventTypes)
  76558. * @param event Defines the related dom event
  76559. */
  76560. constructor(
  76561. /**
  76562. * Defines the type of event (KeyboardEventTypes)
  76563. */
  76564. type: number,
  76565. /**
  76566. * Defines the related dom event
  76567. */
  76568. event: KeyboardEvent);
  76569. }
  76570. }
  76571. declare module BABYLON {
  76572. /**
  76573. * Manage the keyboard inputs to control the movement of a free camera.
  76574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76575. */
  76576. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76577. /**
  76578. * Defines the camera the input is attached to.
  76579. */
  76580. camera: FreeCamera;
  76581. /**
  76582. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76583. */
  76584. keysUp: number[];
  76585. /**
  76586. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76587. */
  76588. keysDown: number[];
  76589. /**
  76590. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76591. */
  76592. keysLeft: number[];
  76593. /**
  76594. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76595. */
  76596. keysRight: number[];
  76597. private _keys;
  76598. private _onCanvasBlurObserver;
  76599. private _onKeyboardObserver;
  76600. private _engine;
  76601. private _scene;
  76602. /**
  76603. * Attach the input controls to a specific dom element to get the input from.
  76604. * @param element Defines the element the controls should be listened from
  76605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76606. */
  76607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76608. /**
  76609. * Detach the current controls from the specified dom element.
  76610. * @param element Defines the element to stop listening the inputs from
  76611. */
  76612. detachControl(element: Nullable<HTMLElement>): void;
  76613. /**
  76614. * Update the current camera state depending on the inputs that have been used this frame.
  76615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76616. */
  76617. checkInputs(): void;
  76618. /**
  76619. * Gets the class name of the current intput.
  76620. * @returns the class name
  76621. */
  76622. getClassName(): string;
  76623. /** @hidden */
  76624. _onLostFocus(): void;
  76625. /**
  76626. * Get the friendly name associated with the input class.
  76627. * @returns the input friendly name
  76628. */
  76629. getSimpleName(): string;
  76630. }
  76631. }
  76632. declare module BABYLON {
  76633. /**
  76634. * Interface describing all the common properties and methods a shadow light needs to implement.
  76635. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76636. * as well as binding the different shadow properties to the effects.
  76637. */
  76638. export interface IShadowLight extends Light {
  76639. /**
  76640. * The light id in the scene (used in scene.findLighById for instance)
  76641. */
  76642. id: string;
  76643. /**
  76644. * The position the shdow will be casted from.
  76645. */
  76646. position: Vector3;
  76647. /**
  76648. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76649. */
  76650. direction: Vector3;
  76651. /**
  76652. * The transformed position. Position of the light in world space taking parenting in account.
  76653. */
  76654. transformedPosition: Vector3;
  76655. /**
  76656. * The transformed direction. Direction of the light in world space taking parenting in account.
  76657. */
  76658. transformedDirection: Vector3;
  76659. /**
  76660. * The friendly name of the light in the scene.
  76661. */
  76662. name: string;
  76663. /**
  76664. * Defines the shadow projection clipping minimum z value.
  76665. */
  76666. shadowMinZ: number;
  76667. /**
  76668. * Defines the shadow projection clipping maximum z value.
  76669. */
  76670. shadowMaxZ: number;
  76671. /**
  76672. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76673. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76674. */
  76675. computeTransformedInformation(): boolean;
  76676. /**
  76677. * Gets the scene the light belongs to.
  76678. * @returns The scene
  76679. */
  76680. getScene(): Scene;
  76681. /**
  76682. * Callback defining a custom Projection Matrix Builder.
  76683. * This can be used to override the default projection matrix computation.
  76684. */
  76685. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76686. /**
  76687. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76688. * @param matrix The materix to updated with the projection information
  76689. * @param viewMatrix The transform matrix of the light
  76690. * @param renderList The list of mesh to render in the map
  76691. * @returns The current light
  76692. */
  76693. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76694. /**
  76695. * Gets the current depth scale used in ESM.
  76696. * @returns The scale
  76697. */
  76698. getDepthScale(): number;
  76699. /**
  76700. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76701. * @returns true if a cube texture needs to be use
  76702. */
  76703. needCube(): boolean;
  76704. /**
  76705. * Detects if the projection matrix requires to be recomputed this frame.
  76706. * @returns true if it requires to be recomputed otherwise, false.
  76707. */
  76708. needProjectionMatrixCompute(): boolean;
  76709. /**
  76710. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76711. */
  76712. forceProjectionMatrixCompute(): void;
  76713. /**
  76714. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76715. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76716. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76717. */
  76718. getShadowDirection(faceIndex?: number): Vector3;
  76719. /**
  76720. * Gets the minZ used for shadow according to both the scene and the light.
  76721. * @param activeCamera The camera we are returning the min for
  76722. * @returns the depth min z
  76723. */
  76724. getDepthMinZ(activeCamera: Camera): number;
  76725. /**
  76726. * Gets the maxZ used for shadow according to both the scene and the light.
  76727. * @param activeCamera The camera we are returning the max for
  76728. * @returns the depth max z
  76729. */
  76730. getDepthMaxZ(activeCamera: Camera): number;
  76731. }
  76732. /**
  76733. * Base implementation IShadowLight
  76734. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76735. */
  76736. export abstract class ShadowLight extends Light implements IShadowLight {
  76737. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76738. protected _position: Vector3;
  76739. protected _setPosition(value: Vector3): void;
  76740. /**
  76741. * Sets the position the shadow will be casted from. Also use as the light position for both
  76742. * point and spot lights.
  76743. */
  76744. /**
  76745. * Sets the position the shadow will be casted from. Also use as the light position for both
  76746. * point and spot lights.
  76747. */
  76748. position: Vector3;
  76749. protected _direction: Vector3;
  76750. protected _setDirection(value: Vector3): void;
  76751. /**
  76752. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76753. * Also use as the light direction on spot and directional lights.
  76754. */
  76755. /**
  76756. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76757. * Also use as the light direction on spot and directional lights.
  76758. */
  76759. direction: Vector3;
  76760. private _shadowMinZ;
  76761. /**
  76762. * Gets the shadow projection clipping minimum z value.
  76763. */
  76764. /**
  76765. * Sets the shadow projection clipping minimum z value.
  76766. */
  76767. shadowMinZ: number;
  76768. private _shadowMaxZ;
  76769. /**
  76770. * Sets the shadow projection clipping maximum z value.
  76771. */
  76772. /**
  76773. * Gets the shadow projection clipping maximum z value.
  76774. */
  76775. shadowMaxZ: number;
  76776. /**
  76777. * Callback defining a custom Projection Matrix Builder.
  76778. * This can be used to override the default projection matrix computation.
  76779. */
  76780. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76781. /**
  76782. * The transformed position. Position of the light in world space taking parenting in account.
  76783. */
  76784. transformedPosition: Vector3;
  76785. /**
  76786. * The transformed direction. Direction of the light in world space taking parenting in account.
  76787. */
  76788. transformedDirection: Vector3;
  76789. private _needProjectionMatrixCompute;
  76790. /**
  76791. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76792. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76793. */
  76794. computeTransformedInformation(): boolean;
  76795. /**
  76796. * Return the depth scale used for the shadow map.
  76797. * @returns the depth scale.
  76798. */
  76799. getDepthScale(): number;
  76800. /**
  76801. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76802. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76803. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76804. */
  76805. getShadowDirection(faceIndex?: number): Vector3;
  76806. /**
  76807. * Returns the ShadowLight absolute position in the World.
  76808. * @returns the position vector in world space
  76809. */
  76810. getAbsolutePosition(): Vector3;
  76811. /**
  76812. * Sets the ShadowLight direction toward the passed target.
  76813. * @param target The point to target in local space
  76814. * @returns the updated ShadowLight direction
  76815. */
  76816. setDirectionToTarget(target: Vector3): Vector3;
  76817. /**
  76818. * Returns the light rotation in euler definition.
  76819. * @returns the x y z rotation in local space.
  76820. */
  76821. getRotation(): Vector3;
  76822. /**
  76823. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76824. * @returns true if a cube texture needs to be use
  76825. */
  76826. needCube(): boolean;
  76827. /**
  76828. * Detects if the projection matrix requires to be recomputed this frame.
  76829. * @returns true if it requires to be recomputed otherwise, false.
  76830. */
  76831. needProjectionMatrixCompute(): boolean;
  76832. /**
  76833. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76834. */
  76835. forceProjectionMatrixCompute(): void;
  76836. /** @hidden */
  76837. _initCache(): void;
  76838. /** @hidden */
  76839. _isSynchronized(): boolean;
  76840. /**
  76841. * Computes the world matrix of the node
  76842. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76843. * @returns the world matrix
  76844. */
  76845. computeWorldMatrix(force?: boolean): Matrix;
  76846. /**
  76847. * Gets the minZ used for shadow according to both the scene and the light.
  76848. * @param activeCamera The camera we are returning the min for
  76849. * @returns the depth min z
  76850. */
  76851. getDepthMinZ(activeCamera: Camera): number;
  76852. /**
  76853. * Gets the maxZ used for shadow according to both the scene and the light.
  76854. * @param activeCamera The camera we are returning the max for
  76855. * @returns the depth max z
  76856. */
  76857. getDepthMaxZ(activeCamera: Camera): number;
  76858. /**
  76859. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76860. * @param matrix The materix to updated with the projection information
  76861. * @param viewMatrix The transform matrix of the light
  76862. * @param renderList The list of mesh to render in the map
  76863. * @returns The current light
  76864. */
  76865. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76866. }
  76867. }
  76868. declare module BABYLON {
  76869. /**
  76870. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76871. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76872. */
  76873. export class EffectFallbacks implements IEffectFallbacks {
  76874. private _defines;
  76875. private _currentRank;
  76876. private _maxRank;
  76877. private _mesh;
  76878. /**
  76879. * Removes the fallback from the bound mesh.
  76880. */
  76881. unBindMesh(): void;
  76882. /**
  76883. * Adds a fallback on the specified property.
  76884. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76885. * @param define The name of the define in the shader
  76886. */
  76887. addFallback(rank: number, define: string): void;
  76888. /**
  76889. * Sets the mesh to use CPU skinning when needing to fallback.
  76890. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76891. * @param mesh The mesh to use the fallbacks.
  76892. */
  76893. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76894. /**
  76895. * Checks to see if more fallbacks are still availible.
  76896. */
  76897. readonly hasMoreFallbacks: boolean;
  76898. /**
  76899. * Removes the defines that should be removed when falling back.
  76900. * @param currentDefines defines the current define statements for the shader.
  76901. * @param effect defines the current effect we try to compile
  76902. * @returns The resulting defines with defines of the current rank removed.
  76903. */
  76904. reduce(currentDefines: string, effect: Effect): string;
  76905. }
  76906. }
  76907. declare module BABYLON {
  76908. /**
  76909. * "Static Class" containing the most commonly used helper while dealing with material for
  76910. * rendering purpose.
  76911. *
  76912. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76913. *
  76914. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76915. */
  76916. export class MaterialHelper {
  76917. /**
  76918. * Bind the current view position to an effect.
  76919. * @param effect The effect to be bound
  76920. * @param scene The scene the eyes position is used from
  76921. */
  76922. static BindEyePosition(effect: Effect, scene: Scene): void;
  76923. /**
  76924. * Helps preparing the defines values about the UVs in used in the effect.
  76925. * UVs are shared as much as we can accross channels in the shaders.
  76926. * @param texture The texture we are preparing the UVs for
  76927. * @param defines The defines to update
  76928. * @param key The channel key "diffuse", "specular"... used in the shader
  76929. */
  76930. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76931. /**
  76932. * Binds a texture matrix value to its corrsponding uniform
  76933. * @param texture The texture to bind the matrix for
  76934. * @param uniformBuffer The uniform buffer receivin the data
  76935. * @param key The channel key "diffuse", "specular"... used in the shader
  76936. */
  76937. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76938. /**
  76939. * Gets the current status of the fog (should it be enabled?)
  76940. * @param mesh defines the mesh to evaluate for fog support
  76941. * @param scene defines the hosting scene
  76942. * @returns true if fog must be enabled
  76943. */
  76944. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76945. /**
  76946. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76947. * @param mesh defines the current mesh
  76948. * @param scene defines the current scene
  76949. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76950. * @param pointsCloud defines if point cloud rendering has to be turned on
  76951. * @param fogEnabled defines if fog has to be turned on
  76952. * @param alphaTest defines if alpha testing has to be turned on
  76953. * @param defines defines the current list of defines
  76954. */
  76955. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76956. /**
  76957. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76958. * @param scene defines the current scene
  76959. * @param engine defines the current engine
  76960. * @param defines specifies the list of active defines
  76961. * @param useInstances defines if instances have to be turned on
  76962. * @param useClipPlane defines if clip plane have to be turned on
  76963. */
  76964. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76965. /**
  76966. * Prepares the defines for bones
  76967. * @param mesh The mesh containing the geometry data we will draw
  76968. * @param defines The defines to update
  76969. */
  76970. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76971. /**
  76972. * Prepares the defines for morph targets
  76973. * @param mesh The mesh containing the geometry data we will draw
  76974. * @param defines The defines to update
  76975. */
  76976. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76977. /**
  76978. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76979. * @param mesh The mesh containing the geometry data we will draw
  76980. * @param defines The defines to update
  76981. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76982. * @param useBones Precise whether bones should be used or not (override mesh info)
  76983. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76984. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76985. * @returns false if defines are considered not dirty and have not been checked
  76986. */
  76987. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76988. /**
  76989. * Prepares the defines related to multiview
  76990. * @param scene The scene we are intending to draw
  76991. * @param defines The defines to update
  76992. */
  76993. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76994. /**
  76995. * Prepares the defines related to the light information passed in parameter
  76996. * @param scene The scene we are intending to draw
  76997. * @param mesh The mesh the effect is compiling for
  76998. * @param light The light the effect is compiling for
  76999. * @param lightIndex The index of the light
  77000. * @param defines The defines to update
  77001. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77002. * @param state Defines the current state regarding what is needed (normals, etc...)
  77003. */
  77004. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77005. needNormals: boolean;
  77006. needRebuild: boolean;
  77007. shadowEnabled: boolean;
  77008. specularEnabled: boolean;
  77009. lightmapMode: boolean;
  77010. }): void;
  77011. /**
  77012. * Prepares the defines related to the light information passed in parameter
  77013. * @param scene The scene we are intending to draw
  77014. * @param mesh The mesh the effect is compiling for
  77015. * @param defines The defines to update
  77016. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77017. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77018. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77019. * @returns true if normals will be required for the rest of the effect
  77020. */
  77021. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77022. /**
  77023. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77024. * @param lightIndex defines the light index
  77025. * @param uniformsList The uniform list
  77026. * @param samplersList The sampler list
  77027. * @param projectedLightTexture defines if projected texture must be used
  77028. * @param uniformBuffersList defines an optional list of uniform buffers
  77029. */
  77030. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77031. /**
  77032. * Prepares the uniforms and samplers list to be used in the effect
  77033. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77034. * @param samplersList The sampler list
  77035. * @param defines The defines helping in the list generation
  77036. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77037. */
  77038. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77039. /**
  77040. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77041. * @param defines The defines to update while falling back
  77042. * @param fallbacks The authorized effect fallbacks
  77043. * @param maxSimultaneousLights The maximum number of lights allowed
  77044. * @param rank the current rank of the Effect
  77045. * @returns The newly affected rank
  77046. */
  77047. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77048. private static _TmpMorphInfluencers;
  77049. /**
  77050. * Prepares the list of attributes required for morph targets according to the effect defines.
  77051. * @param attribs The current list of supported attribs
  77052. * @param mesh The mesh to prepare the morph targets attributes for
  77053. * @param influencers The number of influencers
  77054. */
  77055. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77056. /**
  77057. * Prepares the list of attributes required for morph targets according to the effect defines.
  77058. * @param attribs The current list of supported attribs
  77059. * @param mesh The mesh to prepare the morph targets attributes for
  77060. * @param defines The current Defines of the effect
  77061. */
  77062. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77063. /**
  77064. * Prepares the list of attributes required for bones according to the effect defines.
  77065. * @param attribs The current list of supported attribs
  77066. * @param mesh The mesh to prepare the bones attributes for
  77067. * @param defines The current Defines of the effect
  77068. * @param fallbacks The current efffect fallback strategy
  77069. */
  77070. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77071. /**
  77072. * Check and prepare the list of attributes required for instances according to the effect defines.
  77073. * @param attribs The current list of supported attribs
  77074. * @param defines The current MaterialDefines of the effect
  77075. */
  77076. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77077. /**
  77078. * Add the list of attributes required for instances to the attribs array.
  77079. * @param attribs The current list of supported attribs
  77080. */
  77081. static PushAttributesForInstances(attribs: string[]): void;
  77082. /**
  77083. * Binds the light information to the effect.
  77084. * @param light The light containing the generator
  77085. * @param effect The effect we are binding the data to
  77086. * @param lightIndex The light index in the effect used to render
  77087. */
  77088. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77089. /**
  77090. * Binds the lights information from the scene to the effect for the given mesh.
  77091. * @param light Light to bind
  77092. * @param lightIndex Light index
  77093. * @param scene The scene where the light belongs to
  77094. * @param effect The effect we are binding the data to
  77095. * @param useSpecular Defines if specular is supported
  77096. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77097. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77098. */
  77099. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77100. /**
  77101. * Binds the lights information from the scene to the effect for the given mesh.
  77102. * @param scene The scene the lights belongs to
  77103. * @param mesh The mesh we are binding the information to render
  77104. * @param effect The effect we are binding the data to
  77105. * @param defines The generated defines for the effect
  77106. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77107. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77108. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77109. */
  77110. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77111. private static _tempFogColor;
  77112. /**
  77113. * Binds the fog information from the scene to the effect for the given mesh.
  77114. * @param scene The scene the lights belongs to
  77115. * @param mesh The mesh we are binding the information to render
  77116. * @param effect The effect we are binding the data to
  77117. * @param linearSpace Defines if the fog effect is applied in linear space
  77118. */
  77119. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77120. /**
  77121. * Binds the bones information from the mesh to the effect.
  77122. * @param mesh The mesh we are binding the information to render
  77123. * @param effect The effect we are binding the data to
  77124. */
  77125. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77126. /**
  77127. * Binds the morph targets information from the mesh to the effect.
  77128. * @param abstractMesh The mesh we are binding the information to render
  77129. * @param effect The effect we are binding the data to
  77130. */
  77131. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77132. /**
  77133. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77134. * @param defines The generated defines used in the effect
  77135. * @param effect The effect we are binding the data to
  77136. * @param scene The scene we are willing to render with logarithmic scale for
  77137. */
  77138. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77139. /**
  77140. * Binds the clip plane information from the scene to the effect.
  77141. * @param scene The scene the clip plane information are extracted from
  77142. * @param effect The effect we are binding the data to
  77143. */
  77144. static BindClipPlane(effect: Effect, scene: Scene): void;
  77145. }
  77146. }
  77147. declare module BABYLON {
  77148. /** @hidden */
  77149. export var packingFunctions: {
  77150. name: string;
  77151. shader: string;
  77152. };
  77153. }
  77154. declare module BABYLON {
  77155. /** @hidden */
  77156. export var shadowMapPixelShader: {
  77157. name: string;
  77158. shader: string;
  77159. };
  77160. }
  77161. declare module BABYLON {
  77162. /** @hidden */
  77163. export var bonesDeclaration: {
  77164. name: string;
  77165. shader: string;
  77166. };
  77167. }
  77168. declare module BABYLON {
  77169. /** @hidden */
  77170. export var morphTargetsVertexGlobalDeclaration: {
  77171. name: string;
  77172. shader: string;
  77173. };
  77174. }
  77175. declare module BABYLON {
  77176. /** @hidden */
  77177. export var morphTargetsVertexDeclaration: {
  77178. name: string;
  77179. shader: string;
  77180. };
  77181. }
  77182. declare module BABYLON {
  77183. /** @hidden */
  77184. export var instancesDeclaration: {
  77185. name: string;
  77186. shader: string;
  77187. };
  77188. }
  77189. declare module BABYLON {
  77190. /** @hidden */
  77191. export var helperFunctions: {
  77192. name: string;
  77193. shader: string;
  77194. };
  77195. }
  77196. declare module BABYLON {
  77197. /** @hidden */
  77198. export var morphTargetsVertex: {
  77199. name: string;
  77200. shader: string;
  77201. };
  77202. }
  77203. declare module BABYLON {
  77204. /** @hidden */
  77205. export var instancesVertex: {
  77206. name: string;
  77207. shader: string;
  77208. };
  77209. }
  77210. declare module BABYLON {
  77211. /** @hidden */
  77212. export var bonesVertex: {
  77213. name: string;
  77214. shader: string;
  77215. };
  77216. }
  77217. declare module BABYLON {
  77218. /** @hidden */
  77219. export var shadowMapVertexShader: {
  77220. name: string;
  77221. shader: string;
  77222. };
  77223. }
  77224. declare module BABYLON {
  77225. /** @hidden */
  77226. export var depthBoxBlurPixelShader: {
  77227. name: string;
  77228. shader: string;
  77229. };
  77230. }
  77231. declare module BABYLON {
  77232. /**
  77233. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77234. */
  77235. export interface ICustomShaderOptions {
  77236. /**
  77237. * Gets or sets the custom shader name to use
  77238. */
  77239. shaderName: string;
  77240. /**
  77241. * The list of attribute names used in the shader
  77242. */
  77243. attributes?: string[];
  77244. /**
  77245. * The list of unifrom names used in the shader
  77246. */
  77247. uniforms?: string[];
  77248. /**
  77249. * The list of sampler names used in the shader
  77250. */
  77251. samplers?: string[];
  77252. /**
  77253. * The list of defines used in the shader
  77254. */
  77255. defines?: string[];
  77256. }
  77257. /**
  77258. * Interface to implement to create a shadow generator compatible with BJS.
  77259. */
  77260. export interface IShadowGenerator {
  77261. /**
  77262. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77263. * @returns The render target texture if present otherwise, null
  77264. */
  77265. getShadowMap(): Nullable<RenderTargetTexture>;
  77266. /**
  77267. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77268. * @returns The render target texture if the shadow map is present otherwise, null
  77269. */
  77270. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77271. /**
  77272. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77273. * @param subMesh The submesh we want to render in the shadow map
  77274. * @param useInstances Defines wether will draw in the map using instances
  77275. * @returns true if ready otherwise, false
  77276. */
  77277. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77278. /**
  77279. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77280. * @param defines Defines of the material we want to update
  77281. * @param lightIndex Index of the light in the enabled light list of the material
  77282. */
  77283. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77284. /**
  77285. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77286. * defined in the generator but impacting the effect).
  77287. * It implies the unifroms available on the materials are the standard BJS ones.
  77288. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77289. * @param effect The effect we are binfing the information for
  77290. */
  77291. bindShadowLight(lightIndex: string, effect: Effect): void;
  77292. /**
  77293. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77294. * (eq to shadow prjection matrix * light transform matrix)
  77295. * @returns The transform matrix used to create the shadow map
  77296. */
  77297. getTransformMatrix(): Matrix;
  77298. /**
  77299. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77300. * Cube and 2D textures for instance.
  77301. */
  77302. recreateShadowMap(): void;
  77303. /**
  77304. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77305. * @param onCompiled Callback triggered at the and of the effects compilation
  77306. * @param options Sets of optional options forcing the compilation with different modes
  77307. */
  77308. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77309. useInstances: boolean;
  77310. }>): void;
  77311. /**
  77312. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77313. * @param options Sets of optional options forcing the compilation with different modes
  77314. * @returns A promise that resolves when the compilation completes
  77315. */
  77316. forceCompilationAsync(options?: Partial<{
  77317. useInstances: boolean;
  77318. }>): Promise<void>;
  77319. /**
  77320. * Serializes the shadow generator setup to a json object.
  77321. * @returns The serialized JSON object
  77322. */
  77323. serialize(): any;
  77324. /**
  77325. * Disposes the Shadow map and related Textures and effects.
  77326. */
  77327. dispose(): void;
  77328. }
  77329. /**
  77330. * Default implementation IShadowGenerator.
  77331. * This is the main object responsible of generating shadows in the framework.
  77332. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77333. */
  77334. export class ShadowGenerator implements IShadowGenerator {
  77335. /**
  77336. * Shadow generator mode None: no filtering applied.
  77337. */
  77338. static readonly FILTER_NONE: number;
  77339. /**
  77340. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77342. */
  77343. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77344. /**
  77345. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77346. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77347. */
  77348. static readonly FILTER_POISSONSAMPLING: number;
  77349. /**
  77350. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77351. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77352. */
  77353. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77354. /**
  77355. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77356. * edge artifacts on steep falloff.
  77357. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77358. */
  77359. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77360. /**
  77361. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77362. * edge artifacts on steep falloff.
  77363. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77364. */
  77365. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77366. /**
  77367. * Shadow generator mode PCF: Percentage Closer Filtering
  77368. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77369. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77370. */
  77371. static readonly FILTER_PCF: number;
  77372. /**
  77373. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77374. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77375. * Contact Hardening
  77376. */
  77377. static readonly FILTER_PCSS: number;
  77378. /**
  77379. * Reserved for PCF and PCSS
  77380. * Highest Quality.
  77381. *
  77382. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77383. *
  77384. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77385. */
  77386. static readonly QUALITY_HIGH: number;
  77387. /**
  77388. * Reserved for PCF and PCSS
  77389. * Good tradeoff for quality/perf cross devices
  77390. *
  77391. * Execute PCF on a 3*3 kernel.
  77392. *
  77393. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77394. */
  77395. static readonly QUALITY_MEDIUM: number;
  77396. /**
  77397. * Reserved for PCF and PCSS
  77398. * The lowest quality but the fastest.
  77399. *
  77400. * Execute PCF on a 1*1 kernel.
  77401. *
  77402. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77403. */
  77404. static readonly QUALITY_LOW: number;
  77405. /** Gets or sets the custom shader name to use */
  77406. customShaderOptions: ICustomShaderOptions;
  77407. /**
  77408. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77409. */
  77410. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77411. /**
  77412. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77413. */
  77414. onAfterShadowMapRenderObservable: Observable<Effect>;
  77415. /**
  77416. * Observable triggered before a mesh is rendered in the shadow map.
  77417. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77418. */
  77419. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77420. /**
  77421. * Observable triggered after a mesh is rendered in the shadow map.
  77422. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77423. */
  77424. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77425. private _bias;
  77426. /**
  77427. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77428. */
  77429. /**
  77430. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77431. */
  77432. bias: number;
  77433. private _normalBias;
  77434. /**
  77435. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77436. */
  77437. /**
  77438. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77439. */
  77440. normalBias: number;
  77441. private _blurBoxOffset;
  77442. /**
  77443. * Gets the blur box offset: offset applied during the blur pass.
  77444. * Only useful if useKernelBlur = false
  77445. */
  77446. /**
  77447. * Sets the blur box offset: offset applied during the blur pass.
  77448. * Only useful if useKernelBlur = false
  77449. */
  77450. blurBoxOffset: number;
  77451. private _blurScale;
  77452. /**
  77453. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77454. * 2 means half of the size.
  77455. */
  77456. /**
  77457. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77458. * 2 means half of the size.
  77459. */
  77460. blurScale: number;
  77461. private _blurKernel;
  77462. /**
  77463. * Gets the blur kernel: kernel size of the blur pass.
  77464. * Only useful if useKernelBlur = true
  77465. */
  77466. /**
  77467. * Sets the blur kernel: kernel size of the blur pass.
  77468. * Only useful if useKernelBlur = true
  77469. */
  77470. blurKernel: number;
  77471. private _useKernelBlur;
  77472. /**
  77473. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77474. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77475. */
  77476. /**
  77477. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77478. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77479. */
  77480. useKernelBlur: boolean;
  77481. private _depthScale;
  77482. /**
  77483. * Gets the depth scale used in ESM mode.
  77484. */
  77485. /**
  77486. * Sets the depth scale used in ESM mode.
  77487. * This can override the scale stored on the light.
  77488. */
  77489. depthScale: number;
  77490. private _filter;
  77491. /**
  77492. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77493. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77494. */
  77495. /**
  77496. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77497. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77498. */
  77499. filter: number;
  77500. /**
  77501. * Gets if the current filter is set to Poisson Sampling.
  77502. */
  77503. /**
  77504. * Sets the current filter to Poisson Sampling.
  77505. */
  77506. usePoissonSampling: boolean;
  77507. /**
  77508. * Gets if the current filter is set to ESM.
  77509. */
  77510. /**
  77511. * Sets the current filter is to ESM.
  77512. */
  77513. useExponentialShadowMap: boolean;
  77514. /**
  77515. * Gets if the current filter is set to filtered ESM.
  77516. */
  77517. /**
  77518. * Gets if the current filter is set to filtered ESM.
  77519. */
  77520. useBlurExponentialShadowMap: boolean;
  77521. /**
  77522. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77523. * exponential to prevent steep falloff artifacts).
  77524. */
  77525. /**
  77526. * Sets the current filter to "close ESM" (using the inverse of the
  77527. * exponential to prevent steep falloff artifacts).
  77528. */
  77529. useCloseExponentialShadowMap: boolean;
  77530. /**
  77531. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77532. * exponential to prevent steep falloff artifacts).
  77533. */
  77534. /**
  77535. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77536. * exponential to prevent steep falloff artifacts).
  77537. */
  77538. useBlurCloseExponentialShadowMap: boolean;
  77539. /**
  77540. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77541. */
  77542. /**
  77543. * Sets the current filter to "PCF" (percentage closer filtering).
  77544. */
  77545. usePercentageCloserFiltering: boolean;
  77546. private _filteringQuality;
  77547. /**
  77548. * Gets the PCF or PCSS Quality.
  77549. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77550. */
  77551. /**
  77552. * Sets the PCF or PCSS Quality.
  77553. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77554. */
  77555. filteringQuality: number;
  77556. /**
  77557. * Gets if the current filter is set to "PCSS" (contact hardening).
  77558. */
  77559. /**
  77560. * Sets the current filter to "PCSS" (contact hardening).
  77561. */
  77562. useContactHardeningShadow: boolean;
  77563. private _contactHardeningLightSizeUVRatio;
  77564. /**
  77565. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77566. * Using a ratio helps keeping shape stability independently of the map size.
  77567. *
  77568. * It does not account for the light projection as it was having too much
  77569. * instability during the light setup or during light position changes.
  77570. *
  77571. * Only valid if useContactHardeningShadow is true.
  77572. */
  77573. /**
  77574. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77575. * Using a ratio helps keeping shape stability independently of the map size.
  77576. *
  77577. * It does not account for the light projection as it was having too much
  77578. * instability during the light setup or during light position changes.
  77579. *
  77580. * Only valid if useContactHardeningShadow is true.
  77581. */
  77582. contactHardeningLightSizeUVRatio: number;
  77583. private _darkness;
  77584. /** Gets or sets the actual darkness of a shadow */
  77585. darkness: number;
  77586. /**
  77587. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77588. * 0 means strongest and 1 would means no shadow.
  77589. * @returns the darkness.
  77590. */
  77591. getDarkness(): number;
  77592. /**
  77593. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77594. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77595. * @returns the shadow generator allowing fluent coding.
  77596. */
  77597. setDarkness(darkness: number): ShadowGenerator;
  77598. private _transparencyShadow;
  77599. /** Gets or sets the ability to have transparent shadow */
  77600. transparencyShadow: boolean;
  77601. /**
  77602. * Sets the ability to have transparent shadow (boolean).
  77603. * @param transparent True if transparent else False
  77604. * @returns the shadow generator allowing fluent coding
  77605. */
  77606. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77607. private _shadowMap;
  77608. private _shadowMap2;
  77609. /**
  77610. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77611. * @returns The render target texture if present otherwise, null
  77612. */
  77613. getShadowMap(): Nullable<RenderTargetTexture>;
  77614. /**
  77615. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77616. * @returns The render target texture if the shadow map is present otherwise, null
  77617. */
  77618. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77619. /**
  77620. * Gets the class name of that object
  77621. * @returns "ShadowGenerator"
  77622. */
  77623. getClassName(): string;
  77624. /**
  77625. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77626. * @param mesh Mesh to add
  77627. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77628. * @returns the Shadow Generator itself
  77629. */
  77630. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77631. /**
  77632. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77633. * @param mesh Mesh to remove
  77634. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77635. * @returns the Shadow Generator itself
  77636. */
  77637. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77638. /**
  77639. * Controls the extent to which the shadows fade out at the edge of the frustum
  77640. * Used only by directionals and spots
  77641. */
  77642. frustumEdgeFalloff: number;
  77643. private _light;
  77644. /**
  77645. * Returns the associated light object.
  77646. * @returns the light generating the shadow
  77647. */
  77648. getLight(): IShadowLight;
  77649. /**
  77650. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77651. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77652. * It might on the other hand introduce peter panning.
  77653. */
  77654. forceBackFacesOnly: boolean;
  77655. private _scene;
  77656. private _lightDirection;
  77657. private _effect;
  77658. private _viewMatrix;
  77659. private _projectionMatrix;
  77660. private _transformMatrix;
  77661. private _cachedPosition;
  77662. private _cachedDirection;
  77663. private _cachedDefines;
  77664. private _currentRenderID;
  77665. private _boxBlurPostprocess;
  77666. private _kernelBlurXPostprocess;
  77667. private _kernelBlurYPostprocess;
  77668. private _blurPostProcesses;
  77669. private _mapSize;
  77670. private _currentFaceIndex;
  77671. private _currentFaceIndexCache;
  77672. private _textureType;
  77673. private _defaultTextureMatrix;
  77674. private _storedUniqueId;
  77675. /** @hidden */
  77676. static _SceneComponentInitialization: (scene: Scene) => void;
  77677. /**
  77678. * Creates a ShadowGenerator object.
  77679. * A ShadowGenerator is the required tool to use the shadows.
  77680. * Each light casting shadows needs to use its own ShadowGenerator.
  77681. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77682. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77683. * @param light The light object generating the shadows.
  77684. * @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.
  77685. */
  77686. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77687. private _initializeGenerator;
  77688. private _initializeShadowMap;
  77689. private _initializeBlurRTTAndPostProcesses;
  77690. private _renderForShadowMap;
  77691. private _renderSubMeshForShadowMap;
  77692. private _applyFilterValues;
  77693. /**
  77694. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77695. * @param onCompiled Callback triggered at the and of the effects compilation
  77696. * @param options Sets of optional options forcing the compilation with different modes
  77697. */
  77698. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77699. useInstances: boolean;
  77700. }>): void;
  77701. /**
  77702. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77703. * @param options Sets of optional options forcing the compilation with different modes
  77704. * @returns A promise that resolves when the compilation completes
  77705. */
  77706. forceCompilationAsync(options?: Partial<{
  77707. useInstances: boolean;
  77708. }>): Promise<void>;
  77709. /**
  77710. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77711. * @param subMesh The submesh we want to render in the shadow map
  77712. * @param useInstances Defines wether will draw in the map using instances
  77713. * @returns true if ready otherwise, false
  77714. */
  77715. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77716. /**
  77717. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77718. * @param defines Defines of the material we want to update
  77719. * @param lightIndex Index of the light in the enabled light list of the material
  77720. */
  77721. prepareDefines(defines: any, lightIndex: number): void;
  77722. /**
  77723. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77724. * defined in the generator but impacting the effect).
  77725. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77726. * @param effect The effect we are binfing the information for
  77727. */
  77728. bindShadowLight(lightIndex: string, effect: Effect): void;
  77729. /**
  77730. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77731. * (eq to shadow prjection matrix * light transform matrix)
  77732. * @returns The transform matrix used to create the shadow map
  77733. */
  77734. getTransformMatrix(): Matrix;
  77735. /**
  77736. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77737. * Cube and 2D textures for instance.
  77738. */
  77739. recreateShadowMap(): void;
  77740. private _disposeBlurPostProcesses;
  77741. private _disposeRTTandPostProcesses;
  77742. /**
  77743. * Disposes the ShadowGenerator.
  77744. * Returns nothing.
  77745. */
  77746. dispose(): void;
  77747. /**
  77748. * Serializes the shadow generator setup to a json object.
  77749. * @returns The serialized JSON object
  77750. */
  77751. serialize(): any;
  77752. /**
  77753. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77754. * @param parsedShadowGenerator The JSON object to parse
  77755. * @param scene The scene to create the shadow map for
  77756. * @returns The parsed shadow generator
  77757. */
  77758. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77759. }
  77760. }
  77761. declare module BABYLON {
  77762. /**
  77763. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77764. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77765. * 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.
  77766. */
  77767. export abstract class Light extends Node {
  77768. /**
  77769. * Falloff Default: light is falling off following the material specification:
  77770. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77771. */
  77772. static readonly FALLOFF_DEFAULT: number;
  77773. /**
  77774. * Falloff Physical: light is falling off following the inverse squared distance law.
  77775. */
  77776. static readonly FALLOFF_PHYSICAL: number;
  77777. /**
  77778. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77779. * to enhance interoperability with other engines.
  77780. */
  77781. static readonly FALLOFF_GLTF: number;
  77782. /**
  77783. * Falloff Standard: light is falling off like in the standard material
  77784. * to enhance interoperability with other materials.
  77785. */
  77786. static readonly FALLOFF_STANDARD: number;
  77787. /**
  77788. * If every light affecting the material is in this lightmapMode,
  77789. * material.lightmapTexture adds or multiplies
  77790. * (depends on material.useLightmapAsShadowmap)
  77791. * after every other light calculations.
  77792. */
  77793. static readonly LIGHTMAP_DEFAULT: number;
  77794. /**
  77795. * material.lightmapTexture as only diffuse lighting from this light
  77796. * adds only specular lighting from this light
  77797. * adds dynamic shadows
  77798. */
  77799. static readonly LIGHTMAP_SPECULAR: number;
  77800. /**
  77801. * material.lightmapTexture as only lighting
  77802. * no light calculation from this light
  77803. * only adds dynamic shadows from this light
  77804. */
  77805. static readonly LIGHTMAP_SHADOWSONLY: number;
  77806. /**
  77807. * Each light type uses the default quantity according to its type:
  77808. * point/spot lights use luminous intensity
  77809. * directional lights use illuminance
  77810. */
  77811. static readonly INTENSITYMODE_AUTOMATIC: number;
  77812. /**
  77813. * lumen (lm)
  77814. */
  77815. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77816. /**
  77817. * candela (lm/sr)
  77818. */
  77819. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77820. /**
  77821. * lux (lm/m^2)
  77822. */
  77823. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77824. /**
  77825. * nit (cd/m^2)
  77826. */
  77827. static readonly INTENSITYMODE_LUMINANCE: number;
  77828. /**
  77829. * Light type const id of the point light.
  77830. */
  77831. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77832. /**
  77833. * Light type const id of the directional light.
  77834. */
  77835. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77836. /**
  77837. * Light type const id of the spot light.
  77838. */
  77839. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77840. /**
  77841. * Light type const id of the hemispheric light.
  77842. */
  77843. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77844. /**
  77845. * Diffuse gives the basic color to an object.
  77846. */
  77847. diffuse: Color3;
  77848. /**
  77849. * Specular produces a highlight color on an object.
  77850. * Note: This is note affecting PBR materials.
  77851. */
  77852. specular: Color3;
  77853. /**
  77854. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77855. * falling off base on range or angle.
  77856. * This can be set to any values in Light.FALLOFF_x.
  77857. *
  77858. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77859. * other types of materials.
  77860. */
  77861. falloffType: number;
  77862. /**
  77863. * Strength of the light.
  77864. * Note: By default it is define in the framework own unit.
  77865. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77866. */
  77867. intensity: number;
  77868. private _range;
  77869. protected _inverseSquaredRange: number;
  77870. /**
  77871. * Defines how far from the source the light is impacting in scene units.
  77872. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77873. */
  77874. /**
  77875. * Defines how far from the source the light is impacting in scene units.
  77876. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77877. */
  77878. range: number;
  77879. /**
  77880. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77881. * of light.
  77882. */
  77883. private _photometricScale;
  77884. private _intensityMode;
  77885. /**
  77886. * Gets the photometric scale used to interpret the intensity.
  77887. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77888. */
  77889. /**
  77890. * Sets the photometric scale used to interpret the intensity.
  77891. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77892. */
  77893. intensityMode: number;
  77894. private _radius;
  77895. /**
  77896. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77897. */
  77898. /**
  77899. * sets the light radius used by PBR Materials to simulate soft area lights.
  77900. */
  77901. radius: number;
  77902. private _renderPriority;
  77903. /**
  77904. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77905. * exceeding the number allowed of the materials.
  77906. */
  77907. renderPriority: number;
  77908. private _shadowEnabled;
  77909. /**
  77910. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77911. * the current shadow generator.
  77912. */
  77913. /**
  77914. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77915. * the current shadow generator.
  77916. */
  77917. shadowEnabled: boolean;
  77918. private _includedOnlyMeshes;
  77919. /**
  77920. * Gets the only meshes impacted by this light.
  77921. */
  77922. /**
  77923. * Sets the only meshes impacted by this light.
  77924. */
  77925. includedOnlyMeshes: AbstractMesh[];
  77926. private _excludedMeshes;
  77927. /**
  77928. * Gets the meshes not impacted by this light.
  77929. */
  77930. /**
  77931. * Sets the meshes not impacted by this light.
  77932. */
  77933. excludedMeshes: AbstractMesh[];
  77934. private _excludeWithLayerMask;
  77935. /**
  77936. * Gets the layer id use to find what meshes are not impacted by the light.
  77937. * Inactive if 0
  77938. */
  77939. /**
  77940. * Sets the layer id use to find what meshes are not impacted by the light.
  77941. * Inactive if 0
  77942. */
  77943. excludeWithLayerMask: number;
  77944. private _includeOnlyWithLayerMask;
  77945. /**
  77946. * Gets the layer id use to find what meshes are impacted by the light.
  77947. * Inactive if 0
  77948. */
  77949. /**
  77950. * Sets the layer id use to find what meshes are impacted by the light.
  77951. * Inactive if 0
  77952. */
  77953. includeOnlyWithLayerMask: number;
  77954. private _lightmapMode;
  77955. /**
  77956. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77957. */
  77958. /**
  77959. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77960. */
  77961. lightmapMode: number;
  77962. /**
  77963. * Shadow generator associted to the light.
  77964. * @hidden Internal use only.
  77965. */
  77966. _shadowGenerator: Nullable<IShadowGenerator>;
  77967. /**
  77968. * @hidden Internal use only.
  77969. */
  77970. _excludedMeshesIds: string[];
  77971. /**
  77972. * @hidden Internal use only.
  77973. */
  77974. _includedOnlyMeshesIds: string[];
  77975. /**
  77976. * The current light unifom buffer.
  77977. * @hidden Internal use only.
  77978. */
  77979. _uniformBuffer: UniformBuffer;
  77980. /** @hidden */
  77981. _renderId: number;
  77982. /**
  77983. * Creates a Light object in the scene.
  77984. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77985. * @param name The firendly name of the light
  77986. * @param scene The scene the light belongs too
  77987. */
  77988. constructor(name: string, scene: Scene);
  77989. protected abstract _buildUniformLayout(): void;
  77990. /**
  77991. * Sets the passed Effect "effect" with the Light information.
  77992. * @param effect The effect to update
  77993. * @param lightIndex The index of the light in the effect to update
  77994. * @returns The light
  77995. */
  77996. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77997. /**
  77998. * Sets the passed Effect "effect" with the Light information.
  77999. * @param effect The effect to update
  78000. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78001. * @returns The light
  78002. */
  78003. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78004. /**
  78005. * Returns the string "Light".
  78006. * @returns the class name
  78007. */
  78008. getClassName(): string;
  78009. /** @hidden */
  78010. readonly _isLight: boolean;
  78011. /**
  78012. * Converts the light information to a readable string for debug purpose.
  78013. * @param fullDetails Supports for multiple levels of logging within scene loading
  78014. * @returns the human readable light info
  78015. */
  78016. toString(fullDetails?: boolean): string;
  78017. /** @hidden */
  78018. protected _syncParentEnabledState(): void;
  78019. /**
  78020. * Set the enabled state of this node.
  78021. * @param value - the new enabled state
  78022. */
  78023. setEnabled(value: boolean): void;
  78024. /**
  78025. * Returns the Light associated shadow generator if any.
  78026. * @return the associated shadow generator.
  78027. */
  78028. getShadowGenerator(): Nullable<IShadowGenerator>;
  78029. /**
  78030. * Returns a Vector3, the absolute light position in the World.
  78031. * @returns the world space position of the light
  78032. */
  78033. getAbsolutePosition(): Vector3;
  78034. /**
  78035. * Specifies if the light will affect the passed mesh.
  78036. * @param mesh The mesh to test against the light
  78037. * @return true the mesh is affected otherwise, false.
  78038. */
  78039. canAffectMesh(mesh: AbstractMesh): boolean;
  78040. /**
  78041. * Sort function to order lights for rendering.
  78042. * @param a First Light object to compare to second.
  78043. * @param b Second Light object to compare first.
  78044. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78045. */
  78046. static CompareLightsPriority(a: Light, b: Light): number;
  78047. /**
  78048. * Releases resources associated with this node.
  78049. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78050. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78051. */
  78052. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78053. /**
  78054. * Returns the light type ID (integer).
  78055. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78056. */
  78057. getTypeID(): number;
  78058. /**
  78059. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78060. * @returns the scaled intensity in intensity mode unit
  78061. */
  78062. getScaledIntensity(): number;
  78063. /**
  78064. * Returns a new Light object, named "name", from the current one.
  78065. * @param name The name of the cloned light
  78066. * @returns the new created light
  78067. */
  78068. clone(name: string): Nullable<Light>;
  78069. /**
  78070. * Serializes the current light into a Serialization object.
  78071. * @returns the serialized object.
  78072. */
  78073. serialize(): any;
  78074. /**
  78075. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78076. * This new light is named "name" and added to the passed scene.
  78077. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78078. * @param name The friendly name of the light
  78079. * @param scene The scene the new light will belong to
  78080. * @returns the constructor function
  78081. */
  78082. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78083. /**
  78084. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78085. * @param parsedLight The JSON representation of the light
  78086. * @param scene The scene to create the parsed light in
  78087. * @returns the created light after parsing
  78088. */
  78089. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78090. private _hookArrayForExcluded;
  78091. private _hookArrayForIncludedOnly;
  78092. private _resyncMeshes;
  78093. /**
  78094. * Forces the meshes to update their light related information in their rendering used effects
  78095. * @hidden Internal Use Only
  78096. */
  78097. _markMeshesAsLightDirty(): void;
  78098. /**
  78099. * Recomputes the cached photometric scale if needed.
  78100. */
  78101. private _computePhotometricScale;
  78102. /**
  78103. * Returns the Photometric Scale according to the light type and intensity mode.
  78104. */
  78105. private _getPhotometricScale;
  78106. /**
  78107. * Reorder the light in the scene according to their defined priority.
  78108. * @hidden Internal Use Only
  78109. */
  78110. _reorderLightsInScene(): void;
  78111. /**
  78112. * Prepares the list of defines specific to the light type.
  78113. * @param defines the list of defines
  78114. * @param lightIndex defines the index of the light for the effect
  78115. */
  78116. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78117. }
  78118. }
  78119. declare module BABYLON {
  78120. /**
  78121. * Interface used to define Action
  78122. */
  78123. export interface IAction {
  78124. /**
  78125. * Trigger for the action
  78126. */
  78127. trigger: number;
  78128. /** Options of the trigger */
  78129. triggerOptions: any;
  78130. /**
  78131. * Gets the trigger parameters
  78132. * @returns the trigger parameters
  78133. */
  78134. getTriggerParameter(): any;
  78135. /**
  78136. * Internal only - executes current action event
  78137. * @hidden
  78138. */
  78139. _executeCurrent(evt?: ActionEvent): void;
  78140. /**
  78141. * Serialize placeholder for child classes
  78142. * @param parent of child
  78143. * @returns the serialized object
  78144. */
  78145. serialize(parent: any): any;
  78146. /**
  78147. * Internal only
  78148. * @hidden
  78149. */
  78150. _prepare(): void;
  78151. /**
  78152. * Internal only - manager for action
  78153. * @hidden
  78154. */
  78155. _actionManager: AbstractActionManager;
  78156. /**
  78157. * Adds action to chain of actions, may be a DoNothingAction
  78158. * @param action defines the next action to execute
  78159. * @returns The action passed in
  78160. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78161. */
  78162. then(action: IAction): IAction;
  78163. }
  78164. /**
  78165. * The action to be carried out following a trigger
  78166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78167. */
  78168. export class Action implements IAction {
  78169. /** the trigger, with or without parameters, for the action */
  78170. triggerOptions: any;
  78171. /**
  78172. * Trigger for the action
  78173. */
  78174. trigger: number;
  78175. /**
  78176. * Internal only - manager for action
  78177. * @hidden
  78178. */
  78179. _actionManager: ActionManager;
  78180. private _nextActiveAction;
  78181. private _child;
  78182. private _condition?;
  78183. private _triggerParameter;
  78184. /**
  78185. * An event triggered prior to action being executed.
  78186. */
  78187. onBeforeExecuteObservable: Observable<Action>;
  78188. /**
  78189. * Creates a new Action
  78190. * @param triggerOptions the trigger, with or without parameters, for the action
  78191. * @param condition an optional determinant of action
  78192. */
  78193. constructor(
  78194. /** the trigger, with or without parameters, for the action */
  78195. triggerOptions: any, condition?: Condition);
  78196. /**
  78197. * Internal only
  78198. * @hidden
  78199. */
  78200. _prepare(): void;
  78201. /**
  78202. * Gets the trigger parameters
  78203. * @returns the trigger parameters
  78204. */
  78205. getTriggerParameter(): any;
  78206. /**
  78207. * Internal only - executes current action event
  78208. * @hidden
  78209. */
  78210. _executeCurrent(evt?: ActionEvent): void;
  78211. /**
  78212. * Execute placeholder for child classes
  78213. * @param evt optional action event
  78214. */
  78215. execute(evt?: ActionEvent): void;
  78216. /**
  78217. * Skips to next active action
  78218. */
  78219. skipToNextActiveAction(): void;
  78220. /**
  78221. * Adds action to chain of actions, may be a DoNothingAction
  78222. * @param action defines the next action to execute
  78223. * @returns The action passed in
  78224. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78225. */
  78226. then(action: Action): Action;
  78227. /**
  78228. * Internal only
  78229. * @hidden
  78230. */
  78231. _getProperty(propertyPath: string): string;
  78232. /**
  78233. * Internal only
  78234. * @hidden
  78235. */
  78236. _getEffectiveTarget(target: any, propertyPath: string): any;
  78237. /**
  78238. * Serialize placeholder for child classes
  78239. * @param parent of child
  78240. * @returns the serialized object
  78241. */
  78242. serialize(parent: any): any;
  78243. /**
  78244. * Internal only called by serialize
  78245. * @hidden
  78246. */
  78247. protected _serialize(serializedAction: any, parent?: any): any;
  78248. /**
  78249. * Internal only
  78250. * @hidden
  78251. */
  78252. static _SerializeValueAsString: (value: any) => string;
  78253. /**
  78254. * Internal only
  78255. * @hidden
  78256. */
  78257. static _GetTargetProperty: (target: Node | Scene) => {
  78258. name: string;
  78259. targetType: string;
  78260. value: string;
  78261. };
  78262. }
  78263. }
  78264. declare module BABYLON {
  78265. /**
  78266. * A Condition applied to an Action
  78267. */
  78268. export class Condition {
  78269. /**
  78270. * Internal only - manager for action
  78271. * @hidden
  78272. */
  78273. _actionManager: ActionManager;
  78274. /**
  78275. * Internal only
  78276. * @hidden
  78277. */
  78278. _evaluationId: number;
  78279. /**
  78280. * Internal only
  78281. * @hidden
  78282. */
  78283. _currentResult: boolean;
  78284. /**
  78285. * Creates a new Condition
  78286. * @param actionManager the manager of the action the condition is applied to
  78287. */
  78288. constructor(actionManager: ActionManager);
  78289. /**
  78290. * Check if the current condition is valid
  78291. * @returns a boolean
  78292. */
  78293. isValid(): boolean;
  78294. /**
  78295. * Internal only
  78296. * @hidden
  78297. */
  78298. _getProperty(propertyPath: string): string;
  78299. /**
  78300. * Internal only
  78301. * @hidden
  78302. */
  78303. _getEffectiveTarget(target: any, propertyPath: string): any;
  78304. /**
  78305. * Serialize placeholder for child classes
  78306. * @returns the serialized object
  78307. */
  78308. serialize(): any;
  78309. /**
  78310. * Internal only
  78311. * @hidden
  78312. */
  78313. protected _serialize(serializedCondition: any): any;
  78314. }
  78315. /**
  78316. * Defines specific conditional operators as extensions of Condition
  78317. */
  78318. export class ValueCondition extends Condition {
  78319. /** path to specify the property of the target the conditional operator uses */
  78320. propertyPath: string;
  78321. /** the value compared by the conditional operator against the current value of the property */
  78322. value: any;
  78323. /** the conditional operator, default ValueCondition.IsEqual */
  78324. operator: number;
  78325. /**
  78326. * Internal only
  78327. * @hidden
  78328. */
  78329. private static _IsEqual;
  78330. /**
  78331. * Internal only
  78332. * @hidden
  78333. */
  78334. private static _IsDifferent;
  78335. /**
  78336. * Internal only
  78337. * @hidden
  78338. */
  78339. private static _IsGreater;
  78340. /**
  78341. * Internal only
  78342. * @hidden
  78343. */
  78344. private static _IsLesser;
  78345. /**
  78346. * returns the number for IsEqual
  78347. */
  78348. static readonly IsEqual: number;
  78349. /**
  78350. * Returns the number for IsDifferent
  78351. */
  78352. static readonly IsDifferent: number;
  78353. /**
  78354. * Returns the number for IsGreater
  78355. */
  78356. static readonly IsGreater: number;
  78357. /**
  78358. * Returns the number for IsLesser
  78359. */
  78360. static readonly IsLesser: number;
  78361. /**
  78362. * Internal only The action manager for the condition
  78363. * @hidden
  78364. */
  78365. _actionManager: ActionManager;
  78366. /**
  78367. * Internal only
  78368. * @hidden
  78369. */
  78370. private _target;
  78371. /**
  78372. * Internal only
  78373. * @hidden
  78374. */
  78375. private _effectiveTarget;
  78376. /**
  78377. * Internal only
  78378. * @hidden
  78379. */
  78380. private _property;
  78381. /**
  78382. * Creates a new ValueCondition
  78383. * @param actionManager manager for the action the condition applies to
  78384. * @param target for the action
  78385. * @param propertyPath path to specify the property of the target the conditional operator uses
  78386. * @param value the value compared by the conditional operator against the current value of the property
  78387. * @param operator the conditional operator, default ValueCondition.IsEqual
  78388. */
  78389. constructor(actionManager: ActionManager, target: any,
  78390. /** path to specify the property of the target the conditional operator uses */
  78391. propertyPath: string,
  78392. /** the value compared by the conditional operator against the current value of the property */
  78393. value: any,
  78394. /** the conditional operator, default ValueCondition.IsEqual */
  78395. operator?: number);
  78396. /**
  78397. * Compares the given value with the property value for the specified conditional operator
  78398. * @returns the result of the comparison
  78399. */
  78400. isValid(): boolean;
  78401. /**
  78402. * Serialize the ValueCondition into a JSON compatible object
  78403. * @returns serialization object
  78404. */
  78405. serialize(): any;
  78406. /**
  78407. * Gets the name of the conditional operator for the ValueCondition
  78408. * @param operator the conditional operator
  78409. * @returns the name
  78410. */
  78411. static GetOperatorName(operator: number): string;
  78412. }
  78413. /**
  78414. * Defines a predicate condition as an extension of Condition
  78415. */
  78416. export class PredicateCondition extends Condition {
  78417. /** defines the predicate function used to validate the condition */
  78418. predicate: () => boolean;
  78419. /**
  78420. * Internal only - manager for action
  78421. * @hidden
  78422. */
  78423. _actionManager: ActionManager;
  78424. /**
  78425. * Creates a new PredicateCondition
  78426. * @param actionManager manager for the action the condition applies to
  78427. * @param predicate defines the predicate function used to validate the condition
  78428. */
  78429. constructor(actionManager: ActionManager,
  78430. /** defines the predicate function used to validate the condition */
  78431. predicate: () => boolean);
  78432. /**
  78433. * @returns the validity of the predicate condition
  78434. */
  78435. isValid(): boolean;
  78436. }
  78437. /**
  78438. * Defines a state condition as an extension of Condition
  78439. */
  78440. export class StateCondition extends Condition {
  78441. /** Value to compare with target state */
  78442. value: string;
  78443. /**
  78444. * Internal only - manager for action
  78445. * @hidden
  78446. */
  78447. _actionManager: ActionManager;
  78448. /**
  78449. * Internal only
  78450. * @hidden
  78451. */
  78452. private _target;
  78453. /**
  78454. * Creates a new StateCondition
  78455. * @param actionManager manager for the action the condition applies to
  78456. * @param target of the condition
  78457. * @param value to compare with target state
  78458. */
  78459. constructor(actionManager: ActionManager, target: any,
  78460. /** Value to compare with target state */
  78461. value: string);
  78462. /**
  78463. * Gets a boolean indicating if the current condition is met
  78464. * @returns the validity of the state
  78465. */
  78466. isValid(): boolean;
  78467. /**
  78468. * Serialize the StateCondition into a JSON compatible object
  78469. * @returns serialization object
  78470. */
  78471. serialize(): any;
  78472. }
  78473. }
  78474. declare module BABYLON {
  78475. /**
  78476. * This defines an action responsible to toggle a boolean once triggered.
  78477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78478. */
  78479. export class SwitchBooleanAction extends Action {
  78480. /**
  78481. * The path to the boolean property in the target object
  78482. */
  78483. propertyPath: string;
  78484. private _target;
  78485. private _effectiveTarget;
  78486. private _property;
  78487. /**
  78488. * Instantiate the action
  78489. * @param triggerOptions defines the trigger options
  78490. * @param target defines the object containing the boolean
  78491. * @param propertyPath defines the path to the boolean property in the target object
  78492. * @param condition defines the trigger related conditions
  78493. */
  78494. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78495. /** @hidden */
  78496. _prepare(): void;
  78497. /**
  78498. * Execute the action toggle the boolean value.
  78499. */
  78500. execute(): void;
  78501. /**
  78502. * Serializes the actions and its related information.
  78503. * @param parent defines the object to serialize in
  78504. * @returns the serialized object
  78505. */
  78506. serialize(parent: any): any;
  78507. }
  78508. /**
  78509. * This defines an action responsible to set a the state field of the target
  78510. * to a desired value once triggered.
  78511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78512. */
  78513. export class SetStateAction extends Action {
  78514. /**
  78515. * The value to store in the state field.
  78516. */
  78517. value: string;
  78518. private _target;
  78519. /**
  78520. * Instantiate the action
  78521. * @param triggerOptions defines the trigger options
  78522. * @param target defines the object containing the state property
  78523. * @param value defines the value to store in the state field
  78524. * @param condition defines the trigger related conditions
  78525. */
  78526. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78527. /**
  78528. * Execute the action and store the value on the target state property.
  78529. */
  78530. execute(): void;
  78531. /**
  78532. * Serializes the actions and its related information.
  78533. * @param parent defines the object to serialize in
  78534. * @returns the serialized object
  78535. */
  78536. serialize(parent: any): any;
  78537. }
  78538. /**
  78539. * This defines an action responsible to set a property of the target
  78540. * to a desired value once triggered.
  78541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78542. */
  78543. export class SetValueAction extends Action {
  78544. /**
  78545. * The path of the property to set in the target.
  78546. */
  78547. propertyPath: string;
  78548. /**
  78549. * The value to set in the property
  78550. */
  78551. value: any;
  78552. private _target;
  78553. private _effectiveTarget;
  78554. private _property;
  78555. /**
  78556. * Instantiate the action
  78557. * @param triggerOptions defines the trigger options
  78558. * @param target defines the object containing the property
  78559. * @param propertyPath defines the path of the property to set in the target
  78560. * @param value defines the value to set in the property
  78561. * @param condition defines the trigger related conditions
  78562. */
  78563. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78564. /** @hidden */
  78565. _prepare(): void;
  78566. /**
  78567. * Execute the action and set the targetted property to the desired value.
  78568. */
  78569. execute(): void;
  78570. /**
  78571. * Serializes the actions and its related information.
  78572. * @param parent defines the object to serialize in
  78573. * @returns the serialized object
  78574. */
  78575. serialize(parent: any): any;
  78576. }
  78577. /**
  78578. * This defines an action responsible to increment the target value
  78579. * to a desired value once triggered.
  78580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78581. */
  78582. export class IncrementValueAction extends Action {
  78583. /**
  78584. * The path of the property to increment in the target.
  78585. */
  78586. propertyPath: string;
  78587. /**
  78588. * The value we should increment the property by.
  78589. */
  78590. value: any;
  78591. private _target;
  78592. private _effectiveTarget;
  78593. private _property;
  78594. /**
  78595. * Instantiate the action
  78596. * @param triggerOptions defines the trigger options
  78597. * @param target defines the object containing the property
  78598. * @param propertyPath defines the path of the property to increment in the target
  78599. * @param value defines the value value we should increment the property by
  78600. * @param condition defines the trigger related conditions
  78601. */
  78602. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78603. /** @hidden */
  78604. _prepare(): void;
  78605. /**
  78606. * Execute the action and increment the target of the value amount.
  78607. */
  78608. execute(): void;
  78609. /**
  78610. * Serializes the actions and its related information.
  78611. * @param parent defines the object to serialize in
  78612. * @returns the serialized object
  78613. */
  78614. serialize(parent: any): any;
  78615. }
  78616. /**
  78617. * This defines an action responsible to start an animation once triggered.
  78618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78619. */
  78620. export class PlayAnimationAction extends Action {
  78621. /**
  78622. * Where the animation should start (animation frame)
  78623. */
  78624. from: number;
  78625. /**
  78626. * Where the animation should stop (animation frame)
  78627. */
  78628. to: number;
  78629. /**
  78630. * Define if the animation should loop or stop after the first play.
  78631. */
  78632. loop?: boolean;
  78633. private _target;
  78634. /**
  78635. * Instantiate the action
  78636. * @param triggerOptions defines the trigger options
  78637. * @param target defines the target animation or animation name
  78638. * @param from defines from where the animation should start (animation frame)
  78639. * @param end defines where the animation should stop (animation frame)
  78640. * @param loop defines if the animation should loop or stop after the first play
  78641. * @param condition defines the trigger related conditions
  78642. */
  78643. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78644. /** @hidden */
  78645. _prepare(): void;
  78646. /**
  78647. * Execute the action and play the animation.
  78648. */
  78649. execute(): void;
  78650. /**
  78651. * Serializes the actions and its related information.
  78652. * @param parent defines the object to serialize in
  78653. * @returns the serialized object
  78654. */
  78655. serialize(parent: any): any;
  78656. }
  78657. /**
  78658. * This defines an action responsible to stop an animation once triggered.
  78659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78660. */
  78661. export class StopAnimationAction extends Action {
  78662. private _target;
  78663. /**
  78664. * Instantiate the action
  78665. * @param triggerOptions defines the trigger options
  78666. * @param target defines the target animation or animation name
  78667. * @param condition defines the trigger related conditions
  78668. */
  78669. constructor(triggerOptions: any, target: any, condition?: Condition);
  78670. /** @hidden */
  78671. _prepare(): void;
  78672. /**
  78673. * Execute the action and stop the animation.
  78674. */
  78675. execute(): void;
  78676. /**
  78677. * Serializes the actions and its related information.
  78678. * @param parent defines the object to serialize in
  78679. * @returns the serialized object
  78680. */
  78681. serialize(parent: any): any;
  78682. }
  78683. /**
  78684. * This defines an action responsible that does nothing once triggered.
  78685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78686. */
  78687. export class DoNothingAction extends Action {
  78688. /**
  78689. * Instantiate the action
  78690. * @param triggerOptions defines the trigger options
  78691. * @param condition defines the trigger related conditions
  78692. */
  78693. constructor(triggerOptions?: any, condition?: Condition);
  78694. /**
  78695. * Execute the action and do nothing.
  78696. */
  78697. execute(): void;
  78698. /**
  78699. * Serializes the actions and its related information.
  78700. * @param parent defines the object to serialize in
  78701. * @returns the serialized object
  78702. */
  78703. serialize(parent: any): any;
  78704. }
  78705. /**
  78706. * This defines an action responsible to trigger several actions once triggered.
  78707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78708. */
  78709. export class CombineAction extends Action {
  78710. /**
  78711. * The list of aggregated animations to run.
  78712. */
  78713. children: Action[];
  78714. /**
  78715. * Instantiate the action
  78716. * @param triggerOptions defines the trigger options
  78717. * @param children defines the list of aggregated animations to run
  78718. * @param condition defines the trigger related conditions
  78719. */
  78720. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78721. /** @hidden */
  78722. _prepare(): void;
  78723. /**
  78724. * Execute the action and executes all the aggregated actions.
  78725. */
  78726. execute(evt: ActionEvent): void;
  78727. /**
  78728. * Serializes the actions and its related information.
  78729. * @param parent defines the object to serialize in
  78730. * @returns the serialized object
  78731. */
  78732. serialize(parent: any): any;
  78733. }
  78734. /**
  78735. * This defines an action responsible to run code (external event) once triggered.
  78736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78737. */
  78738. export class ExecuteCodeAction extends Action {
  78739. /**
  78740. * The callback function to run.
  78741. */
  78742. func: (evt: ActionEvent) => void;
  78743. /**
  78744. * Instantiate the action
  78745. * @param triggerOptions defines the trigger options
  78746. * @param func defines the callback function to run
  78747. * @param condition defines the trigger related conditions
  78748. */
  78749. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78750. /**
  78751. * Execute the action and run the attached code.
  78752. */
  78753. execute(evt: ActionEvent): void;
  78754. }
  78755. /**
  78756. * This defines an action responsible to set the parent property of the target once triggered.
  78757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78758. */
  78759. export class SetParentAction extends Action {
  78760. private _parent;
  78761. private _target;
  78762. /**
  78763. * Instantiate the action
  78764. * @param triggerOptions defines the trigger options
  78765. * @param target defines the target containing the parent property
  78766. * @param parent defines from where the animation should start (animation frame)
  78767. * @param condition defines the trigger related conditions
  78768. */
  78769. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78770. /** @hidden */
  78771. _prepare(): void;
  78772. /**
  78773. * Execute the action and set the parent property.
  78774. */
  78775. execute(): void;
  78776. /**
  78777. * Serializes the actions and its related information.
  78778. * @param parent defines the object to serialize in
  78779. * @returns the serialized object
  78780. */
  78781. serialize(parent: any): any;
  78782. }
  78783. }
  78784. declare module BABYLON {
  78785. /**
  78786. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78787. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78789. */
  78790. export class ActionManager extends AbstractActionManager {
  78791. /**
  78792. * Nothing
  78793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78794. */
  78795. static readonly NothingTrigger: number;
  78796. /**
  78797. * On pick
  78798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78799. */
  78800. static readonly OnPickTrigger: number;
  78801. /**
  78802. * On left pick
  78803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78804. */
  78805. static readonly OnLeftPickTrigger: number;
  78806. /**
  78807. * On right pick
  78808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78809. */
  78810. static readonly OnRightPickTrigger: number;
  78811. /**
  78812. * On center pick
  78813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78814. */
  78815. static readonly OnCenterPickTrigger: number;
  78816. /**
  78817. * On pick down
  78818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78819. */
  78820. static readonly OnPickDownTrigger: number;
  78821. /**
  78822. * On double pick
  78823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78824. */
  78825. static readonly OnDoublePickTrigger: number;
  78826. /**
  78827. * On pick up
  78828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78829. */
  78830. static readonly OnPickUpTrigger: number;
  78831. /**
  78832. * On pick out.
  78833. * This trigger will only be raised if you also declared a OnPickDown
  78834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78835. */
  78836. static readonly OnPickOutTrigger: number;
  78837. /**
  78838. * On long press
  78839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78840. */
  78841. static readonly OnLongPressTrigger: number;
  78842. /**
  78843. * On pointer over
  78844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78845. */
  78846. static readonly OnPointerOverTrigger: number;
  78847. /**
  78848. * On pointer out
  78849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78850. */
  78851. static readonly OnPointerOutTrigger: number;
  78852. /**
  78853. * On every frame
  78854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78855. */
  78856. static readonly OnEveryFrameTrigger: number;
  78857. /**
  78858. * On intersection enter
  78859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78860. */
  78861. static readonly OnIntersectionEnterTrigger: number;
  78862. /**
  78863. * On intersection exit
  78864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78865. */
  78866. static readonly OnIntersectionExitTrigger: number;
  78867. /**
  78868. * On key down
  78869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78870. */
  78871. static readonly OnKeyDownTrigger: number;
  78872. /**
  78873. * On key up
  78874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78875. */
  78876. static readonly OnKeyUpTrigger: number;
  78877. private _scene;
  78878. /**
  78879. * Creates a new action manager
  78880. * @param scene defines the hosting scene
  78881. */
  78882. constructor(scene: Scene);
  78883. /**
  78884. * Releases all associated resources
  78885. */
  78886. dispose(): void;
  78887. /**
  78888. * Gets hosting scene
  78889. * @returns the hosting scene
  78890. */
  78891. getScene(): Scene;
  78892. /**
  78893. * Does this action manager handles actions of any of the given triggers
  78894. * @param triggers defines the triggers to be tested
  78895. * @return a boolean indicating whether one (or more) of the triggers is handled
  78896. */
  78897. hasSpecificTriggers(triggers: number[]): boolean;
  78898. /**
  78899. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78900. * speed.
  78901. * @param triggerA defines the trigger to be tested
  78902. * @param triggerB defines the trigger to be tested
  78903. * @return a boolean indicating whether one (or more) of the triggers is handled
  78904. */
  78905. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78906. /**
  78907. * Does this action manager handles actions of a given trigger
  78908. * @param trigger defines the trigger to be tested
  78909. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78910. * @return whether the trigger is handled
  78911. */
  78912. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78913. /**
  78914. * Does this action manager has pointer triggers
  78915. */
  78916. readonly hasPointerTriggers: boolean;
  78917. /**
  78918. * Does this action manager has pick triggers
  78919. */
  78920. readonly hasPickTriggers: boolean;
  78921. /**
  78922. * Registers an action to this action manager
  78923. * @param action defines the action to be registered
  78924. * @return the action amended (prepared) after registration
  78925. */
  78926. registerAction(action: IAction): Nullable<IAction>;
  78927. /**
  78928. * Unregisters an action to this action manager
  78929. * @param action defines the action to be unregistered
  78930. * @return a boolean indicating whether the action has been unregistered
  78931. */
  78932. unregisterAction(action: IAction): Boolean;
  78933. /**
  78934. * Process a specific trigger
  78935. * @param trigger defines the trigger to process
  78936. * @param evt defines the event details to be processed
  78937. */
  78938. processTrigger(trigger: number, evt?: IActionEvent): void;
  78939. /** @hidden */
  78940. _getEffectiveTarget(target: any, propertyPath: string): any;
  78941. /** @hidden */
  78942. _getProperty(propertyPath: string): string;
  78943. /**
  78944. * Serialize this manager to a JSON object
  78945. * @param name defines the property name to store this manager
  78946. * @returns a JSON representation of this manager
  78947. */
  78948. serialize(name: string): any;
  78949. /**
  78950. * Creates a new ActionManager from a JSON data
  78951. * @param parsedActions defines the JSON data to read from
  78952. * @param object defines the hosting mesh
  78953. * @param scene defines the hosting scene
  78954. */
  78955. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78956. /**
  78957. * Get a trigger name by index
  78958. * @param trigger defines the trigger index
  78959. * @returns a trigger name
  78960. */
  78961. static GetTriggerName(trigger: number): string;
  78962. }
  78963. }
  78964. declare module BABYLON {
  78965. /**
  78966. * Class representing a ray with position and direction
  78967. */
  78968. export class Ray {
  78969. /** origin point */
  78970. origin: Vector3;
  78971. /** direction */
  78972. direction: Vector3;
  78973. /** length of the ray */
  78974. length: number;
  78975. private static readonly TmpVector3;
  78976. private _tmpRay;
  78977. /**
  78978. * Creates a new ray
  78979. * @param origin origin point
  78980. * @param direction direction
  78981. * @param length length of the ray
  78982. */
  78983. constructor(
  78984. /** origin point */
  78985. origin: Vector3,
  78986. /** direction */
  78987. direction: Vector3,
  78988. /** length of the ray */
  78989. length?: number);
  78990. /**
  78991. * Checks if the ray intersects a box
  78992. * @param minimum bound of the box
  78993. * @param maximum bound of the box
  78994. * @param intersectionTreshold extra extend to be added to the box in all direction
  78995. * @returns if the box was hit
  78996. */
  78997. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78998. /**
  78999. * Checks if the ray intersects a box
  79000. * @param box the bounding box to check
  79001. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79002. * @returns if the box was hit
  79003. */
  79004. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79005. /**
  79006. * If the ray hits a sphere
  79007. * @param sphere the bounding sphere to check
  79008. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79009. * @returns true if it hits the sphere
  79010. */
  79011. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79012. /**
  79013. * If the ray hits a triange
  79014. * @param vertex0 triangle vertex
  79015. * @param vertex1 triangle vertex
  79016. * @param vertex2 triangle vertex
  79017. * @returns intersection information if hit
  79018. */
  79019. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79020. /**
  79021. * Checks if ray intersects a plane
  79022. * @param plane the plane to check
  79023. * @returns the distance away it was hit
  79024. */
  79025. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79026. /**
  79027. * Calculate the intercept of a ray on a given axis
  79028. * @param axis to check 'x' | 'y' | 'z'
  79029. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79030. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79031. */
  79032. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79033. /**
  79034. * Checks if ray intersects a mesh
  79035. * @param mesh the mesh to check
  79036. * @param fastCheck if only the bounding box should checked
  79037. * @returns picking info of the intersecton
  79038. */
  79039. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79040. /**
  79041. * Checks if ray intersects a mesh
  79042. * @param meshes the meshes to check
  79043. * @param fastCheck if only the bounding box should checked
  79044. * @param results array to store result in
  79045. * @returns Array of picking infos
  79046. */
  79047. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79048. private _comparePickingInfo;
  79049. private static smallnum;
  79050. private static rayl;
  79051. /**
  79052. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79053. * @param sega the first point of the segment to test the intersection against
  79054. * @param segb the second point of the segment to test the intersection against
  79055. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79056. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79057. */
  79058. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79059. /**
  79060. * Update the ray from viewport position
  79061. * @param x position
  79062. * @param y y position
  79063. * @param viewportWidth viewport width
  79064. * @param viewportHeight viewport height
  79065. * @param world world matrix
  79066. * @param view view matrix
  79067. * @param projection projection matrix
  79068. * @returns this ray updated
  79069. */
  79070. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79071. /**
  79072. * Creates a ray with origin and direction of 0,0,0
  79073. * @returns the new ray
  79074. */
  79075. static Zero(): Ray;
  79076. /**
  79077. * Creates a new ray from screen space and viewport
  79078. * @param x position
  79079. * @param y y position
  79080. * @param viewportWidth viewport width
  79081. * @param viewportHeight viewport height
  79082. * @param world world matrix
  79083. * @param view view matrix
  79084. * @param projection projection matrix
  79085. * @returns new ray
  79086. */
  79087. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79088. /**
  79089. * 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
  79090. * transformed to the given world matrix.
  79091. * @param origin The origin point
  79092. * @param end The end point
  79093. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79094. * @returns the new ray
  79095. */
  79096. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79097. /**
  79098. * Transforms a ray by a matrix
  79099. * @param ray ray to transform
  79100. * @param matrix matrix to apply
  79101. * @returns the resulting new ray
  79102. */
  79103. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79104. /**
  79105. * Transforms a ray by a matrix
  79106. * @param ray ray to transform
  79107. * @param matrix matrix to apply
  79108. * @param result ray to store result in
  79109. */
  79110. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79111. /**
  79112. * Unproject a ray from screen space to object space
  79113. * @param sourceX defines the screen space x coordinate to use
  79114. * @param sourceY defines the screen space y coordinate to use
  79115. * @param viewportWidth defines the current width of the viewport
  79116. * @param viewportHeight defines the current height of the viewport
  79117. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79118. * @param view defines the view matrix to use
  79119. * @param projection defines the projection matrix to use
  79120. */
  79121. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79122. }
  79123. /**
  79124. * Type used to define predicate used to select faces when a mesh intersection is detected
  79125. */
  79126. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79127. interface Scene {
  79128. /** @hidden */
  79129. _tempPickingRay: Nullable<Ray>;
  79130. /** @hidden */
  79131. _cachedRayForTransform: Ray;
  79132. /** @hidden */
  79133. _pickWithRayInverseMatrix: Matrix;
  79134. /** @hidden */
  79135. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79136. /** @hidden */
  79137. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79138. }
  79139. }
  79140. declare module BABYLON {
  79141. /**
  79142. * Groups all the scene component constants in one place to ease maintenance.
  79143. * @hidden
  79144. */
  79145. export class SceneComponentConstants {
  79146. static readonly NAME_EFFECTLAYER: string;
  79147. static readonly NAME_LAYER: string;
  79148. static readonly NAME_LENSFLARESYSTEM: string;
  79149. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79150. static readonly NAME_PARTICLESYSTEM: string;
  79151. static readonly NAME_GAMEPAD: string;
  79152. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79153. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79154. static readonly NAME_DEPTHRENDERER: string;
  79155. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79156. static readonly NAME_SPRITE: string;
  79157. static readonly NAME_OUTLINERENDERER: string;
  79158. static readonly NAME_PROCEDURALTEXTURE: string;
  79159. static readonly NAME_SHADOWGENERATOR: string;
  79160. static readonly NAME_OCTREE: string;
  79161. static readonly NAME_PHYSICSENGINE: string;
  79162. static readonly NAME_AUDIO: string;
  79163. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79164. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79165. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79166. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79167. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79168. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79169. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79170. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79171. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79172. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79173. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79174. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79175. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79176. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79177. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79178. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79179. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79180. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79181. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79182. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79183. static readonly STEP_AFTERRENDER_AUDIO: number;
  79184. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79185. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79186. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79187. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79188. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79189. static readonly STEP_POINTERMOVE_SPRITE: number;
  79190. static readonly STEP_POINTERDOWN_SPRITE: number;
  79191. static readonly STEP_POINTERUP_SPRITE: number;
  79192. }
  79193. /**
  79194. * This represents a scene component.
  79195. *
  79196. * This is used to decouple the dependency the scene is having on the different workloads like
  79197. * layers, post processes...
  79198. */
  79199. export interface ISceneComponent {
  79200. /**
  79201. * The name of the component. Each component must have a unique name.
  79202. */
  79203. name: string;
  79204. /**
  79205. * The scene the component belongs to.
  79206. */
  79207. scene: Scene;
  79208. /**
  79209. * Register the component to one instance of a scene.
  79210. */
  79211. register(): void;
  79212. /**
  79213. * Rebuilds the elements related to this component in case of
  79214. * context lost for instance.
  79215. */
  79216. rebuild(): void;
  79217. /**
  79218. * Disposes the component and the associated ressources.
  79219. */
  79220. dispose(): void;
  79221. }
  79222. /**
  79223. * This represents a SERIALIZABLE scene component.
  79224. *
  79225. * This extends Scene Component to add Serialization methods on top.
  79226. */
  79227. export interface ISceneSerializableComponent extends ISceneComponent {
  79228. /**
  79229. * Adds all the elements from the container to the scene
  79230. * @param container the container holding the elements
  79231. */
  79232. addFromContainer(container: AbstractScene): void;
  79233. /**
  79234. * Removes all the elements in the container from the scene
  79235. * @param container contains the elements to remove
  79236. * @param dispose if the removed element should be disposed (default: false)
  79237. */
  79238. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79239. /**
  79240. * Serializes the component data to the specified json object
  79241. * @param serializationObject The object to serialize to
  79242. */
  79243. serialize(serializationObject: any): void;
  79244. }
  79245. /**
  79246. * Strong typing of a Mesh related stage step action
  79247. */
  79248. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79249. /**
  79250. * Strong typing of a Evaluate Sub Mesh related stage step action
  79251. */
  79252. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79253. /**
  79254. * Strong typing of a Active Mesh related stage step action
  79255. */
  79256. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79257. /**
  79258. * Strong typing of a Camera related stage step action
  79259. */
  79260. export type CameraStageAction = (camera: Camera) => void;
  79261. /**
  79262. * Strong typing of a Camera Frame buffer related stage step action
  79263. */
  79264. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79265. /**
  79266. * Strong typing of a Render Target related stage step action
  79267. */
  79268. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79269. /**
  79270. * Strong typing of a RenderingGroup related stage step action
  79271. */
  79272. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79273. /**
  79274. * Strong typing of a Mesh Render related stage step action
  79275. */
  79276. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79277. /**
  79278. * Strong typing of a simple stage step action
  79279. */
  79280. export type SimpleStageAction = () => void;
  79281. /**
  79282. * Strong typing of a render target action.
  79283. */
  79284. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79285. /**
  79286. * Strong typing of a pointer move action.
  79287. */
  79288. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79289. /**
  79290. * Strong typing of a pointer up/down action.
  79291. */
  79292. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79293. /**
  79294. * Representation of a stage in the scene (Basically a list of ordered steps)
  79295. * @hidden
  79296. */
  79297. export class Stage<T extends Function> extends Array<{
  79298. index: number;
  79299. component: ISceneComponent;
  79300. action: T;
  79301. }> {
  79302. /**
  79303. * Hide ctor from the rest of the world.
  79304. * @param items The items to add.
  79305. */
  79306. private constructor();
  79307. /**
  79308. * Creates a new Stage.
  79309. * @returns A new instance of a Stage
  79310. */
  79311. static Create<T extends Function>(): Stage<T>;
  79312. /**
  79313. * Registers a step in an ordered way in the targeted stage.
  79314. * @param index Defines the position to register the step in
  79315. * @param component Defines the component attached to the step
  79316. * @param action Defines the action to launch during the step
  79317. */
  79318. registerStep(index: number, component: ISceneComponent, action: T): void;
  79319. /**
  79320. * Clears all the steps from the stage.
  79321. */
  79322. clear(): void;
  79323. }
  79324. }
  79325. declare module BABYLON {
  79326. interface Scene {
  79327. /** @hidden */
  79328. _pointerOverSprite: Nullable<Sprite>;
  79329. /** @hidden */
  79330. _pickedDownSprite: Nullable<Sprite>;
  79331. /** @hidden */
  79332. _tempSpritePickingRay: Nullable<Ray>;
  79333. /**
  79334. * All of the sprite managers added to this scene
  79335. * @see http://doc.babylonjs.com/babylon101/sprites
  79336. */
  79337. spriteManagers: Array<ISpriteManager>;
  79338. /**
  79339. * An event triggered when sprites rendering is about to start
  79340. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79341. */
  79342. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79343. /**
  79344. * An event triggered when sprites rendering is done
  79345. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79346. */
  79347. onAfterSpritesRenderingObservable: Observable<Scene>;
  79348. /** @hidden */
  79349. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79350. /** Launch a ray to try to pick a sprite in the scene
  79351. * @param x position on screen
  79352. * @param y position on screen
  79353. * @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
  79354. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79355. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79356. * @returns a PickingInfo
  79357. */
  79358. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79359. /** Use the given ray to pick a sprite in the scene
  79360. * @param ray The ray (in world space) to use to pick meshes
  79361. * @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
  79362. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79363. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79364. * @returns a PickingInfo
  79365. */
  79366. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79367. /** @hidden */
  79368. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79369. /** Launch a ray to try to pick sprites in the scene
  79370. * @param x position on screen
  79371. * @param y position on screen
  79372. * @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
  79373. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79374. * @returns a PickingInfo array
  79375. */
  79376. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79377. /** Use the given ray to pick sprites in the scene
  79378. * @param ray The ray (in world space) to use to pick meshes
  79379. * @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
  79380. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79381. * @returns a PickingInfo array
  79382. */
  79383. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79384. /**
  79385. * Force the sprite under the pointer
  79386. * @param sprite defines the sprite to use
  79387. */
  79388. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79389. /**
  79390. * Gets the sprite under the pointer
  79391. * @returns a Sprite or null if no sprite is under the pointer
  79392. */
  79393. getPointerOverSprite(): Nullable<Sprite>;
  79394. }
  79395. /**
  79396. * Defines the sprite scene component responsible to manage sprites
  79397. * in a given scene.
  79398. */
  79399. export class SpriteSceneComponent implements ISceneComponent {
  79400. /**
  79401. * The component name helpfull to identify the component in the list of scene components.
  79402. */
  79403. readonly name: string;
  79404. /**
  79405. * The scene the component belongs to.
  79406. */
  79407. scene: Scene;
  79408. /** @hidden */
  79409. private _spritePredicate;
  79410. /**
  79411. * Creates a new instance of the component for the given scene
  79412. * @param scene Defines the scene to register the component in
  79413. */
  79414. constructor(scene: Scene);
  79415. /**
  79416. * Registers the component in a given scene
  79417. */
  79418. register(): void;
  79419. /**
  79420. * Rebuilds the elements related to this component in case of
  79421. * context lost for instance.
  79422. */
  79423. rebuild(): void;
  79424. /**
  79425. * Disposes the component and the associated ressources.
  79426. */
  79427. dispose(): void;
  79428. private _pickSpriteButKeepRay;
  79429. private _pointerMove;
  79430. private _pointerDown;
  79431. private _pointerUp;
  79432. }
  79433. }
  79434. declare module BABYLON {
  79435. /** @hidden */
  79436. export var fogFragmentDeclaration: {
  79437. name: string;
  79438. shader: string;
  79439. };
  79440. }
  79441. declare module BABYLON {
  79442. /** @hidden */
  79443. export var fogFragment: {
  79444. name: string;
  79445. shader: string;
  79446. };
  79447. }
  79448. declare module BABYLON {
  79449. /** @hidden */
  79450. export var spritesPixelShader: {
  79451. name: string;
  79452. shader: string;
  79453. };
  79454. }
  79455. declare module BABYLON {
  79456. /** @hidden */
  79457. export var fogVertexDeclaration: {
  79458. name: string;
  79459. shader: string;
  79460. };
  79461. }
  79462. declare module BABYLON {
  79463. /** @hidden */
  79464. export var spritesVertexShader: {
  79465. name: string;
  79466. shader: string;
  79467. };
  79468. }
  79469. declare module BABYLON {
  79470. /**
  79471. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79472. */
  79473. export interface ISpriteManager extends IDisposable {
  79474. /**
  79475. * Restricts the camera to viewing objects with the same layerMask.
  79476. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79477. */
  79478. layerMask: number;
  79479. /**
  79480. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79481. */
  79482. isPickable: boolean;
  79483. /**
  79484. * Specifies the rendering group id for this mesh (0 by default)
  79485. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79486. */
  79487. renderingGroupId: number;
  79488. /**
  79489. * Defines the list of sprites managed by the manager.
  79490. */
  79491. sprites: Array<Sprite>;
  79492. /**
  79493. * Tests the intersection of a sprite with a specific ray.
  79494. * @param ray The ray we are sending to test the collision
  79495. * @param camera The camera space we are sending rays in
  79496. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79497. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79498. * @returns picking info or null.
  79499. */
  79500. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79501. /**
  79502. * Intersects the sprites with a ray
  79503. * @param ray defines the ray to intersect with
  79504. * @param camera defines the current active camera
  79505. * @param predicate defines a predicate used to select candidate sprites
  79506. * @returns null if no hit or a PickingInfo array
  79507. */
  79508. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79509. /**
  79510. * Renders the list of sprites on screen.
  79511. */
  79512. render(): void;
  79513. }
  79514. /**
  79515. * Class used to manage multiple sprites on the same spritesheet
  79516. * @see http://doc.babylonjs.com/babylon101/sprites
  79517. */
  79518. export class SpriteManager implements ISpriteManager {
  79519. /** defines the manager's name */
  79520. name: string;
  79521. /** Gets the list of sprites */
  79522. sprites: Sprite[];
  79523. /** Gets or sets the rendering group id (0 by default) */
  79524. renderingGroupId: number;
  79525. /** Gets or sets camera layer mask */
  79526. layerMask: number;
  79527. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79528. fogEnabled: boolean;
  79529. /** Gets or sets a boolean indicating if the sprites are pickable */
  79530. isPickable: boolean;
  79531. /** Defines the default width of a cell in the spritesheet */
  79532. cellWidth: number;
  79533. /** Defines the default height of a cell in the spritesheet */
  79534. cellHeight: number;
  79535. /** Associative array from JSON sprite data file */
  79536. private _cellData;
  79537. /** Array of sprite names from JSON sprite data file */
  79538. private _spriteMap;
  79539. /** True when packed cell data from JSON file is ready*/
  79540. private _packedAndReady;
  79541. /**
  79542. * An event triggered when the manager is disposed.
  79543. */
  79544. onDisposeObservable: Observable<SpriteManager>;
  79545. private _onDisposeObserver;
  79546. /**
  79547. * Callback called when the manager is disposed
  79548. */
  79549. onDispose: () => void;
  79550. private _capacity;
  79551. private _fromPacked;
  79552. private _spriteTexture;
  79553. private _epsilon;
  79554. private _scene;
  79555. private _vertexData;
  79556. private _buffer;
  79557. private _vertexBuffers;
  79558. private _indexBuffer;
  79559. private _effectBase;
  79560. private _effectFog;
  79561. /**
  79562. * Gets or sets the spritesheet texture
  79563. */
  79564. texture: Texture;
  79565. /**
  79566. * Creates a new sprite manager
  79567. * @param name defines the manager's name
  79568. * @param imgUrl defines the sprite sheet url
  79569. * @param capacity defines the maximum allowed number of sprites
  79570. * @param cellSize defines the size of a sprite cell
  79571. * @param scene defines the hosting scene
  79572. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79573. * @param samplingMode defines the smapling mode to use with spritesheet
  79574. * @param fromPacked set to false; do not alter
  79575. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79576. */
  79577. constructor(
  79578. /** defines the manager's name */
  79579. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79580. private _makePacked;
  79581. private _appendSpriteVertex;
  79582. /**
  79583. * Intersects the sprites with a ray
  79584. * @param ray defines the ray to intersect with
  79585. * @param camera defines the current active camera
  79586. * @param predicate defines a predicate used to select candidate sprites
  79587. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79588. * @returns null if no hit or a PickingInfo
  79589. */
  79590. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79591. /**
  79592. * Intersects the sprites with a ray
  79593. * @param ray defines the ray to intersect with
  79594. * @param camera defines the current active camera
  79595. * @param predicate defines a predicate used to select candidate sprites
  79596. * @returns null if no hit or a PickingInfo array
  79597. */
  79598. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79599. /**
  79600. * Render all child sprites
  79601. */
  79602. render(): void;
  79603. /**
  79604. * Release associated resources
  79605. */
  79606. dispose(): void;
  79607. }
  79608. }
  79609. declare module BABYLON {
  79610. /**
  79611. * Class used to represent a sprite
  79612. * @see http://doc.babylonjs.com/babylon101/sprites
  79613. */
  79614. export class Sprite {
  79615. /** defines the name */
  79616. name: string;
  79617. /** Gets or sets the current world position */
  79618. position: Vector3;
  79619. /** Gets or sets the main color */
  79620. color: Color4;
  79621. /** Gets or sets the width */
  79622. width: number;
  79623. /** Gets or sets the height */
  79624. height: number;
  79625. /** Gets or sets rotation angle */
  79626. angle: number;
  79627. /** Gets or sets the cell index in the sprite sheet */
  79628. cellIndex: number;
  79629. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79630. cellRef: string;
  79631. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79632. invertU: number;
  79633. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79634. invertV: number;
  79635. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79636. disposeWhenFinishedAnimating: boolean;
  79637. /** Gets the list of attached animations */
  79638. animations: Animation[];
  79639. /** Gets or sets a boolean indicating if the sprite can be picked */
  79640. isPickable: boolean;
  79641. /**
  79642. * Gets or sets the associated action manager
  79643. */
  79644. actionManager: Nullable<ActionManager>;
  79645. private _animationStarted;
  79646. private _loopAnimation;
  79647. private _fromIndex;
  79648. private _toIndex;
  79649. private _delay;
  79650. private _direction;
  79651. private _manager;
  79652. private _time;
  79653. private _onAnimationEnd;
  79654. /**
  79655. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79656. */
  79657. isVisible: boolean;
  79658. /**
  79659. * Gets or sets the sprite size
  79660. */
  79661. size: number;
  79662. /**
  79663. * Creates a new Sprite
  79664. * @param name defines the name
  79665. * @param manager defines the manager
  79666. */
  79667. constructor(
  79668. /** defines the name */
  79669. name: string, manager: ISpriteManager);
  79670. /**
  79671. * Starts an animation
  79672. * @param from defines the initial key
  79673. * @param to defines the end key
  79674. * @param loop defines if the animation must loop
  79675. * @param delay defines the start delay (in ms)
  79676. * @param onAnimationEnd defines a callback to call when animation ends
  79677. */
  79678. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79679. /** Stops current animation (if any) */
  79680. stopAnimation(): void;
  79681. /** @hidden */
  79682. _animate(deltaTime: number): void;
  79683. /** Release associated resources */
  79684. dispose(): void;
  79685. }
  79686. }
  79687. declare module BABYLON {
  79688. /**
  79689. * Information about the result of picking within a scene
  79690. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79691. */
  79692. export class PickingInfo {
  79693. /** @hidden */
  79694. _pickingUnavailable: boolean;
  79695. /**
  79696. * If the pick collided with an object
  79697. */
  79698. hit: boolean;
  79699. /**
  79700. * Distance away where the pick collided
  79701. */
  79702. distance: number;
  79703. /**
  79704. * The location of pick collision
  79705. */
  79706. pickedPoint: Nullable<Vector3>;
  79707. /**
  79708. * The mesh corresponding the the pick collision
  79709. */
  79710. pickedMesh: Nullable<AbstractMesh>;
  79711. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79712. bu: number;
  79713. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79714. bv: number;
  79715. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79716. faceId: number;
  79717. /** Id of the the submesh that was picked */
  79718. subMeshId: number;
  79719. /** If a sprite was picked, this will be the sprite the pick collided with */
  79720. pickedSprite: Nullable<Sprite>;
  79721. /**
  79722. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79723. */
  79724. originMesh: Nullable<AbstractMesh>;
  79725. /**
  79726. * The ray that was used to perform the picking.
  79727. */
  79728. ray: Nullable<Ray>;
  79729. /**
  79730. * Gets the normal correspodning to the face the pick collided with
  79731. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79732. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79733. * @returns The normal correspodning to the face the pick collided with
  79734. */
  79735. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79736. /**
  79737. * Gets the texture coordinates of where the pick occured
  79738. * @returns the vector containing the coordnates of the texture
  79739. */
  79740. getTextureCoordinates(): Nullable<Vector2>;
  79741. }
  79742. }
  79743. declare module BABYLON {
  79744. /**
  79745. * Gather the list of pointer event types as constants.
  79746. */
  79747. export class PointerEventTypes {
  79748. /**
  79749. * 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.
  79750. */
  79751. static readonly POINTERDOWN: number;
  79752. /**
  79753. * The pointerup event is fired when a pointer is no longer active.
  79754. */
  79755. static readonly POINTERUP: number;
  79756. /**
  79757. * The pointermove event is fired when a pointer changes coordinates.
  79758. */
  79759. static readonly POINTERMOVE: number;
  79760. /**
  79761. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79762. */
  79763. static readonly POINTERWHEEL: number;
  79764. /**
  79765. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79766. */
  79767. static readonly POINTERPICK: number;
  79768. /**
  79769. * The pointertap event is fired when a the object has been touched and released without drag.
  79770. */
  79771. static readonly POINTERTAP: number;
  79772. /**
  79773. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79774. */
  79775. static readonly POINTERDOUBLETAP: number;
  79776. }
  79777. /**
  79778. * Base class of pointer info types.
  79779. */
  79780. export class PointerInfoBase {
  79781. /**
  79782. * Defines the type of event (PointerEventTypes)
  79783. */
  79784. type: number;
  79785. /**
  79786. * Defines the related dom event
  79787. */
  79788. event: PointerEvent | MouseWheelEvent;
  79789. /**
  79790. * Instantiates the base class of pointers info.
  79791. * @param type Defines the type of event (PointerEventTypes)
  79792. * @param event Defines the related dom event
  79793. */
  79794. constructor(
  79795. /**
  79796. * Defines the type of event (PointerEventTypes)
  79797. */
  79798. type: number,
  79799. /**
  79800. * Defines the related dom event
  79801. */
  79802. event: PointerEvent | MouseWheelEvent);
  79803. }
  79804. /**
  79805. * This class is used to store pointer related info for the onPrePointerObservable event.
  79806. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79807. */
  79808. export class PointerInfoPre extends PointerInfoBase {
  79809. /**
  79810. * Ray from a pointer if availible (eg. 6dof controller)
  79811. */
  79812. ray: Nullable<Ray>;
  79813. /**
  79814. * Defines the local position of the pointer on the canvas.
  79815. */
  79816. localPosition: Vector2;
  79817. /**
  79818. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79819. */
  79820. skipOnPointerObservable: boolean;
  79821. /**
  79822. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79823. * @param type Defines the type of event (PointerEventTypes)
  79824. * @param event Defines the related dom event
  79825. * @param localX Defines the local x coordinates of the pointer when the event occured
  79826. * @param localY Defines the local y coordinates of the pointer when the event occured
  79827. */
  79828. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79829. }
  79830. /**
  79831. * This type contains all the data related to a pointer event in Babylon.js.
  79832. * 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.
  79833. */
  79834. export class PointerInfo extends PointerInfoBase {
  79835. /**
  79836. * Defines the picking info associated to the info (if any)\
  79837. */
  79838. pickInfo: Nullable<PickingInfo>;
  79839. /**
  79840. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79841. * @param type Defines the type of event (PointerEventTypes)
  79842. * @param event Defines the related dom event
  79843. * @param pickInfo Defines the picking info associated to the info (if any)\
  79844. */
  79845. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79846. /**
  79847. * Defines the picking info associated to the info (if any)\
  79848. */
  79849. pickInfo: Nullable<PickingInfo>);
  79850. }
  79851. /**
  79852. * Data relating to a touch event on the screen.
  79853. */
  79854. export interface PointerTouch {
  79855. /**
  79856. * X coordinate of touch.
  79857. */
  79858. x: number;
  79859. /**
  79860. * Y coordinate of touch.
  79861. */
  79862. y: number;
  79863. /**
  79864. * Id of touch. Unique for each finger.
  79865. */
  79866. pointerId: number;
  79867. /**
  79868. * Event type passed from DOM.
  79869. */
  79870. type: any;
  79871. }
  79872. }
  79873. declare module BABYLON {
  79874. /**
  79875. * Manage the mouse inputs to control the movement of a free camera.
  79876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79877. */
  79878. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79879. /**
  79880. * Define if touch is enabled in the mouse input
  79881. */
  79882. touchEnabled: boolean;
  79883. /**
  79884. * Defines the camera the input is attached to.
  79885. */
  79886. camera: FreeCamera;
  79887. /**
  79888. * Defines the buttons associated with the input to handle camera move.
  79889. */
  79890. buttons: number[];
  79891. /**
  79892. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79893. */
  79894. angularSensibility: number;
  79895. private _pointerInput;
  79896. private _onMouseMove;
  79897. private _observer;
  79898. private previousPosition;
  79899. /**
  79900. * Observable for when a pointer move event occurs containing the move offset
  79901. */
  79902. onPointerMovedObservable: Observable<{
  79903. offsetX: number;
  79904. offsetY: number;
  79905. }>;
  79906. /**
  79907. * @hidden
  79908. * If the camera should be rotated automatically based on pointer movement
  79909. */
  79910. _allowCameraRotation: boolean;
  79911. /**
  79912. * Manage the mouse inputs to control the movement of a free camera.
  79913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79914. * @param touchEnabled Defines if touch is enabled or not
  79915. */
  79916. constructor(
  79917. /**
  79918. * Define if touch is enabled in the mouse input
  79919. */
  79920. touchEnabled?: boolean);
  79921. /**
  79922. * Attach the input controls to a specific dom element to get the input from.
  79923. * @param element Defines the element the controls should be listened from
  79924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79925. */
  79926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79927. /**
  79928. * Called on JS contextmenu event.
  79929. * Override this method to provide functionality.
  79930. */
  79931. protected onContextMenu(evt: PointerEvent): void;
  79932. /**
  79933. * Detach the current controls from the specified dom element.
  79934. * @param element Defines the element to stop listening the inputs from
  79935. */
  79936. detachControl(element: Nullable<HTMLElement>): void;
  79937. /**
  79938. * Gets the class name of the current intput.
  79939. * @returns the class name
  79940. */
  79941. getClassName(): string;
  79942. /**
  79943. * Get the friendly name associated with the input class.
  79944. * @returns the input friendly name
  79945. */
  79946. getSimpleName(): string;
  79947. }
  79948. }
  79949. declare module BABYLON {
  79950. /**
  79951. * Manage the touch inputs to control the movement of a free camera.
  79952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79953. */
  79954. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79955. /**
  79956. * Defines the camera the input is attached to.
  79957. */
  79958. camera: FreeCamera;
  79959. /**
  79960. * Defines the touch sensibility for rotation.
  79961. * The higher the faster.
  79962. */
  79963. touchAngularSensibility: number;
  79964. /**
  79965. * Defines the touch sensibility for move.
  79966. * The higher the faster.
  79967. */
  79968. touchMoveSensibility: number;
  79969. private _offsetX;
  79970. private _offsetY;
  79971. private _pointerPressed;
  79972. private _pointerInput;
  79973. private _observer;
  79974. private _onLostFocus;
  79975. /**
  79976. * Attach the input controls to a specific dom element to get the input from.
  79977. * @param element Defines the element the controls should be listened from
  79978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79979. */
  79980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79981. /**
  79982. * Detach the current controls from the specified dom element.
  79983. * @param element Defines the element to stop listening the inputs from
  79984. */
  79985. detachControl(element: Nullable<HTMLElement>): void;
  79986. /**
  79987. * Update the current camera state depending on the inputs that have been used this frame.
  79988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79989. */
  79990. checkInputs(): void;
  79991. /**
  79992. * Gets the class name of the current intput.
  79993. * @returns the class name
  79994. */
  79995. getClassName(): string;
  79996. /**
  79997. * Get the friendly name associated with the input class.
  79998. * @returns the input friendly name
  79999. */
  80000. getSimpleName(): string;
  80001. }
  80002. }
  80003. declare module BABYLON {
  80004. /**
  80005. * Default Inputs manager for the FreeCamera.
  80006. * It groups all the default supported inputs for ease of use.
  80007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80008. */
  80009. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80010. /**
  80011. * @hidden
  80012. */
  80013. _mouseInput: Nullable<FreeCameraMouseInput>;
  80014. /**
  80015. * Instantiates a new FreeCameraInputsManager.
  80016. * @param camera Defines the camera the inputs belong to
  80017. */
  80018. constructor(camera: FreeCamera);
  80019. /**
  80020. * Add keyboard input support to the input manager.
  80021. * @returns the current input manager
  80022. */
  80023. addKeyboard(): FreeCameraInputsManager;
  80024. /**
  80025. * Add mouse input support to the input manager.
  80026. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80027. * @returns the current input manager
  80028. */
  80029. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80030. /**
  80031. * Removes the mouse input support from the manager
  80032. * @returns the current input manager
  80033. */
  80034. removeMouse(): FreeCameraInputsManager;
  80035. /**
  80036. * Add touch input support to the input manager.
  80037. * @returns the current input manager
  80038. */
  80039. addTouch(): FreeCameraInputsManager;
  80040. /**
  80041. * Remove all attached input methods from a camera
  80042. */
  80043. clear(): void;
  80044. }
  80045. }
  80046. declare module BABYLON {
  80047. /**
  80048. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80049. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80050. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80051. */
  80052. export class FreeCamera extends TargetCamera {
  80053. /**
  80054. * Define the collision ellipsoid of the camera.
  80055. * This is helpful to simulate a camera body like the player body around the camera
  80056. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80057. */
  80058. ellipsoid: Vector3;
  80059. /**
  80060. * Define an offset for the position of the ellipsoid around the camera.
  80061. * This can be helpful to determine the center of the body near the gravity center of the body
  80062. * instead of its head.
  80063. */
  80064. ellipsoidOffset: Vector3;
  80065. /**
  80066. * Enable or disable collisions of the camera with the rest of the scene objects.
  80067. */
  80068. checkCollisions: boolean;
  80069. /**
  80070. * Enable or disable gravity on the camera.
  80071. */
  80072. applyGravity: boolean;
  80073. /**
  80074. * Define the input manager associated to the camera.
  80075. */
  80076. inputs: FreeCameraInputsManager;
  80077. /**
  80078. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80079. * Higher values reduce sensitivity.
  80080. */
  80081. /**
  80082. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80083. * Higher values reduce sensitivity.
  80084. */
  80085. angularSensibility: number;
  80086. /**
  80087. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80088. */
  80089. keysUp: number[];
  80090. /**
  80091. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80092. */
  80093. keysDown: number[];
  80094. /**
  80095. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80096. */
  80097. keysLeft: number[];
  80098. /**
  80099. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80100. */
  80101. keysRight: number[];
  80102. /**
  80103. * Event raised when the camera collide with a mesh in the scene.
  80104. */
  80105. onCollide: (collidedMesh: AbstractMesh) => void;
  80106. private _collider;
  80107. private _needMoveForGravity;
  80108. private _oldPosition;
  80109. private _diffPosition;
  80110. private _newPosition;
  80111. /** @hidden */
  80112. _localDirection: Vector3;
  80113. /** @hidden */
  80114. _transformedDirection: Vector3;
  80115. /**
  80116. * Instantiates a Free Camera.
  80117. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80118. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80119. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80120. * @param name Define the name of the camera in the scene
  80121. * @param position Define the start position of the camera in the scene
  80122. * @param scene Define the scene the camera belongs to
  80123. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80124. */
  80125. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80126. /**
  80127. * Attached controls to the current camera.
  80128. * @param element Defines the element the controls should be listened from
  80129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80130. */
  80131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80132. /**
  80133. * Detach the current controls from the camera.
  80134. * The camera will stop reacting to inputs.
  80135. * @param element Defines the element to stop listening the inputs from
  80136. */
  80137. detachControl(element: HTMLElement): void;
  80138. private _collisionMask;
  80139. /**
  80140. * Define a collision mask to limit the list of object the camera can collide with
  80141. */
  80142. collisionMask: number;
  80143. /** @hidden */
  80144. _collideWithWorld(displacement: Vector3): void;
  80145. private _onCollisionPositionChange;
  80146. /** @hidden */
  80147. _checkInputs(): void;
  80148. /** @hidden */
  80149. _decideIfNeedsToMove(): boolean;
  80150. /** @hidden */
  80151. _updatePosition(): void;
  80152. /**
  80153. * Destroy the camera and release the current resources hold by it.
  80154. */
  80155. dispose(): void;
  80156. /**
  80157. * Gets the current object class name.
  80158. * @return the class name
  80159. */
  80160. getClassName(): string;
  80161. }
  80162. }
  80163. declare module BABYLON {
  80164. /**
  80165. * Represents a gamepad control stick position
  80166. */
  80167. export class StickValues {
  80168. /**
  80169. * The x component of the control stick
  80170. */
  80171. x: number;
  80172. /**
  80173. * The y component of the control stick
  80174. */
  80175. y: number;
  80176. /**
  80177. * Initializes the gamepad x and y control stick values
  80178. * @param x The x component of the gamepad control stick value
  80179. * @param y The y component of the gamepad control stick value
  80180. */
  80181. constructor(
  80182. /**
  80183. * The x component of the control stick
  80184. */
  80185. x: number,
  80186. /**
  80187. * The y component of the control stick
  80188. */
  80189. y: number);
  80190. }
  80191. /**
  80192. * An interface which manages callbacks for gamepad button changes
  80193. */
  80194. export interface GamepadButtonChanges {
  80195. /**
  80196. * Called when a gamepad has been changed
  80197. */
  80198. changed: boolean;
  80199. /**
  80200. * Called when a gamepad press event has been triggered
  80201. */
  80202. pressChanged: boolean;
  80203. /**
  80204. * Called when a touch event has been triggered
  80205. */
  80206. touchChanged: boolean;
  80207. /**
  80208. * Called when a value has changed
  80209. */
  80210. valueChanged: boolean;
  80211. }
  80212. /**
  80213. * Represents a gamepad
  80214. */
  80215. export class Gamepad {
  80216. /**
  80217. * The id of the gamepad
  80218. */
  80219. id: string;
  80220. /**
  80221. * The index of the gamepad
  80222. */
  80223. index: number;
  80224. /**
  80225. * The browser gamepad
  80226. */
  80227. browserGamepad: any;
  80228. /**
  80229. * Specifies what type of gamepad this represents
  80230. */
  80231. type: number;
  80232. private _leftStick;
  80233. private _rightStick;
  80234. /** @hidden */
  80235. _isConnected: boolean;
  80236. private _leftStickAxisX;
  80237. private _leftStickAxisY;
  80238. private _rightStickAxisX;
  80239. private _rightStickAxisY;
  80240. /**
  80241. * Triggered when the left control stick has been changed
  80242. */
  80243. private _onleftstickchanged;
  80244. /**
  80245. * Triggered when the right control stick has been changed
  80246. */
  80247. private _onrightstickchanged;
  80248. /**
  80249. * Represents a gamepad controller
  80250. */
  80251. static GAMEPAD: number;
  80252. /**
  80253. * Represents a generic controller
  80254. */
  80255. static GENERIC: number;
  80256. /**
  80257. * Represents an XBox controller
  80258. */
  80259. static XBOX: number;
  80260. /**
  80261. * Represents a pose-enabled controller
  80262. */
  80263. static POSE_ENABLED: number;
  80264. /**
  80265. * Represents an Dual Shock controller
  80266. */
  80267. static DUALSHOCK: number;
  80268. /**
  80269. * Specifies whether the left control stick should be Y-inverted
  80270. */
  80271. protected _invertLeftStickY: boolean;
  80272. /**
  80273. * Specifies if the gamepad has been connected
  80274. */
  80275. readonly isConnected: boolean;
  80276. /**
  80277. * Initializes the gamepad
  80278. * @param id The id of the gamepad
  80279. * @param index The index of the gamepad
  80280. * @param browserGamepad The browser gamepad
  80281. * @param leftStickX The x component of the left joystick
  80282. * @param leftStickY The y component of the left joystick
  80283. * @param rightStickX The x component of the right joystick
  80284. * @param rightStickY The y component of the right joystick
  80285. */
  80286. constructor(
  80287. /**
  80288. * The id of the gamepad
  80289. */
  80290. id: string,
  80291. /**
  80292. * The index of the gamepad
  80293. */
  80294. index: number,
  80295. /**
  80296. * The browser gamepad
  80297. */
  80298. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80299. /**
  80300. * Callback triggered when the left joystick has changed
  80301. * @param callback
  80302. */
  80303. onleftstickchanged(callback: (values: StickValues) => void): void;
  80304. /**
  80305. * Callback triggered when the right joystick has changed
  80306. * @param callback
  80307. */
  80308. onrightstickchanged(callback: (values: StickValues) => void): void;
  80309. /**
  80310. * Gets the left joystick
  80311. */
  80312. /**
  80313. * Sets the left joystick values
  80314. */
  80315. leftStick: StickValues;
  80316. /**
  80317. * Gets the right joystick
  80318. */
  80319. /**
  80320. * Sets the right joystick value
  80321. */
  80322. rightStick: StickValues;
  80323. /**
  80324. * Updates the gamepad joystick positions
  80325. */
  80326. update(): void;
  80327. /**
  80328. * Disposes the gamepad
  80329. */
  80330. dispose(): void;
  80331. }
  80332. /**
  80333. * Represents a generic gamepad
  80334. */
  80335. export class GenericPad extends Gamepad {
  80336. private _buttons;
  80337. private _onbuttondown;
  80338. private _onbuttonup;
  80339. /**
  80340. * Observable triggered when a button has been pressed
  80341. */
  80342. onButtonDownObservable: Observable<number>;
  80343. /**
  80344. * Observable triggered when a button has been released
  80345. */
  80346. onButtonUpObservable: Observable<number>;
  80347. /**
  80348. * Callback triggered when a button has been pressed
  80349. * @param callback Called when a button has been pressed
  80350. */
  80351. onbuttondown(callback: (buttonPressed: number) => void): void;
  80352. /**
  80353. * Callback triggered when a button has been released
  80354. * @param callback Called when a button has been released
  80355. */
  80356. onbuttonup(callback: (buttonReleased: number) => void): void;
  80357. /**
  80358. * Initializes the generic gamepad
  80359. * @param id The id of the generic gamepad
  80360. * @param index The index of the generic gamepad
  80361. * @param browserGamepad The browser gamepad
  80362. */
  80363. constructor(id: string, index: number, browserGamepad: any);
  80364. private _setButtonValue;
  80365. /**
  80366. * Updates the generic gamepad
  80367. */
  80368. update(): void;
  80369. /**
  80370. * Disposes the generic gamepad
  80371. */
  80372. dispose(): void;
  80373. }
  80374. }
  80375. declare module BABYLON {
  80376. interface Engine {
  80377. /**
  80378. * Creates a raw texture
  80379. * @param data defines the data to store in the texture
  80380. * @param width defines the width of the texture
  80381. * @param height defines the height of the texture
  80382. * @param format defines the format of the data
  80383. * @param generateMipMaps defines if the engine should generate the mip levels
  80384. * @param invertY defines if data must be stored with Y axis inverted
  80385. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80386. * @param compression defines the compression used (null by default)
  80387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80388. * @returns the raw texture inside an InternalTexture
  80389. */
  80390. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80391. /**
  80392. * Update a raw texture
  80393. * @param texture defines the texture to update
  80394. * @param data defines the data to store in the texture
  80395. * @param format defines the format of the data
  80396. * @param invertY defines if data must be stored with Y axis inverted
  80397. */
  80398. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80399. /**
  80400. * Update a raw texture
  80401. * @param texture defines the texture to update
  80402. * @param data defines the data to store in the texture
  80403. * @param format defines the format of the data
  80404. * @param invertY defines if data must be stored with Y axis inverted
  80405. * @param compression defines the compression used (null by default)
  80406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80407. */
  80408. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80409. /**
  80410. * Creates a new raw cube texture
  80411. * @param data defines the array of data to use to create each face
  80412. * @param size defines the size of the textures
  80413. * @param format defines the format of the data
  80414. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80415. * @param generateMipMaps defines if the engine should generate the mip levels
  80416. * @param invertY defines if data must be stored with Y axis inverted
  80417. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80418. * @param compression defines the compression used (null by default)
  80419. * @returns the cube texture as an InternalTexture
  80420. */
  80421. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80422. /**
  80423. * Update a raw cube texture
  80424. * @param texture defines the texture to udpdate
  80425. * @param data defines the data to store
  80426. * @param format defines the data format
  80427. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80428. * @param invertY defines if data must be stored with Y axis inverted
  80429. */
  80430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80431. /**
  80432. * Update a raw cube texture
  80433. * @param texture defines the texture to udpdate
  80434. * @param data defines the data to store
  80435. * @param format defines the data format
  80436. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80437. * @param invertY defines if data must be stored with Y axis inverted
  80438. * @param compression defines the compression used (null by default)
  80439. */
  80440. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80441. /**
  80442. * Update a raw cube texture
  80443. * @param texture defines the texture to udpdate
  80444. * @param data defines the data to store
  80445. * @param format defines the data format
  80446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80447. * @param invertY defines if data must be stored with Y axis inverted
  80448. * @param compression defines the compression used (null by default)
  80449. * @param level defines which level of the texture to update
  80450. */
  80451. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80452. /**
  80453. * Creates a new raw cube texture from a specified url
  80454. * @param url defines the url where the data is located
  80455. * @param scene defines the current scene
  80456. * @param size defines the size of the textures
  80457. * @param format defines the format of the data
  80458. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80459. * @param noMipmap defines if the engine should avoid generating the mip levels
  80460. * @param callback defines a callback used to extract texture data from loaded data
  80461. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80462. * @param onLoad defines a callback called when texture is loaded
  80463. * @param onError defines a callback called if there is an error
  80464. * @returns the cube texture as an InternalTexture
  80465. */
  80466. 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;
  80467. /**
  80468. * Creates a new raw cube texture from a specified url
  80469. * @param url defines the url where the data is located
  80470. * @param scene defines the current scene
  80471. * @param size defines the size of the textures
  80472. * @param format defines the format of the data
  80473. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80474. * @param noMipmap defines if the engine should avoid generating the mip levels
  80475. * @param callback defines a callback used to extract texture data from loaded data
  80476. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80477. * @param onLoad defines a callback called when texture is loaded
  80478. * @param onError defines a callback called if there is an error
  80479. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80480. * @param invertY defines if data must be stored with Y axis inverted
  80481. * @returns the cube texture as an InternalTexture
  80482. */
  80483. 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;
  80484. /**
  80485. * Creates a new raw 3D texture
  80486. * @param data defines the data used to create the texture
  80487. * @param width defines the width of the texture
  80488. * @param height defines the height of the texture
  80489. * @param depth defines the depth of the texture
  80490. * @param format defines the format of the texture
  80491. * @param generateMipMaps defines if the engine must generate mip levels
  80492. * @param invertY defines if data must be stored with Y axis inverted
  80493. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80494. * @param compression defines the compressed used (can be null)
  80495. * @param textureType defines the compressed used (can be null)
  80496. * @returns a new raw 3D texture (stored in an InternalTexture)
  80497. */
  80498. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80499. /**
  80500. * Update a raw 3D texture
  80501. * @param texture defines the texture to update
  80502. * @param data defines the data to store
  80503. * @param format defines the data format
  80504. * @param invertY defines if data must be stored with Y axis inverted
  80505. */
  80506. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80507. /**
  80508. * Update a raw 3D texture
  80509. * @param texture defines the texture to update
  80510. * @param data defines the data to store
  80511. * @param format defines the data format
  80512. * @param invertY defines if data must be stored with Y axis inverted
  80513. * @param compression defines the used compression (can be null)
  80514. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80515. */
  80516. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80517. /**
  80518. * Creates a new raw 2D array texture
  80519. * @param data defines the data used to create the texture
  80520. * @param width defines the width of the texture
  80521. * @param height defines the height of the texture
  80522. * @param depth defines the number of layers of the texture
  80523. * @param format defines the format of the texture
  80524. * @param generateMipMaps defines if the engine must generate mip levels
  80525. * @param invertY defines if data must be stored with Y axis inverted
  80526. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80527. * @param compression defines the compressed used (can be null)
  80528. * @param textureType defines the compressed used (can be null)
  80529. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80530. */
  80531. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80532. /**
  80533. * Update a raw 2D array texture
  80534. * @param texture defines the texture to update
  80535. * @param data defines the data to store
  80536. * @param format defines the data format
  80537. * @param invertY defines if data must be stored with Y axis inverted
  80538. */
  80539. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80540. /**
  80541. * Update a raw 2D array texture
  80542. * @param texture defines the texture to update
  80543. * @param data defines the data to store
  80544. * @param format defines the data format
  80545. * @param invertY defines if data must be stored with Y axis inverted
  80546. * @param compression defines the used compression (can be null)
  80547. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80548. */
  80549. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80550. }
  80551. }
  80552. declare module BABYLON {
  80553. /**
  80554. * Raw texture can help creating a texture directly from an array of data.
  80555. * This can be super useful if you either get the data from an uncompressed source or
  80556. * if you wish to create your texture pixel by pixel.
  80557. */
  80558. export class RawTexture extends Texture {
  80559. /**
  80560. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80561. */
  80562. format: number;
  80563. private _engine;
  80564. /**
  80565. * Instantiates a new RawTexture.
  80566. * Raw texture can help creating a texture directly from an array of data.
  80567. * This can be super useful if you either get the data from an uncompressed source or
  80568. * if you wish to create your texture pixel by pixel.
  80569. * @param data define the array of data to use to create the texture
  80570. * @param width define the width of the texture
  80571. * @param height define the height of the texture
  80572. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80573. * @param scene define the scene the texture belongs to
  80574. * @param generateMipMaps define whether mip maps should be generated or not
  80575. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80576. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80577. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80578. */
  80579. constructor(data: ArrayBufferView, width: number, height: number,
  80580. /**
  80581. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80582. */
  80583. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80584. /**
  80585. * Updates the texture underlying data.
  80586. * @param data Define the new data of the texture
  80587. */
  80588. update(data: ArrayBufferView): void;
  80589. /**
  80590. * Creates a luminance 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 luminance texture
  80599. */
  80600. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80601. /**
  80602. * Creates a luminance alpha 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. * @returns the luminance alpha texture
  80611. */
  80612. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80613. /**
  80614. * Creates an alpha texture from some data.
  80615. * @param data Define the texture data
  80616. * @param width Define the width of the texture
  80617. * @param height Define the height of the texture
  80618. * @param scene Define the scene the texture belongs to
  80619. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80622. * @returns the alpha texture
  80623. */
  80624. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80625. /**
  80626. * Creates a RGB texture from some data.
  80627. * @param data Define the texture data
  80628. * @param width Define the width of the texture
  80629. * @param height Define the height of the texture
  80630. * @param scene Define the scene the texture belongs to
  80631. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80632. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80633. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80634. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80635. * @returns the RGB alpha texture
  80636. */
  80637. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80638. /**
  80639. * Creates a RGBA texture from some data.
  80640. * @param data Define the texture data
  80641. * @param width Define the width of the texture
  80642. * @param height Define the height of the texture
  80643. * @param scene Define the scene the texture belongs to
  80644. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80645. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80646. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80647. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80648. * @returns the RGBA texture
  80649. */
  80650. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80651. /**
  80652. * Creates a R texture from some data.
  80653. * @param data Define the texture data
  80654. * @param width Define the width of the texture
  80655. * @param height Define the height of the texture
  80656. * @param scene Define the scene the texture belongs to
  80657. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80658. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80659. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80660. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80661. * @returns the R texture
  80662. */
  80663. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80664. }
  80665. }
  80666. declare module BABYLON {
  80667. /**
  80668. * Interface for the size containing width and height
  80669. */
  80670. export interface ISize {
  80671. /**
  80672. * Width
  80673. */
  80674. width: number;
  80675. /**
  80676. * Heighht
  80677. */
  80678. height: number;
  80679. }
  80680. /**
  80681. * Size containing widht and height
  80682. */
  80683. export class Size implements ISize {
  80684. /**
  80685. * Width
  80686. */
  80687. width: number;
  80688. /**
  80689. * Height
  80690. */
  80691. height: number;
  80692. /**
  80693. * Creates a Size object from the given width and height (floats).
  80694. * @param width width of the new size
  80695. * @param height height of the new size
  80696. */
  80697. constructor(width: number, height: number);
  80698. /**
  80699. * Returns a string with the Size width and height
  80700. * @returns a string with the Size width and height
  80701. */
  80702. toString(): string;
  80703. /**
  80704. * "Size"
  80705. * @returns the string "Size"
  80706. */
  80707. getClassName(): string;
  80708. /**
  80709. * Returns the Size hash code.
  80710. * @returns a hash code for a unique width and height
  80711. */
  80712. getHashCode(): number;
  80713. /**
  80714. * Updates the current size from the given one.
  80715. * @param src the given size
  80716. */
  80717. copyFrom(src: Size): void;
  80718. /**
  80719. * Updates in place the current Size from the given floats.
  80720. * @param width width of the new size
  80721. * @param height height of the new size
  80722. * @returns the updated Size.
  80723. */
  80724. copyFromFloats(width: number, height: number): Size;
  80725. /**
  80726. * Updates in place the current Size from the given floats.
  80727. * @param width width to set
  80728. * @param height height to set
  80729. * @returns the updated Size.
  80730. */
  80731. set(width: number, height: number): Size;
  80732. /**
  80733. * Multiplies the width and height by numbers
  80734. * @param w factor to multiple the width by
  80735. * @param h factor to multiple the height by
  80736. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80737. */
  80738. multiplyByFloats(w: number, h: number): Size;
  80739. /**
  80740. * Clones the size
  80741. * @returns a new Size copied from the given one.
  80742. */
  80743. clone(): Size;
  80744. /**
  80745. * True if the current Size and the given one width and height are strictly equal.
  80746. * @param other the other size to compare against
  80747. * @returns True if the current Size and the given one width and height are strictly equal.
  80748. */
  80749. equals(other: Size): boolean;
  80750. /**
  80751. * The surface of the Size : width * height (float).
  80752. */
  80753. readonly surface: number;
  80754. /**
  80755. * Create a new size of zero
  80756. * @returns a new Size set to (0.0, 0.0)
  80757. */
  80758. static Zero(): Size;
  80759. /**
  80760. * Sums the width and height of two sizes
  80761. * @param otherSize size to add to this size
  80762. * @returns a new Size set as the addition result of the current Size and the given one.
  80763. */
  80764. add(otherSize: Size): Size;
  80765. /**
  80766. * Subtracts the width and height of two
  80767. * @param otherSize size to subtract to this size
  80768. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80769. */
  80770. subtract(otherSize: Size): Size;
  80771. /**
  80772. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80773. * @param start starting size to lerp between
  80774. * @param end end size to lerp between
  80775. * @param amount amount to lerp between the start and end values
  80776. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80777. */
  80778. static Lerp(start: Size, end: Size, amount: number): Size;
  80779. }
  80780. }
  80781. declare module BABYLON {
  80782. /**
  80783. * Defines a runtime animation
  80784. */
  80785. export class RuntimeAnimation {
  80786. private _events;
  80787. /**
  80788. * The current frame of the runtime animation
  80789. */
  80790. private _currentFrame;
  80791. /**
  80792. * The animation used by the runtime animation
  80793. */
  80794. private _animation;
  80795. /**
  80796. * The target of the runtime animation
  80797. */
  80798. private _target;
  80799. /**
  80800. * The initiating animatable
  80801. */
  80802. private _host;
  80803. /**
  80804. * The original value of the runtime animation
  80805. */
  80806. private _originalValue;
  80807. /**
  80808. * The original blend value of the runtime animation
  80809. */
  80810. private _originalBlendValue;
  80811. /**
  80812. * The offsets cache of the runtime animation
  80813. */
  80814. private _offsetsCache;
  80815. /**
  80816. * The high limits cache of the runtime animation
  80817. */
  80818. private _highLimitsCache;
  80819. /**
  80820. * Specifies if the runtime animation has been stopped
  80821. */
  80822. private _stopped;
  80823. /**
  80824. * The blending factor of the runtime animation
  80825. */
  80826. private _blendingFactor;
  80827. /**
  80828. * The BabylonJS scene
  80829. */
  80830. private _scene;
  80831. /**
  80832. * The current value of the runtime animation
  80833. */
  80834. private _currentValue;
  80835. /** @hidden */
  80836. _animationState: _IAnimationState;
  80837. /**
  80838. * The active target of the runtime animation
  80839. */
  80840. private _activeTargets;
  80841. private _currentActiveTarget;
  80842. private _directTarget;
  80843. /**
  80844. * The target path of the runtime animation
  80845. */
  80846. private _targetPath;
  80847. /**
  80848. * The weight of the runtime animation
  80849. */
  80850. private _weight;
  80851. /**
  80852. * The ratio offset of the runtime animation
  80853. */
  80854. private _ratioOffset;
  80855. /**
  80856. * The previous delay of the runtime animation
  80857. */
  80858. private _previousDelay;
  80859. /**
  80860. * The previous ratio of the runtime animation
  80861. */
  80862. private _previousRatio;
  80863. private _enableBlending;
  80864. private _keys;
  80865. private _minFrame;
  80866. private _maxFrame;
  80867. private _minValue;
  80868. private _maxValue;
  80869. private _targetIsArray;
  80870. /**
  80871. * Gets the current frame of the runtime animation
  80872. */
  80873. readonly currentFrame: number;
  80874. /**
  80875. * Gets the weight of the runtime animation
  80876. */
  80877. readonly weight: number;
  80878. /**
  80879. * Gets the current value of the runtime animation
  80880. */
  80881. readonly currentValue: any;
  80882. /**
  80883. * Gets the target path of the runtime animation
  80884. */
  80885. readonly targetPath: string;
  80886. /**
  80887. * Gets the actual target of the runtime animation
  80888. */
  80889. readonly target: any;
  80890. /** @hidden */
  80891. _onLoop: () => void;
  80892. /**
  80893. * Create a new RuntimeAnimation object
  80894. * @param target defines the target of the animation
  80895. * @param animation defines the source animation object
  80896. * @param scene defines the hosting scene
  80897. * @param host defines the initiating Animatable
  80898. */
  80899. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80900. private _preparePath;
  80901. /**
  80902. * Gets the animation from the runtime animation
  80903. */
  80904. readonly animation: Animation;
  80905. /**
  80906. * Resets the runtime animation to the beginning
  80907. * @param restoreOriginal defines whether to restore the target property to the original value
  80908. */
  80909. reset(restoreOriginal?: boolean): void;
  80910. /**
  80911. * Specifies if the runtime animation is stopped
  80912. * @returns Boolean specifying if the runtime animation is stopped
  80913. */
  80914. isStopped(): boolean;
  80915. /**
  80916. * Disposes of the runtime animation
  80917. */
  80918. dispose(): void;
  80919. /**
  80920. * Apply the interpolated value to the target
  80921. * @param currentValue defines the value computed by the animation
  80922. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80923. */
  80924. setValue(currentValue: any, weight: number): void;
  80925. private _getOriginalValues;
  80926. private _setValue;
  80927. /**
  80928. * Gets the loop pmode of the runtime animation
  80929. * @returns Loop Mode
  80930. */
  80931. private _getCorrectLoopMode;
  80932. /**
  80933. * Move the current animation to a given frame
  80934. * @param frame defines the frame to move to
  80935. */
  80936. goToFrame(frame: number): void;
  80937. /**
  80938. * @hidden Internal use only
  80939. */
  80940. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80941. /**
  80942. * Execute the current animation
  80943. * @param delay defines the delay to add to the current frame
  80944. * @param from defines the lower bound of the animation range
  80945. * @param to defines the upper bound of the animation range
  80946. * @param loop defines if the current animation must loop
  80947. * @param speedRatio defines the current speed ratio
  80948. * @param weight defines the weight of the animation (default is -1 so no weight)
  80949. * @param onLoop optional callback called when animation loops
  80950. * @returns a boolean indicating if the animation is running
  80951. */
  80952. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80953. }
  80954. }
  80955. declare module BABYLON {
  80956. /**
  80957. * Class used to store an actual running animation
  80958. */
  80959. export class Animatable {
  80960. /** defines the target object */
  80961. target: any;
  80962. /** defines the starting frame number (default is 0) */
  80963. fromFrame: number;
  80964. /** defines the ending frame number (default is 100) */
  80965. toFrame: number;
  80966. /** defines if the animation must loop (default is false) */
  80967. loopAnimation: boolean;
  80968. /** defines a callback to call when animation ends if it is not looping */
  80969. onAnimationEnd?: (() => void) | null | undefined;
  80970. /** defines a callback to call when animation loops */
  80971. onAnimationLoop?: (() => void) | null | undefined;
  80972. private _localDelayOffset;
  80973. private _pausedDelay;
  80974. private _runtimeAnimations;
  80975. private _paused;
  80976. private _scene;
  80977. private _speedRatio;
  80978. private _weight;
  80979. private _syncRoot;
  80980. /**
  80981. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80982. * This will only apply for non looping animation (default is true)
  80983. */
  80984. disposeOnEnd: boolean;
  80985. /**
  80986. * Gets a boolean indicating if the animation has started
  80987. */
  80988. animationStarted: boolean;
  80989. /**
  80990. * Observer raised when the animation ends
  80991. */
  80992. onAnimationEndObservable: Observable<Animatable>;
  80993. /**
  80994. * Observer raised when the animation loops
  80995. */
  80996. onAnimationLoopObservable: Observable<Animatable>;
  80997. /**
  80998. * Gets the root Animatable used to synchronize and normalize animations
  80999. */
  81000. readonly syncRoot: Nullable<Animatable>;
  81001. /**
  81002. * Gets the current frame of the first RuntimeAnimation
  81003. * Used to synchronize Animatables
  81004. */
  81005. readonly masterFrame: number;
  81006. /**
  81007. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81008. */
  81009. weight: number;
  81010. /**
  81011. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81012. */
  81013. speedRatio: number;
  81014. /**
  81015. * Creates a new Animatable
  81016. * @param scene defines the hosting scene
  81017. * @param target defines the target object
  81018. * @param fromFrame defines the starting frame number (default is 0)
  81019. * @param toFrame defines the ending frame number (default is 100)
  81020. * @param loopAnimation defines if the animation must loop (default is false)
  81021. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81022. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81023. * @param animations defines a group of animation to add to the new Animatable
  81024. * @param onAnimationLoop defines a callback to call when animation loops
  81025. */
  81026. constructor(scene: Scene,
  81027. /** defines the target object */
  81028. target: any,
  81029. /** defines the starting frame number (default is 0) */
  81030. fromFrame?: number,
  81031. /** defines the ending frame number (default is 100) */
  81032. toFrame?: number,
  81033. /** defines if the animation must loop (default is false) */
  81034. loopAnimation?: boolean, speedRatio?: number,
  81035. /** defines a callback to call when animation ends if it is not looping */
  81036. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81037. /** defines a callback to call when animation loops */
  81038. onAnimationLoop?: (() => void) | null | undefined);
  81039. /**
  81040. * Synchronize and normalize current Animatable with a source Animatable
  81041. * This is useful when using animation weights and when animations are not of the same length
  81042. * @param root defines the root Animatable to synchronize with
  81043. * @returns the current Animatable
  81044. */
  81045. syncWith(root: Animatable): Animatable;
  81046. /**
  81047. * Gets the list of runtime animations
  81048. * @returns an array of RuntimeAnimation
  81049. */
  81050. getAnimations(): RuntimeAnimation[];
  81051. /**
  81052. * Adds more animations to the current animatable
  81053. * @param target defines the target of the animations
  81054. * @param animations defines the new animations to add
  81055. */
  81056. appendAnimations(target: any, animations: Animation[]): void;
  81057. /**
  81058. * Gets the source animation for a specific property
  81059. * @param property defines the propertyu to look for
  81060. * @returns null or the source animation for the given property
  81061. */
  81062. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81063. /**
  81064. * Gets the runtime animation for a specific property
  81065. * @param property defines the propertyu to look for
  81066. * @returns null or the runtime animation for the given property
  81067. */
  81068. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81069. /**
  81070. * Resets the animatable to its original state
  81071. */
  81072. reset(): void;
  81073. /**
  81074. * Allows the animatable to blend with current running animations
  81075. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81076. * @param blendingSpeed defines the blending speed to use
  81077. */
  81078. enableBlending(blendingSpeed: number): void;
  81079. /**
  81080. * Disable animation blending
  81081. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81082. */
  81083. disableBlending(): void;
  81084. /**
  81085. * Jump directly to a given frame
  81086. * @param frame defines the frame to jump to
  81087. */
  81088. goToFrame(frame: number): void;
  81089. /**
  81090. * Pause the animation
  81091. */
  81092. pause(): void;
  81093. /**
  81094. * Restart the animation
  81095. */
  81096. restart(): void;
  81097. private _raiseOnAnimationEnd;
  81098. /**
  81099. * Stop and delete the current animation
  81100. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81101. * @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)
  81102. */
  81103. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81104. /**
  81105. * Wait asynchronously for the animation to end
  81106. * @returns a promise which will be fullfilled when the animation ends
  81107. */
  81108. waitAsync(): Promise<Animatable>;
  81109. /** @hidden */
  81110. _animate(delay: number): boolean;
  81111. }
  81112. interface Scene {
  81113. /** @hidden */
  81114. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81115. /** @hidden */
  81116. _processLateAnimationBindingsForMatrices(holder: {
  81117. totalWeight: number;
  81118. animations: RuntimeAnimation[];
  81119. originalValue: Matrix;
  81120. }): any;
  81121. /** @hidden */
  81122. _processLateAnimationBindingsForQuaternions(holder: {
  81123. totalWeight: number;
  81124. animations: RuntimeAnimation[];
  81125. originalValue: Quaternion;
  81126. }, refQuaternion: Quaternion): Quaternion;
  81127. /** @hidden */
  81128. _processLateAnimationBindings(): void;
  81129. /**
  81130. * Will start the animation sequence of a given target
  81131. * @param target defines the target
  81132. * @param from defines from which frame should animation start
  81133. * @param to defines until which frame should animation run.
  81134. * @param weight defines the weight to apply to the animation (1.0 by default)
  81135. * @param loop defines if the animation loops
  81136. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81137. * @param onAnimationEnd defines the function to be executed when the animation ends
  81138. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81139. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81140. * @param onAnimationLoop defines the callback to call when an animation loops
  81141. * @returns the animatable object created for this animation
  81142. */
  81143. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81144. /**
  81145. * Will start the animation sequence of a given target
  81146. * @param target defines the target
  81147. * @param from defines from which frame should animation start
  81148. * @param to defines until which frame should animation run.
  81149. * @param loop defines if the animation loops
  81150. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81151. * @param onAnimationEnd defines the function to be executed when the animation ends
  81152. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81153. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81154. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81155. * @param onAnimationLoop defines the callback to call when an animation loops
  81156. * @returns the animatable object created for this animation
  81157. */
  81158. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81159. /**
  81160. * Will start the animation sequence of a given target and its hierarchy
  81161. * @param target defines the target
  81162. * @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.
  81163. * @param from defines from which frame should animation start
  81164. * @param to defines until which frame should animation run.
  81165. * @param loop defines if the animation loops
  81166. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81167. * @param onAnimationEnd defines the function to be executed when the animation ends
  81168. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81169. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81170. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81171. * @param onAnimationLoop defines the callback to call when an animation loops
  81172. * @returns the list of created animatables
  81173. */
  81174. 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[];
  81175. /**
  81176. * Begin a new animation on a given node
  81177. * @param target defines the target where the animation will take place
  81178. * @param animations defines the list of animations to start
  81179. * @param from defines the initial value
  81180. * @param to defines the final value
  81181. * @param loop defines if you want animation to loop (off by default)
  81182. * @param speedRatio defines the speed ratio to apply to all animations
  81183. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81184. * @param onAnimationLoop defines the callback to call when an animation loops
  81185. * @returns the list of created animatables
  81186. */
  81187. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81188. /**
  81189. * Begin a new animation on a given node and its hierarchy
  81190. * @param target defines the root node where the animation will take place
  81191. * @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.
  81192. * @param animations defines the list of animations to start
  81193. * @param from defines the initial value
  81194. * @param to defines the final value
  81195. * @param loop defines if you want animation to loop (off by default)
  81196. * @param speedRatio defines the speed ratio to apply to all animations
  81197. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81198. * @param onAnimationLoop defines the callback to call when an animation loops
  81199. * @returns the list of animatables created for all nodes
  81200. */
  81201. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81202. /**
  81203. * Gets the animatable associated with a specific target
  81204. * @param target defines the target of the animatable
  81205. * @returns the required animatable if found
  81206. */
  81207. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81208. /**
  81209. * Gets all animatables associated with a given target
  81210. * @param target defines the target to look animatables for
  81211. * @returns an array of Animatables
  81212. */
  81213. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81214. /**
  81215. * Stops and removes all animations that have been applied to the scene
  81216. */
  81217. stopAllAnimations(): void;
  81218. /**
  81219. * Gets the current delta time used by animation engine
  81220. */
  81221. deltaTime: number;
  81222. }
  81223. interface Bone {
  81224. /**
  81225. * Copy an animation range from another bone
  81226. * @param source defines the source bone
  81227. * @param rangeName defines the range name to copy
  81228. * @param frameOffset defines the frame offset
  81229. * @param rescaleAsRequired defines if rescaling must be applied if required
  81230. * @param skelDimensionsRatio defines the scaling ratio
  81231. * @returns true if operation was successful
  81232. */
  81233. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81234. }
  81235. }
  81236. declare module BABYLON {
  81237. /**
  81238. * Class used to override all child animations of a given target
  81239. */
  81240. export class AnimationPropertiesOverride {
  81241. /**
  81242. * Gets or sets a value indicating if animation blending must be used
  81243. */
  81244. enableBlending: boolean;
  81245. /**
  81246. * Gets or sets the blending speed to use when enableBlending is true
  81247. */
  81248. blendingSpeed: number;
  81249. /**
  81250. * Gets or sets the default loop mode to use
  81251. */
  81252. loopMode: number;
  81253. }
  81254. }
  81255. declare module BABYLON {
  81256. /**
  81257. * Class used to handle skinning animations
  81258. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81259. */
  81260. export class Skeleton implements IAnimatable {
  81261. /** defines the skeleton name */
  81262. name: string;
  81263. /** defines the skeleton Id */
  81264. id: string;
  81265. /**
  81266. * Defines the list of child bones
  81267. */
  81268. bones: Bone[];
  81269. /**
  81270. * Defines an estimate of the dimension of the skeleton at rest
  81271. */
  81272. dimensionsAtRest: Vector3;
  81273. /**
  81274. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81275. */
  81276. needInitialSkinMatrix: boolean;
  81277. /**
  81278. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81279. */
  81280. overrideMesh: Nullable<AbstractMesh>;
  81281. /**
  81282. * Gets the list of animations attached to this skeleton
  81283. */
  81284. animations: Array<Animation>;
  81285. private _scene;
  81286. private _isDirty;
  81287. private _transformMatrices;
  81288. private _transformMatrixTexture;
  81289. private _meshesWithPoseMatrix;
  81290. private _animatables;
  81291. private _identity;
  81292. private _synchronizedWithMesh;
  81293. private _ranges;
  81294. private _lastAbsoluteTransformsUpdateId;
  81295. private _canUseTextureForBones;
  81296. private _uniqueId;
  81297. /** @hidden */
  81298. _numBonesWithLinkedTransformNode: number;
  81299. /** @hidden */
  81300. _hasWaitingData: Nullable<boolean>;
  81301. /**
  81302. * Specifies if the skeleton should be serialized
  81303. */
  81304. doNotSerialize: boolean;
  81305. private _useTextureToStoreBoneMatrices;
  81306. /**
  81307. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81308. * Please note that this option is not available if the hardware does not support it
  81309. */
  81310. useTextureToStoreBoneMatrices: boolean;
  81311. private _animationPropertiesOverride;
  81312. /**
  81313. * Gets or sets the animation properties override
  81314. */
  81315. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81316. /**
  81317. * List of inspectable custom properties (used by the Inspector)
  81318. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81319. */
  81320. inspectableCustomProperties: IInspectable[];
  81321. /**
  81322. * An observable triggered before computing the skeleton's matrices
  81323. */
  81324. onBeforeComputeObservable: Observable<Skeleton>;
  81325. /**
  81326. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81327. */
  81328. readonly isUsingTextureForMatrices: boolean;
  81329. /**
  81330. * Gets the unique ID of this skeleton
  81331. */
  81332. readonly uniqueId: number;
  81333. /**
  81334. * Creates a new skeleton
  81335. * @param name defines the skeleton name
  81336. * @param id defines the skeleton Id
  81337. * @param scene defines the hosting scene
  81338. */
  81339. constructor(
  81340. /** defines the skeleton name */
  81341. name: string,
  81342. /** defines the skeleton Id */
  81343. id: string, scene: Scene);
  81344. /**
  81345. * Gets the current object class name.
  81346. * @return the class name
  81347. */
  81348. getClassName(): string;
  81349. /**
  81350. * Returns an array containing the root bones
  81351. * @returns an array containing the root bones
  81352. */
  81353. getChildren(): Array<Bone>;
  81354. /**
  81355. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81356. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81357. * @returns a Float32Array containing matrices data
  81358. */
  81359. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81360. /**
  81361. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81362. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81363. * @returns a raw texture containing the data
  81364. */
  81365. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81366. /**
  81367. * Gets the current hosting scene
  81368. * @returns a scene object
  81369. */
  81370. getScene(): Scene;
  81371. /**
  81372. * Gets a string representing the current skeleton data
  81373. * @param fullDetails defines a boolean indicating if we want a verbose version
  81374. * @returns a string representing the current skeleton data
  81375. */
  81376. toString(fullDetails?: boolean): string;
  81377. /**
  81378. * Get bone's index searching by name
  81379. * @param name defines bone's name to search for
  81380. * @return the indice of the bone. Returns -1 if not found
  81381. */
  81382. getBoneIndexByName(name: string): number;
  81383. /**
  81384. * Creater a new animation range
  81385. * @param name defines the name of the range
  81386. * @param from defines the start key
  81387. * @param to defines the end key
  81388. */
  81389. createAnimationRange(name: string, from: number, to: number): void;
  81390. /**
  81391. * Delete a specific animation range
  81392. * @param name defines the name of the range
  81393. * @param deleteFrames defines if frames must be removed as well
  81394. */
  81395. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81396. /**
  81397. * Gets a specific animation range
  81398. * @param name defines the name of the range to look for
  81399. * @returns the requested animation range or null if not found
  81400. */
  81401. getAnimationRange(name: string): Nullable<AnimationRange>;
  81402. /**
  81403. * Gets the list of all animation ranges defined on this skeleton
  81404. * @returns an array
  81405. */
  81406. getAnimationRanges(): Nullable<AnimationRange>[];
  81407. /**
  81408. * Copy animation range from a source skeleton.
  81409. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81410. * @param source defines the source skeleton
  81411. * @param name defines the name of the range to copy
  81412. * @param rescaleAsRequired defines if rescaling must be applied if required
  81413. * @returns true if operation was successful
  81414. */
  81415. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81416. /**
  81417. * Forces the skeleton to go to rest pose
  81418. */
  81419. returnToRest(): void;
  81420. private _getHighestAnimationFrame;
  81421. /**
  81422. * Begin a specific animation range
  81423. * @param name defines the name of the range to start
  81424. * @param loop defines if looping must be turned on (false by default)
  81425. * @param speedRatio defines the speed ratio to apply (1 by default)
  81426. * @param onAnimationEnd defines a callback which will be called when animation will end
  81427. * @returns a new animatable
  81428. */
  81429. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81430. /** @hidden */
  81431. _markAsDirty(): void;
  81432. /** @hidden */
  81433. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81434. /** @hidden */
  81435. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81436. private _computeTransformMatrices;
  81437. /**
  81438. * Build all resources required to render a skeleton
  81439. */
  81440. prepare(): void;
  81441. /**
  81442. * Gets the list of animatables currently running for this skeleton
  81443. * @returns an array of animatables
  81444. */
  81445. getAnimatables(): IAnimatable[];
  81446. /**
  81447. * Clone the current skeleton
  81448. * @param name defines the name of the new skeleton
  81449. * @param id defines the id of the new skeleton
  81450. * @returns the new skeleton
  81451. */
  81452. clone(name: string, id?: string): Skeleton;
  81453. /**
  81454. * Enable animation blending for this skeleton
  81455. * @param blendingSpeed defines the blending speed to apply
  81456. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81457. */
  81458. enableBlending(blendingSpeed?: number): void;
  81459. /**
  81460. * Releases all resources associated with the current skeleton
  81461. */
  81462. dispose(): void;
  81463. /**
  81464. * Serialize the skeleton in a JSON object
  81465. * @returns a JSON object
  81466. */
  81467. serialize(): any;
  81468. /**
  81469. * Creates a new skeleton from serialized data
  81470. * @param parsedSkeleton defines the serialized data
  81471. * @param scene defines the hosting scene
  81472. * @returns a new skeleton
  81473. */
  81474. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81475. /**
  81476. * Compute all node absolute transforms
  81477. * @param forceUpdate defines if computation must be done even if cache is up to date
  81478. */
  81479. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81480. /**
  81481. * Gets the root pose matrix
  81482. * @returns a matrix
  81483. */
  81484. getPoseMatrix(): Nullable<Matrix>;
  81485. /**
  81486. * Sorts bones per internal index
  81487. */
  81488. sortBones(): void;
  81489. private _sortBones;
  81490. }
  81491. }
  81492. declare module BABYLON {
  81493. /**
  81494. * Class used to store bone information
  81495. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81496. */
  81497. export class Bone extends Node {
  81498. /**
  81499. * defines the bone name
  81500. */
  81501. name: string;
  81502. private static _tmpVecs;
  81503. private static _tmpQuat;
  81504. private static _tmpMats;
  81505. /**
  81506. * Gets the list of child bones
  81507. */
  81508. children: Bone[];
  81509. /** Gets the animations associated with this bone */
  81510. animations: Animation[];
  81511. /**
  81512. * Gets or sets bone length
  81513. */
  81514. length: number;
  81515. /**
  81516. * @hidden Internal only
  81517. * Set this value to map this bone to a different index in the transform matrices
  81518. * Set this value to -1 to exclude the bone from the transform matrices
  81519. */
  81520. _index: Nullable<number>;
  81521. private _skeleton;
  81522. private _localMatrix;
  81523. private _restPose;
  81524. private _baseMatrix;
  81525. private _absoluteTransform;
  81526. private _invertedAbsoluteTransform;
  81527. private _parent;
  81528. private _scalingDeterminant;
  81529. private _worldTransform;
  81530. private _localScaling;
  81531. private _localRotation;
  81532. private _localPosition;
  81533. private _needToDecompose;
  81534. private _needToCompose;
  81535. /** @hidden */
  81536. _linkedTransformNode: Nullable<TransformNode>;
  81537. /** @hidden */
  81538. _waitingTransformNodeId: Nullable<string>;
  81539. /** @hidden */
  81540. /** @hidden */
  81541. _matrix: Matrix;
  81542. /**
  81543. * Create a new bone
  81544. * @param name defines the bone name
  81545. * @param skeleton defines the parent skeleton
  81546. * @param parentBone defines the parent (can be null if the bone is the root)
  81547. * @param localMatrix defines the local matrix
  81548. * @param restPose defines the rest pose matrix
  81549. * @param baseMatrix defines the base matrix
  81550. * @param index defines index of the bone in the hiearchy
  81551. */
  81552. constructor(
  81553. /**
  81554. * defines the bone name
  81555. */
  81556. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81557. /**
  81558. * Gets the current object class name.
  81559. * @return the class name
  81560. */
  81561. getClassName(): string;
  81562. /**
  81563. * Gets the parent skeleton
  81564. * @returns a skeleton
  81565. */
  81566. getSkeleton(): Skeleton;
  81567. /**
  81568. * Gets parent bone
  81569. * @returns a bone or null if the bone is the root of the bone hierarchy
  81570. */
  81571. getParent(): Nullable<Bone>;
  81572. /**
  81573. * Returns an array containing the root bones
  81574. * @returns an array containing the root bones
  81575. */
  81576. getChildren(): Array<Bone>;
  81577. /**
  81578. * Gets the node index in matrix array generated for rendering
  81579. * @returns the node index
  81580. */
  81581. getIndex(): number;
  81582. /**
  81583. * Sets the parent bone
  81584. * @param parent defines the parent (can be null if the bone is the root)
  81585. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81586. */
  81587. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81588. /**
  81589. * Gets the local matrix
  81590. * @returns a matrix
  81591. */
  81592. getLocalMatrix(): Matrix;
  81593. /**
  81594. * Gets the base matrix (initial matrix which remains unchanged)
  81595. * @returns a matrix
  81596. */
  81597. getBaseMatrix(): Matrix;
  81598. /**
  81599. * Gets the rest pose matrix
  81600. * @returns a matrix
  81601. */
  81602. getRestPose(): Matrix;
  81603. /**
  81604. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81605. */
  81606. getWorldMatrix(): Matrix;
  81607. /**
  81608. * Sets the local matrix to rest pose matrix
  81609. */
  81610. returnToRest(): void;
  81611. /**
  81612. * Gets the inverse of the absolute transform matrix.
  81613. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81614. * @returns a matrix
  81615. */
  81616. getInvertedAbsoluteTransform(): Matrix;
  81617. /**
  81618. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81619. * @returns a matrix
  81620. */
  81621. getAbsoluteTransform(): Matrix;
  81622. /**
  81623. * Links with the given transform node.
  81624. * The local matrix of this bone is copied from the transform node every frame.
  81625. * @param transformNode defines the transform node to link to
  81626. */
  81627. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81628. /**
  81629. * Gets the node used to drive the bone's transformation
  81630. * @returns a transform node or null
  81631. */
  81632. getTransformNode(): Nullable<TransformNode>;
  81633. /** Gets or sets current position (in local space) */
  81634. position: Vector3;
  81635. /** Gets or sets current rotation (in local space) */
  81636. rotation: Vector3;
  81637. /** Gets or sets current rotation quaternion (in local space) */
  81638. rotationQuaternion: Quaternion;
  81639. /** Gets or sets current scaling (in local space) */
  81640. scaling: Vector3;
  81641. /**
  81642. * Gets the animation properties override
  81643. */
  81644. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81645. private _decompose;
  81646. private _compose;
  81647. /**
  81648. * Update the base and local matrices
  81649. * @param matrix defines the new base or local matrix
  81650. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81651. * @param updateLocalMatrix defines if the local matrix should be updated
  81652. */
  81653. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81654. /** @hidden */
  81655. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81656. /**
  81657. * Flag the bone as dirty (Forcing it to update everything)
  81658. */
  81659. markAsDirty(): void;
  81660. /** @hidden */
  81661. _markAsDirtyAndCompose(): void;
  81662. private _markAsDirtyAndDecompose;
  81663. /**
  81664. * Translate the bone in local or world space
  81665. * @param vec The amount to translate the bone
  81666. * @param space The space that the translation is in
  81667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81668. */
  81669. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81670. /**
  81671. * Set the postion of the bone in local or world space
  81672. * @param position The position to set the bone
  81673. * @param space The space that the position is in
  81674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81675. */
  81676. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81677. /**
  81678. * Set the absolute position of the bone (world space)
  81679. * @param position The position to set the bone
  81680. * @param mesh The mesh that this bone is attached to
  81681. */
  81682. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81683. /**
  81684. * Scale the bone on the x, y and z axes (in local space)
  81685. * @param x The amount to scale the bone on the x axis
  81686. * @param y The amount to scale the bone on the y axis
  81687. * @param z The amount to scale the bone on the z axis
  81688. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81689. */
  81690. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81691. /**
  81692. * Set the bone scaling in local space
  81693. * @param scale defines the scaling vector
  81694. */
  81695. setScale(scale: Vector3): void;
  81696. /**
  81697. * Gets the current scaling in local space
  81698. * @returns the current scaling vector
  81699. */
  81700. getScale(): Vector3;
  81701. /**
  81702. * Gets the current scaling in local space and stores it in a target vector
  81703. * @param result defines the target vector
  81704. */
  81705. getScaleToRef(result: Vector3): void;
  81706. /**
  81707. * Set the yaw, pitch, and roll of the bone in local or world space
  81708. * @param yaw The rotation of the bone on the y axis
  81709. * @param pitch The rotation of the bone on the x axis
  81710. * @param roll The rotation of the bone on the z axis
  81711. * @param space The space that the axes of rotation are in
  81712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81713. */
  81714. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81715. /**
  81716. * Add a rotation to the bone on an axis in local or world space
  81717. * @param axis The axis to rotate the bone on
  81718. * @param amount The amount to rotate the bone
  81719. * @param space The space that the axis is in
  81720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81721. */
  81722. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81723. /**
  81724. * Set the rotation of the bone to a particular axis angle in local or world space
  81725. * @param axis The axis to rotate the bone on
  81726. * @param angle The angle that the bone should be rotated to
  81727. * @param space The space that the axis is in
  81728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81729. */
  81730. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81731. /**
  81732. * Set the euler rotation of the bone in local of world space
  81733. * @param rotation The euler rotation that the bone should be set to
  81734. * @param space The space that the rotation is in
  81735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81736. */
  81737. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81738. /**
  81739. * Set the quaternion rotation of the bone in local of world space
  81740. * @param quat The quaternion rotation that the bone should be set to
  81741. * @param space The space that the rotation is in
  81742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81743. */
  81744. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81745. /**
  81746. * Set the rotation matrix of the bone in local of world space
  81747. * @param rotMat The rotation matrix that the bone should be set to
  81748. * @param space The space that the rotation is in
  81749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81750. */
  81751. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81752. private _rotateWithMatrix;
  81753. private _getNegativeRotationToRef;
  81754. /**
  81755. * Get the position of the bone in local or world space
  81756. * @param space The space that the returned position is in
  81757. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81758. * @returns The position of the bone
  81759. */
  81760. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81761. /**
  81762. * Copy the position of the bone to a vector3 in local or world space
  81763. * @param space The space that the returned position is in
  81764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81765. * @param result The vector3 to copy the position to
  81766. */
  81767. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81768. /**
  81769. * Get the absolute position of the bone (world space)
  81770. * @param mesh The mesh that this bone is attached to
  81771. * @returns The absolute position of the bone
  81772. */
  81773. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81774. /**
  81775. * Copy the absolute position of the bone (world space) to the result param
  81776. * @param mesh The mesh that this bone is attached to
  81777. * @param result The vector3 to copy the absolute position to
  81778. */
  81779. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81780. /**
  81781. * Compute the absolute transforms of this bone and its children
  81782. */
  81783. computeAbsoluteTransforms(): void;
  81784. /**
  81785. * Get the world direction from an axis that is in the local space of the bone
  81786. * @param localAxis The local direction that is used to compute the world direction
  81787. * @param mesh The mesh that this bone is attached to
  81788. * @returns The world direction
  81789. */
  81790. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81791. /**
  81792. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81793. * @param localAxis The local direction that is used to compute the world direction
  81794. * @param mesh The mesh that this bone is attached to
  81795. * @param result The vector3 that the world direction will be copied to
  81796. */
  81797. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81798. /**
  81799. * Get the euler rotation of the bone in local or world space
  81800. * @param space The space that the rotation should be in
  81801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81802. * @returns The euler rotation
  81803. */
  81804. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81805. /**
  81806. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81807. * @param space The space that the rotation should be in
  81808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81809. * @param result The vector3 that the rotation should be copied to
  81810. */
  81811. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81812. /**
  81813. * Get the quaternion rotation of the bone in either local or world space
  81814. * @param space The space that the rotation should be in
  81815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81816. * @returns The quaternion rotation
  81817. */
  81818. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81819. /**
  81820. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81821. * @param space The space that the rotation should be in
  81822. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81823. * @param result The quaternion that the rotation should be copied to
  81824. */
  81825. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81826. /**
  81827. * Get the rotation matrix of the bone in local or world space
  81828. * @param space The space that the rotation should be in
  81829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81830. * @returns The rotation matrix
  81831. */
  81832. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81833. /**
  81834. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81835. * @param space The space that the rotation should be in
  81836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81837. * @param result The quaternion that the rotation should be copied to
  81838. */
  81839. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81840. /**
  81841. * Get the world position of a point that is in the local space of the bone
  81842. * @param position The local position
  81843. * @param mesh The mesh that this bone is attached to
  81844. * @returns The world position
  81845. */
  81846. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81847. /**
  81848. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81849. * @param position The local position
  81850. * @param mesh The mesh that this bone is attached to
  81851. * @param result The vector3 that the world position should be copied to
  81852. */
  81853. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81854. /**
  81855. * Get the local position of a point that is in world space
  81856. * @param position The world position
  81857. * @param mesh The mesh that this bone is attached to
  81858. * @returns The local position
  81859. */
  81860. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81861. /**
  81862. * Get the local position of a point that is in world space and copy it to the result param
  81863. * @param position The world position
  81864. * @param mesh The mesh that this bone is attached to
  81865. * @param result The vector3 that the local position should be copied to
  81866. */
  81867. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81868. }
  81869. }
  81870. declare module BABYLON {
  81871. /**
  81872. * 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.
  81873. * @see https://doc.babylonjs.com/how_to/transformnode
  81874. */
  81875. export class TransformNode extends Node {
  81876. /**
  81877. * Object will not rotate to face the camera
  81878. */
  81879. static BILLBOARDMODE_NONE: number;
  81880. /**
  81881. * Object will rotate to face the camera but only on the x axis
  81882. */
  81883. static BILLBOARDMODE_X: number;
  81884. /**
  81885. * Object will rotate to face the camera but only on the y axis
  81886. */
  81887. static BILLBOARDMODE_Y: number;
  81888. /**
  81889. * Object will rotate to face the camera but only on the z axis
  81890. */
  81891. static BILLBOARDMODE_Z: number;
  81892. /**
  81893. * Object will rotate to face the camera
  81894. */
  81895. static BILLBOARDMODE_ALL: number;
  81896. /**
  81897. * Object will rotate to face the camera's position instead of orientation
  81898. */
  81899. static BILLBOARDMODE_USE_POSITION: number;
  81900. private _forward;
  81901. private _forwardInverted;
  81902. private _up;
  81903. private _right;
  81904. private _rightInverted;
  81905. private _position;
  81906. private _rotation;
  81907. private _rotationQuaternion;
  81908. protected _scaling: Vector3;
  81909. protected _isDirty: boolean;
  81910. private _transformToBoneReferal;
  81911. private _isAbsoluteSynced;
  81912. private _billboardMode;
  81913. /**
  81914. * Gets or sets the billboard mode. Default is 0.
  81915. *
  81916. * | Value | Type | Description |
  81917. * | --- | --- | --- |
  81918. * | 0 | BILLBOARDMODE_NONE | |
  81919. * | 1 | BILLBOARDMODE_X | |
  81920. * | 2 | BILLBOARDMODE_Y | |
  81921. * | 4 | BILLBOARDMODE_Z | |
  81922. * | 7 | BILLBOARDMODE_ALL | |
  81923. *
  81924. */
  81925. billboardMode: number;
  81926. private _preserveParentRotationForBillboard;
  81927. /**
  81928. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81929. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81930. */
  81931. preserveParentRotationForBillboard: boolean;
  81932. /**
  81933. * 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
  81934. */
  81935. scalingDeterminant: number;
  81936. private _infiniteDistance;
  81937. /**
  81938. * Gets or sets the distance of the object to max, often used by skybox
  81939. */
  81940. infiniteDistance: boolean;
  81941. /**
  81942. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81943. * By default the system will update normals to compensate
  81944. */
  81945. ignoreNonUniformScaling: boolean;
  81946. /**
  81947. * 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
  81948. */
  81949. reIntegrateRotationIntoRotationQuaternion: boolean;
  81950. /** @hidden */
  81951. _poseMatrix: Nullable<Matrix>;
  81952. /** @hidden */
  81953. _localMatrix: Matrix;
  81954. private _usePivotMatrix;
  81955. private _absolutePosition;
  81956. private _absoluteScaling;
  81957. private _absoluteRotationQuaternion;
  81958. private _pivotMatrix;
  81959. private _pivotMatrixInverse;
  81960. protected _postMultiplyPivotMatrix: boolean;
  81961. protected _isWorldMatrixFrozen: boolean;
  81962. /** @hidden */
  81963. _indexInSceneTransformNodesArray: number;
  81964. /**
  81965. * An event triggered after the world matrix is updated
  81966. */
  81967. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81968. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81969. /**
  81970. * Gets a string identifying the name of the class
  81971. * @returns "TransformNode" string
  81972. */
  81973. getClassName(): string;
  81974. /**
  81975. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81976. */
  81977. position: Vector3;
  81978. /**
  81979. * 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)).
  81980. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81981. */
  81982. rotation: Vector3;
  81983. /**
  81984. * 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)).
  81985. */
  81986. scaling: Vector3;
  81987. /**
  81988. * 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).
  81989. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81990. */
  81991. rotationQuaternion: Nullable<Quaternion>;
  81992. /**
  81993. * The forward direction of that transform in world space.
  81994. */
  81995. readonly forward: Vector3;
  81996. /**
  81997. * The up direction of that transform in world space.
  81998. */
  81999. readonly up: Vector3;
  82000. /**
  82001. * The right direction of that transform in world space.
  82002. */
  82003. readonly right: Vector3;
  82004. /**
  82005. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82006. * @param matrix the matrix to copy the pose from
  82007. * @returns this TransformNode.
  82008. */
  82009. updatePoseMatrix(matrix: Matrix): TransformNode;
  82010. /**
  82011. * Returns the mesh Pose matrix.
  82012. * @returns the pose matrix
  82013. */
  82014. getPoseMatrix(): Matrix;
  82015. /** @hidden */
  82016. _isSynchronized(): boolean;
  82017. /** @hidden */
  82018. _initCache(): void;
  82019. /**
  82020. * Flag the transform node as dirty (Forcing it to update everything)
  82021. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82022. * @returns this transform node
  82023. */
  82024. markAsDirty(property: string): TransformNode;
  82025. /**
  82026. * Returns the current mesh absolute position.
  82027. * Returns a Vector3.
  82028. */
  82029. readonly absolutePosition: Vector3;
  82030. /**
  82031. * Returns the current mesh absolute scaling.
  82032. * Returns a Vector3.
  82033. */
  82034. readonly absoluteScaling: Vector3;
  82035. /**
  82036. * Returns the current mesh absolute rotation.
  82037. * Returns a Quaternion.
  82038. */
  82039. readonly absoluteRotationQuaternion: Quaternion;
  82040. /**
  82041. * Sets a new matrix to apply before all other transformation
  82042. * @param matrix defines the transform matrix
  82043. * @returns the current TransformNode
  82044. */
  82045. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82046. /**
  82047. * Sets a new pivot matrix to the current node
  82048. * @param matrix defines the new pivot matrix to use
  82049. * @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
  82050. * @returns the current TransformNode
  82051. */
  82052. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82053. /**
  82054. * Returns the mesh pivot matrix.
  82055. * Default : Identity.
  82056. * @returns the matrix
  82057. */
  82058. getPivotMatrix(): Matrix;
  82059. /**
  82060. * Instantiate (when possible) or clone that node with its hierarchy
  82061. * @param newParent defines the new parent to use for the instance (or clone)
  82062. * @param options defines options to configure how copy is done
  82063. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82064. * @returns an instance (or a clone) of the current node with its hiearchy
  82065. */
  82066. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82067. doNotInstantiate: boolean;
  82068. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82069. /**
  82070. * Prevents the World matrix to be computed any longer
  82071. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82072. * @returns the TransformNode.
  82073. */
  82074. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82075. /**
  82076. * Allows back the World matrix computation.
  82077. * @returns the TransformNode.
  82078. */
  82079. unfreezeWorldMatrix(): this;
  82080. /**
  82081. * True if the World matrix has been frozen.
  82082. */
  82083. readonly isWorldMatrixFrozen: boolean;
  82084. /**
  82085. * Retuns the mesh absolute position in the World.
  82086. * @returns a Vector3.
  82087. */
  82088. getAbsolutePosition(): Vector3;
  82089. /**
  82090. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82091. * @param absolutePosition the absolute position to set
  82092. * @returns the TransformNode.
  82093. */
  82094. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82095. /**
  82096. * Sets the mesh position in its local space.
  82097. * @param vector3 the position to set in localspace
  82098. * @returns the TransformNode.
  82099. */
  82100. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82101. /**
  82102. * Returns the mesh position in the local space from the current World matrix values.
  82103. * @returns a new Vector3.
  82104. */
  82105. getPositionExpressedInLocalSpace(): Vector3;
  82106. /**
  82107. * Translates the mesh along the passed Vector3 in its local space.
  82108. * @param vector3 the distance to translate in localspace
  82109. * @returns the TransformNode.
  82110. */
  82111. locallyTranslate(vector3: Vector3): TransformNode;
  82112. private static _lookAtVectorCache;
  82113. /**
  82114. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82115. * @param targetPoint the position (must be in same space as current mesh) to look at
  82116. * @param yawCor optional yaw (y-axis) correction in radians
  82117. * @param pitchCor optional pitch (x-axis) correction in radians
  82118. * @param rollCor optional roll (z-axis) correction in radians
  82119. * @param space the choosen space of the target
  82120. * @returns the TransformNode.
  82121. */
  82122. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82123. /**
  82124. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82125. * This Vector3 is expressed in the World space.
  82126. * @param localAxis axis to rotate
  82127. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82128. */
  82129. getDirection(localAxis: Vector3): Vector3;
  82130. /**
  82131. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82132. * localAxis is expressed in the mesh local space.
  82133. * result is computed in the Wordl space from the mesh World matrix.
  82134. * @param localAxis axis to rotate
  82135. * @param result the resulting transformnode
  82136. * @returns this TransformNode.
  82137. */
  82138. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82139. /**
  82140. * Sets this transform node rotation to the given local axis.
  82141. * @param localAxis the axis in local space
  82142. * @param yawCor optional yaw (y-axis) correction in radians
  82143. * @param pitchCor optional pitch (x-axis) correction in radians
  82144. * @param rollCor optional roll (z-axis) correction in radians
  82145. * @returns this TransformNode
  82146. */
  82147. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82148. /**
  82149. * Sets a new pivot point to the current node
  82150. * @param point defines the new pivot point to use
  82151. * @param space defines if the point is in world or local space (local by default)
  82152. * @returns the current TransformNode
  82153. */
  82154. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82155. /**
  82156. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82157. * @returns the pivot point
  82158. */
  82159. getPivotPoint(): Vector3;
  82160. /**
  82161. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82162. * @param result the vector3 to store the result
  82163. * @returns this TransformNode.
  82164. */
  82165. getPivotPointToRef(result: Vector3): TransformNode;
  82166. /**
  82167. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82168. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82169. */
  82170. getAbsolutePivotPoint(): Vector3;
  82171. /**
  82172. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82173. * @param result vector3 to store the result
  82174. * @returns this TransformNode.
  82175. */
  82176. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82177. /**
  82178. * Defines the passed node as the parent of the current node.
  82179. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82180. * @see https://doc.babylonjs.com/how_to/parenting
  82181. * @param node the node ot set as the parent
  82182. * @returns this TransformNode.
  82183. */
  82184. setParent(node: Nullable<Node>): TransformNode;
  82185. private _nonUniformScaling;
  82186. /**
  82187. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82188. */
  82189. readonly nonUniformScaling: boolean;
  82190. /** @hidden */
  82191. _updateNonUniformScalingState(value: boolean): boolean;
  82192. /**
  82193. * Attach the current TransformNode to another TransformNode associated with a bone
  82194. * @param bone Bone affecting the TransformNode
  82195. * @param affectedTransformNode TransformNode associated with the bone
  82196. * @returns this object
  82197. */
  82198. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82199. /**
  82200. * Detach the transform node if its associated with a bone
  82201. * @returns this object
  82202. */
  82203. detachFromBone(): TransformNode;
  82204. private static _rotationAxisCache;
  82205. /**
  82206. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82207. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82208. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82209. * The passed axis is also normalized.
  82210. * @param axis the axis to rotate around
  82211. * @param amount the amount to rotate in radians
  82212. * @param space Space to rotate in (Default: local)
  82213. * @returns the TransformNode.
  82214. */
  82215. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82216. /**
  82217. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82218. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82219. * The passed axis is also normalized. .
  82220. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82221. * @param point the point to rotate around
  82222. * @param axis the axis to rotate around
  82223. * @param amount the amount to rotate in radians
  82224. * @returns the TransformNode
  82225. */
  82226. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82227. /**
  82228. * Translates the mesh along the axis vector for the passed distance in the given space.
  82229. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82230. * @param axis the axis to translate in
  82231. * @param distance the distance to translate
  82232. * @param space Space to rotate in (Default: local)
  82233. * @returns the TransformNode.
  82234. */
  82235. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82236. /**
  82237. * Adds a rotation step to the mesh current rotation.
  82238. * x, y, z are Euler angles expressed in radians.
  82239. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82240. * This means this rotation is made in the mesh local space only.
  82241. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82242. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82243. * ```javascript
  82244. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82245. * ```
  82246. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82247. * 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.
  82248. * @param x Rotation to add
  82249. * @param y Rotation to add
  82250. * @param z Rotation to add
  82251. * @returns the TransformNode.
  82252. */
  82253. addRotation(x: number, y: number, z: number): TransformNode;
  82254. /**
  82255. * @hidden
  82256. */
  82257. protected _getEffectiveParent(): Nullable<Node>;
  82258. /**
  82259. * Computes the world matrix of the node
  82260. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82261. * @returns the world matrix
  82262. */
  82263. computeWorldMatrix(force?: boolean): Matrix;
  82264. protected _afterComputeWorldMatrix(): void;
  82265. /**
  82266. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82267. * @param func callback function to add
  82268. *
  82269. * @returns the TransformNode.
  82270. */
  82271. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82272. /**
  82273. * Removes a registered callback function.
  82274. * @param func callback function to remove
  82275. * @returns the TransformNode.
  82276. */
  82277. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82278. /**
  82279. * Gets the position of the current mesh in camera space
  82280. * @param camera defines the camera to use
  82281. * @returns a position
  82282. */
  82283. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82284. /**
  82285. * Returns the distance from the mesh to the active camera
  82286. * @param camera defines the camera to use
  82287. * @returns the distance
  82288. */
  82289. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82290. /**
  82291. * Clone the current transform node
  82292. * @param name Name of the new clone
  82293. * @param newParent New parent for the clone
  82294. * @param doNotCloneChildren Do not clone children hierarchy
  82295. * @returns the new transform node
  82296. */
  82297. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82298. /**
  82299. * Serializes the objects information.
  82300. * @param currentSerializationObject defines the object to serialize in
  82301. * @returns the serialized object
  82302. */
  82303. serialize(currentSerializationObject?: any): any;
  82304. /**
  82305. * Returns a new TransformNode object parsed from the source provided.
  82306. * @param parsedTransformNode is the source.
  82307. * @param scene the scne the object belongs to
  82308. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82309. * @returns a new TransformNode object parsed from the source provided.
  82310. */
  82311. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82312. /**
  82313. * Get all child-transformNodes of this node
  82314. * @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
  82315. * @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
  82316. * @returns an array of TransformNode
  82317. */
  82318. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82319. /**
  82320. * Releases resources associated with this transform node.
  82321. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82322. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82323. */
  82324. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82325. /**
  82326. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82327. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82328. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82329. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82330. * @returns the current mesh
  82331. */
  82332. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82333. private _syncAbsoluteScalingAndRotation;
  82334. }
  82335. }
  82336. declare module BABYLON {
  82337. /**
  82338. * Defines the types of pose enabled controllers that are supported
  82339. */
  82340. export enum PoseEnabledControllerType {
  82341. /**
  82342. * HTC Vive
  82343. */
  82344. VIVE = 0,
  82345. /**
  82346. * Oculus Rift
  82347. */
  82348. OCULUS = 1,
  82349. /**
  82350. * Windows mixed reality
  82351. */
  82352. WINDOWS = 2,
  82353. /**
  82354. * Samsung gear VR
  82355. */
  82356. GEAR_VR = 3,
  82357. /**
  82358. * Google Daydream
  82359. */
  82360. DAYDREAM = 4,
  82361. /**
  82362. * Generic
  82363. */
  82364. GENERIC = 5
  82365. }
  82366. /**
  82367. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82368. */
  82369. export interface MutableGamepadButton {
  82370. /**
  82371. * Value of the button/trigger
  82372. */
  82373. value: number;
  82374. /**
  82375. * If the button/trigger is currently touched
  82376. */
  82377. touched: boolean;
  82378. /**
  82379. * If the button/trigger is currently pressed
  82380. */
  82381. pressed: boolean;
  82382. }
  82383. /**
  82384. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82385. * @hidden
  82386. */
  82387. export interface ExtendedGamepadButton extends GamepadButton {
  82388. /**
  82389. * If the button/trigger is currently pressed
  82390. */
  82391. readonly pressed: boolean;
  82392. /**
  82393. * If the button/trigger is currently touched
  82394. */
  82395. readonly touched: boolean;
  82396. /**
  82397. * Value of the button/trigger
  82398. */
  82399. readonly value: number;
  82400. }
  82401. /** @hidden */
  82402. export interface _GamePadFactory {
  82403. /**
  82404. * Returns wether or not the current gamepad can be created for this type of controller.
  82405. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82406. * @returns true if it can be created, otherwise false
  82407. */
  82408. canCreate(gamepadInfo: any): boolean;
  82409. /**
  82410. * Creates a new instance of the Gamepad.
  82411. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82412. * @returns the new gamepad instance
  82413. */
  82414. create(gamepadInfo: any): Gamepad;
  82415. }
  82416. /**
  82417. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82418. */
  82419. export class PoseEnabledControllerHelper {
  82420. /** @hidden */
  82421. static _ControllerFactories: _GamePadFactory[];
  82422. /** @hidden */
  82423. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82424. /**
  82425. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82426. * @param vrGamepad the gamepad to initialized
  82427. * @returns a vr controller of the type the gamepad identified as
  82428. */
  82429. static InitiateController(vrGamepad: any): Gamepad;
  82430. }
  82431. /**
  82432. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82433. */
  82434. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82435. /**
  82436. * If the controller is used in a webXR session
  82437. */
  82438. isXR: boolean;
  82439. private _deviceRoomPosition;
  82440. private _deviceRoomRotationQuaternion;
  82441. /**
  82442. * The device position in babylon space
  82443. */
  82444. devicePosition: Vector3;
  82445. /**
  82446. * The device rotation in babylon space
  82447. */
  82448. deviceRotationQuaternion: Quaternion;
  82449. /**
  82450. * The scale factor of the device in babylon space
  82451. */
  82452. deviceScaleFactor: number;
  82453. /**
  82454. * (Likely devicePosition should be used instead) The device position in its room space
  82455. */
  82456. position: Vector3;
  82457. /**
  82458. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82459. */
  82460. rotationQuaternion: Quaternion;
  82461. /**
  82462. * The type of controller (Eg. Windows mixed reality)
  82463. */
  82464. controllerType: PoseEnabledControllerType;
  82465. protected _calculatedPosition: Vector3;
  82466. private _calculatedRotation;
  82467. /**
  82468. * The raw pose from the device
  82469. */
  82470. rawPose: DevicePose;
  82471. private _trackPosition;
  82472. private _maxRotationDistFromHeadset;
  82473. private _draggedRoomRotation;
  82474. /**
  82475. * @hidden
  82476. */
  82477. _disableTrackPosition(fixedPosition: Vector3): void;
  82478. /**
  82479. * Internal, the mesh attached to the controller
  82480. * @hidden
  82481. */
  82482. _mesh: Nullable<AbstractMesh>;
  82483. private _poseControlledCamera;
  82484. private _leftHandSystemQuaternion;
  82485. /**
  82486. * Internal, matrix used to convert room space to babylon space
  82487. * @hidden
  82488. */
  82489. _deviceToWorld: Matrix;
  82490. /**
  82491. * Node to be used when casting a ray from the controller
  82492. * @hidden
  82493. */
  82494. _pointingPoseNode: Nullable<TransformNode>;
  82495. /**
  82496. * Name of the child mesh that can be used to cast a ray from the controller
  82497. */
  82498. static readonly POINTING_POSE: string;
  82499. /**
  82500. * Creates a new PoseEnabledController from a gamepad
  82501. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82502. */
  82503. constructor(browserGamepad: any);
  82504. private _workingMatrix;
  82505. /**
  82506. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82507. */
  82508. update(): void;
  82509. /**
  82510. * Updates only the pose device and mesh without doing any button event checking
  82511. */
  82512. protected _updatePoseAndMesh(): void;
  82513. /**
  82514. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82515. * @param poseData raw pose fromthe device
  82516. */
  82517. updateFromDevice(poseData: DevicePose): void;
  82518. /**
  82519. * @hidden
  82520. */
  82521. _meshAttachedObservable: Observable<AbstractMesh>;
  82522. /**
  82523. * Attaches a mesh to the controller
  82524. * @param mesh the mesh to be attached
  82525. */
  82526. attachToMesh(mesh: AbstractMesh): void;
  82527. /**
  82528. * Attaches the controllers mesh to a camera
  82529. * @param camera the camera the mesh should be attached to
  82530. */
  82531. attachToPoseControlledCamera(camera: TargetCamera): void;
  82532. /**
  82533. * Disposes of the controller
  82534. */
  82535. dispose(): void;
  82536. /**
  82537. * The mesh that is attached to the controller
  82538. */
  82539. readonly mesh: Nullable<AbstractMesh>;
  82540. /**
  82541. * Gets the ray of the controller in the direction the controller is pointing
  82542. * @param length the length the resulting ray should be
  82543. * @returns a ray in the direction the controller is pointing
  82544. */
  82545. getForwardRay(length?: number): Ray;
  82546. }
  82547. }
  82548. declare module BABYLON {
  82549. /**
  82550. * Defines the WebVRController object that represents controllers tracked in 3D space
  82551. */
  82552. export abstract class WebVRController extends PoseEnabledController {
  82553. /**
  82554. * Internal, the default controller model for the controller
  82555. */
  82556. protected _defaultModel: Nullable<AbstractMesh>;
  82557. /**
  82558. * Fired when the trigger state has changed
  82559. */
  82560. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82561. /**
  82562. * Fired when the main button state has changed
  82563. */
  82564. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82565. /**
  82566. * Fired when the secondary button state has changed
  82567. */
  82568. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82569. /**
  82570. * Fired when the pad state has changed
  82571. */
  82572. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82573. /**
  82574. * Fired when controllers stick values have changed
  82575. */
  82576. onPadValuesChangedObservable: Observable<StickValues>;
  82577. /**
  82578. * Array of button availible on the controller
  82579. */
  82580. protected _buttons: Array<MutableGamepadButton>;
  82581. private _onButtonStateChange;
  82582. /**
  82583. * Fired when a controller button's state has changed
  82584. * @param callback the callback containing the button that was modified
  82585. */
  82586. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82587. /**
  82588. * X and Y axis corresponding to the controllers joystick
  82589. */
  82590. pad: StickValues;
  82591. /**
  82592. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82593. */
  82594. hand: string;
  82595. /**
  82596. * The default controller model for the controller
  82597. */
  82598. readonly defaultModel: Nullable<AbstractMesh>;
  82599. /**
  82600. * Creates a new WebVRController from a gamepad
  82601. * @param vrGamepad the gamepad that the WebVRController should be created from
  82602. */
  82603. constructor(vrGamepad: any);
  82604. /**
  82605. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82606. */
  82607. update(): void;
  82608. /**
  82609. * Function to be called when a button is modified
  82610. */
  82611. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82612. /**
  82613. * Loads a mesh and attaches it to the controller
  82614. * @param scene the scene the mesh should be added to
  82615. * @param meshLoaded callback for when the mesh has been loaded
  82616. */
  82617. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82618. private _setButtonValue;
  82619. private _changes;
  82620. private _checkChanges;
  82621. /**
  82622. * Disposes of th webVRCOntroller
  82623. */
  82624. dispose(): void;
  82625. }
  82626. }
  82627. declare module BABYLON {
  82628. /**
  82629. * The HemisphericLight simulates the ambient environment light,
  82630. * so the passed direction is the light reflection direction, not the incoming direction.
  82631. */
  82632. export class HemisphericLight extends Light {
  82633. /**
  82634. * The groundColor is the light in the opposite direction to the one specified during creation.
  82635. * 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.
  82636. */
  82637. groundColor: Color3;
  82638. /**
  82639. * The light reflection direction, not the incoming direction.
  82640. */
  82641. direction: Vector3;
  82642. /**
  82643. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82644. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82645. * The HemisphericLight can't cast shadows.
  82646. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82647. * @param name The friendly name of the light
  82648. * @param direction The direction of the light reflection
  82649. * @param scene The scene the light belongs to
  82650. */
  82651. constructor(name: string, direction: Vector3, scene: Scene);
  82652. protected _buildUniformLayout(): void;
  82653. /**
  82654. * Returns the string "HemisphericLight".
  82655. * @return The class name
  82656. */
  82657. getClassName(): string;
  82658. /**
  82659. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82660. * Returns the updated direction.
  82661. * @param target The target the direction should point to
  82662. * @return The computed direction
  82663. */
  82664. setDirectionToTarget(target: Vector3): Vector3;
  82665. /**
  82666. * Returns the shadow generator associated to the light.
  82667. * @returns Always null for hemispheric lights because it does not support shadows.
  82668. */
  82669. getShadowGenerator(): Nullable<IShadowGenerator>;
  82670. /**
  82671. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82672. * @param effect The effect to update
  82673. * @param lightIndex The index of the light in the effect to update
  82674. * @returns The hemispheric light
  82675. */
  82676. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82677. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82678. /**
  82679. * Computes the world matrix of the node
  82680. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82681. * @param useWasUpdatedFlag defines a reserved property
  82682. * @returns the world matrix
  82683. */
  82684. computeWorldMatrix(): Matrix;
  82685. /**
  82686. * Returns the integer 3.
  82687. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82688. */
  82689. getTypeID(): number;
  82690. /**
  82691. * Prepares the list of defines specific to the light type.
  82692. * @param defines the list of defines
  82693. * @param lightIndex defines the index of the light for the effect
  82694. */
  82695. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82696. }
  82697. }
  82698. declare module BABYLON {
  82699. /** @hidden */
  82700. export var vrMultiviewToSingleviewPixelShader: {
  82701. name: string;
  82702. shader: string;
  82703. };
  82704. }
  82705. declare module BABYLON {
  82706. /**
  82707. * Renders to multiple views with a single draw call
  82708. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82709. */
  82710. export class MultiviewRenderTarget extends RenderTargetTexture {
  82711. /**
  82712. * Creates a multiview render target
  82713. * @param scene scene used with the render target
  82714. * @param size the size of the render target (used for each view)
  82715. */
  82716. constructor(scene: Scene, size?: number | {
  82717. width: number;
  82718. height: number;
  82719. } | {
  82720. ratio: number;
  82721. });
  82722. /**
  82723. * @hidden
  82724. * @param faceIndex the face index, if its a cube texture
  82725. */
  82726. _bindFrameBuffer(faceIndex?: number): void;
  82727. /**
  82728. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82729. * @returns the view count
  82730. */
  82731. getViewCount(): number;
  82732. }
  82733. }
  82734. declare module BABYLON {
  82735. /**
  82736. * Represents a camera frustum
  82737. */
  82738. export class Frustum {
  82739. /**
  82740. * Gets the planes representing the frustum
  82741. * @param transform matrix to be applied to the returned planes
  82742. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82743. */
  82744. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82745. /**
  82746. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82751. /**
  82752. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82757. /**
  82758. * Gets the left frustum plane transformed by the transform matrix
  82759. * @param transform transformation matrix to be applied to the resulting frustum plane
  82760. * @param frustumPlane the resuling frustum plane
  82761. */
  82762. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82763. /**
  82764. * Gets the right frustum plane transformed by the transform matrix
  82765. * @param transform transformation matrix to be applied to the resulting frustum plane
  82766. * @param frustumPlane the resuling frustum plane
  82767. */
  82768. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82769. /**
  82770. * Gets the top frustum plane transformed by the transform matrix
  82771. * @param transform transformation matrix to be applied to the resulting frustum plane
  82772. * @param frustumPlane the resuling frustum plane
  82773. */
  82774. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82775. /**
  82776. * Gets the bottom frustum plane transformed by the transform matrix
  82777. * @param transform transformation matrix to be applied to the resulting frustum plane
  82778. * @param frustumPlane the resuling frustum plane
  82779. */
  82780. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82781. /**
  82782. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82783. * @param transform transformation matrix to be applied to the resulting frustum planes
  82784. * @param frustumPlanes the resuling frustum planes
  82785. */
  82786. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82787. }
  82788. }
  82789. declare module BABYLON {
  82790. interface Engine {
  82791. /**
  82792. * Creates a new multiview render target
  82793. * @param width defines the width of the texture
  82794. * @param height defines the height of the texture
  82795. * @returns the created multiview texture
  82796. */
  82797. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82798. /**
  82799. * Binds a multiview framebuffer to be drawn to
  82800. * @param multiviewTexture texture to bind
  82801. */
  82802. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82803. }
  82804. interface Camera {
  82805. /**
  82806. * @hidden
  82807. * 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)
  82808. */
  82809. _useMultiviewToSingleView: boolean;
  82810. /**
  82811. * @hidden
  82812. * 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)
  82813. */
  82814. _multiviewTexture: Nullable<RenderTargetTexture>;
  82815. /**
  82816. * @hidden
  82817. * ensures the multiview texture of the camera exists and has the specified width/height
  82818. * @param width height to set on the multiview texture
  82819. * @param height width to set on the multiview texture
  82820. */
  82821. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82822. }
  82823. interface Scene {
  82824. /** @hidden */
  82825. _transformMatrixR: Matrix;
  82826. /** @hidden */
  82827. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82828. /** @hidden */
  82829. _createMultiviewUbo(): void;
  82830. /** @hidden */
  82831. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82832. /** @hidden */
  82833. _renderMultiviewToSingleView(camera: Camera): void;
  82834. }
  82835. }
  82836. declare module BABYLON {
  82837. /**
  82838. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82839. * This will not be used for webXR as it supports displaying texture arrays directly
  82840. */
  82841. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82842. /**
  82843. * Initializes a VRMultiviewToSingleview
  82844. * @param name name of the post process
  82845. * @param camera camera to be applied to
  82846. * @param scaleFactor scaling factor to the size of the output texture
  82847. */
  82848. constructor(name: string, camera: Camera, scaleFactor: number);
  82849. }
  82850. }
  82851. declare module BABYLON {
  82852. /**
  82853. * Interface used to define additional presentation attributes
  82854. */
  82855. export interface IVRPresentationAttributes {
  82856. /**
  82857. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  82858. */
  82859. highRefreshRate: boolean;
  82860. /**
  82861. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  82862. */
  82863. foveationLevel: number;
  82864. }
  82865. interface Engine {
  82866. /** @hidden */
  82867. _vrDisplay: any;
  82868. /** @hidden */
  82869. _vrSupported: boolean;
  82870. /** @hidden */
  82871. _oldSize: Size;
  82872. /** @hidden */
  82873. _oldHardwareScaleFactor: number;
  82874. /** @hidden */
  82875. _vrExclusivePointerMode: boolean;
  82876. /** @hidden */
  82877. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82878. /** @hidden */
  82879. _onVRDisplayPointerRestricted: () => void;
  82880. /** @hidden */
  82881. _onVRDisplayPointerUnrestricted: () => void;
  82882. /** @hidden */
  82883. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82884. /** @hidden */
  82885. _onVrDisplayDisconnect: Nullable<() => void>;
  82886. /** @hidden */
  82887. _onVrDisplayPresentChange: Nullable<() => void>;
  82888. /**
  82889. * Observable signaled when VR display mode changes
  82890. */
  82891. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82892. /**
  82893. * Observable signaled when VR request present is complete
  82894. */
  82895. onVRRequestPresentComplete: Observable<boolean>;
  82896. /**
  82897. * Observable signaled when VR request present starts
  82898. */
  82899. onVRRequestPresentStart: Observable<Engine>;
  82900. /**
  82901. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82902. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82903. */
  82904. isInVRExclusivePointerMode: boolean;
  82905. /**
  82906. * Gets a boolean indicating if a webVR device was detected
  82907. * @returns true if a webVR device was detected
  82908. */
  82909. isVRDevicePresent(): boolean;
  82910. /**
  82911. * Gets the current webVR device
  82912. * @returns the current webVR device (or null)
  82913. */
  82914. getVRDevice(): any;
  82915. /**
  82916. * Initializes a webVR display and starts listening to display change events
  82917. * The onVRDisplayChangedObservable will be notified upon these changes
  82918. * @returns A promise containing a VRDisplay and if vr is supported
  82919. */
  82920. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82921. /** @hidden */
  82922. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82923. /**
  82924. * Gets or sets the presentation attributes used to configure VR rendering
  82925. */
  82926. vrPresentationAttributes?: IVRPresentationAttributes;
  82927. /**
  82928. * Call this function to switch to webVR mode
  82929. * Will do nothing if webVR is not supported or if there is no webVR device
  82930. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82931. */
  82932. enableVR(): void;
  82933. /** @hidden */
  82934. _onVRFullScreenTriggered(): void;
  82935. }
  82936. }
  82937. declare module BABYLON {
  82938. /**
  82939. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82940. * IMPORTANT!! The data is right-hand data.
  82941. * @export
  82942. * @interface DevicePose
  82943. */
  82944. export interface DevicePose {
  82945. /**
  82946. * The position of the device, values in array are [x,y,z].
  82947. */
  82948. readonly position: Nullable<Float32Array>;
  82949. /**
  82950. * The linearVelocity of the device, values in array are [x,y,z].
  82951. */
  82952. readonly linearVelocity: Nullable<Float32Array>;
  82953. /**
  82954. * The linearAcceleration of the device, values in array are [x,y,z].
  82955. */
  82956. readonly linearAcceleration: Nullable<Float32Array>;
  82957. /**
  82958. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82959. */
  82960. readonly orientation: Nullable<Float32Array>;
  82961. /**
  82962. * The angularVelocity of the device, values in array are [x,y,z].
  82963. */
  82964. readonly angularVelocity: Nullable<Float32Array>;
  82965. /**
  82966. * The angularAcceleration of the device, values in array are [x,y,z].
  82967. */
  82968. readonly angularAcceleration: Nullable<Float32Array>;
  82969. }
  82970. /**
  82971. * Interface representing a pose controlled object in Babylon.
  82972. * A pose controlled object has both regular pose values as well as pose values
  82973. * from an external device such as a VR head mounted display
  82974. */
  82975. export interface PoseControlled {
  82976. /**
  82977. * The position of the object in babylon space.
  82978. */
  82979. position: Vector3;
  82980. /**
  82981. * The rotation quaternion of the object in babylon space.
  82982. */
  82983. rotationQuaternion: Quaternion;
  82984. /**
  82985. * The position of the device in babylon space.
  82986. */
  82987. devicePosition?: Vector3;
  82988. /**
  82989. * The rotation quaternion of the device in babylon space.
  82990. */
  82991. deviceRotationQuaternion: Quaternion;
  82992. /**
  82993. * The raw pose coming from the device.
  82994. */
  82995. rawPose: Nullable<DevicePose>;
  82996. /**
  82997. * The scale of the device to be used when translating from device space to babylon space.
  82998. */
  82999. deviceScaleFactor: number;
  83000. /**
  83001. * Updates the poseControlled values based on the input device pose.
  83002. * @param poseData the pose data to update the object with
  83003. */
  83004. updateFromDevice(poseData: DevicePose): void;
  83005. }
  83006. /**
  83007. * Set of options to customize the webVRCamera
  83008. */
  83009. export interface WebVROptions {
  83010. /**
  83011. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83012. */
  83013. trackPosition?: boolean;
  83014. /**
  83015. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83016. */
  83017. positionScale?: number;
  83018. /**
  83019. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83020. */
  83021. displayName?: string;
  83022. /**
  83023. * Should the native controller meshes be initialized. (default: true)
  83024. */
  83025. controllerMeshes?: boolean;
  83026. /**
  83027. * Creating a default HemiLight only on controllers. (default: true)
  83028. */
  83029. defaultLightingOnControllers?: boolean;
  83030. /**
  83031. * If you don't want to use the default VR button of the helper. (default: false)
  83032. */
  83033. useCustomVRButton?: boolean;
  83034. /**
  83035. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83036. */
  83037. customVRButton?: HTMLButtonElement;
  83038. /**
  83039. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83040. */
  83041. rayLength?: number;
  83042. /**
  83043. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83044. */
  83045. defaultHeight?: number;
  83046. /**
  83047. * If multiview should be used if availible (default: false)
  83048. */
  83049. useMultiview?: boolean;
  83050. }
  83051. /**
  83052. * This represents a WebVR camera.
  83053. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83054. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83055. */
  83056. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83057. private webVROptions;
  83058. /**
  83059. * @hidden
  83060. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83061. */
  83062. _vrDevice: any;
  83063. /**
  83064. * The rawPose of the vrDevice.
  83065. */
  83066. rawPose: Nullable<DevicePose>;
  83067. private _onVREnabled;
  83068. private _specsVersion;
  83069. private _attached;
  83070. private _frameData;
  83071. protected _descendants: Array<Node>;
  83072. private _deviceRoomPosition;
  83073. /** @hidden */
  83074. _deviceRoomRotationQuaternion: Quaternion;
  83075. private _standingMatrix;
  83076. /**
  83077. * Represents device position in babylon space.
  83078. */
  83079. devicePosition: Vector3;
  83080. /**
  83081. * Represents device rotation in babylon space.
  83082. */
  83083. deviceRotationQuaternion: Quaternion;
  83084. /**
  83085. * The scale of the device to be used when translating from device space to babylon space.
  83086. */
  83087. deviceScaleFactor: number;
  83088. private _deviceToWorld;
  83089. private _worldToDevice;
  83090. /**
  83091. * References to the webVR controllers for the vrDevice.
  83092. */
  83093. controllers: Array<WebVRController>;
  83094. /**
  83095. * Emits an event when a controller is attached.
  83096. */
  83097. onControllersAttachedObservable: Observable<WebVRController[]>;
  83098. /**
  83099. * Emits an event when a controller's mesh has been loaded;
  83100. */
  83101. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83102. /**
  83103. * Emits an event when the HMD's pose has been updated.
  83104. */
  83105. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83106. private _poseSet;
  83107. /**
  83108. * If the rig cameras be used as parent instead of this camera.
  83109. */
  83110. rigParenting: boolean;
  83111. private _lightOnControllers;
  83112. private _defaultHeight?;
  83113. /**
  83114. * Instantiates a WebVRFreeCamera.
  83115. * @param name The name of the WebVRFreeCamera
  83116. * @param position The starting anchor position for the camera
  83117. * @param scene The scene the camera belongs to
  83118. * @param webVROptions a set of customizable options for the webVRCamera
  83119. */
  83120. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83121. /**
  83122. * Gets the device distance from the ground in meters.
  83123. * @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.
  83124. */
  83125. deviceDistanceToRoomGround(): number;
  83126. /**
  83127. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83128. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83129. */
  83130. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83131. /**
  83132. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83133. * @returns A promise with a boolean set to if the standing matrix is supported.
  83134. */
  83135. useStandingMatrixAsync(): Promise<boolean>;
  83136. /**
  83137. * Disposes the camera
  83138. */
  83139. dispose(): void;
  83140. /**
  83141. * Gets a vrController by name.
  83142. * @param name The name of the controller to retreive
  83143. * @returns the controller matching the name specified or null if not found
  83144. */
  83145. getControllerByName(name: string): Nullable<WebVRController>;
  83146. private _leftController;
  83147. /**
  83148. * The controller corresponding to the users left hand.
  83149. */
  83150. readonly leftController: Nullable<WebVRController>;
  83151. private _rightController;
  83152. /**
  83153. * The controller corresponding to the users right hand.
  83154. */
  83155. readonly rightController: Nullable<WebVRController>;
  83156. /**
  83157. * Casts a ray forward from the vrCamera's gaze.
  83158. * @param length Length of the ray (default: 100)
  83159. * @returns the ray corresponding to the gaze
  83160. */
  83161. getForwardRay(length?: number): Ray;
  83162. /**
  83163. * @hidden
  83164. * Updates the camera based on device's frame data
  83165. */
  83166. _checkInputs(): void;
  83167. /**
  83168. * Updates the poseControlled values based on the input device pose.
  83169. * @param poseData Pose coming from the device
  83170. */
  83171. updateFromDevice(poseData: DevicePose): void;
  83172. private _htmlElementAttached;
  83173. private _detachIfAttached;
  83174. /**
  83175. * WebVR's attach control will start broadcasting frames to the device.
  83176. * Note that in certain browsers (chrome for example) this function must be called
  83177. * within a user-interaction callback. Example:
  83178. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83179. *
  83180. * @param element html element to attach the vrDevice to
  83181. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83182. */
  83183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83184. /**
  83185. * Detaches the camera from the html element and disables VR
  83186. *
  83187. * @param element html element to detach from
  83188. */
  83189. detachControl(element: HTMLElement): void;
  83190. /**
  83191. * @returns the name of this class
  83192. */
  83193. getClassName(): string;
  83194. /**
  83195. * Calls resetPose on the vrDisplay
  83196. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83197. */
  83198. resetToCurrentRotation(): void;
  83199. /**
  83200. * @hidden
  83201. * Updates the rig cameras (left and right eye)
  83202. */
  83203. _updateRigCameras(): void;
  83204. private _workingVector;
  83205. private _oneVector;
  83206. private _workingMatrix;
  83207. private updateCacheCalled;
  83208. private _correctPositionIfNotTrackPosition;
  83209. /**
  83210. * @hidden
  83211. * Updates the cached values of the camera
  83212. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83213. */
  83214. _updateCache(ignoreParentClass?: boolean): void;
  83215. /**
  83216. * @hidden
  83217. * Get current device position in babylon world
  83218. */
  83219. _computeDevicePosition(): void;
  83220. /**
  83221. * Updates the current device position and rotation in the babylon world
  83222. */
  83223. update(): void;
  83224. /**
  83225. * @hidden
  83226. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83227. * @returns an identity matrix
  83228. */
  83229. _getViewMatrix(): Matrix;
  83230. private _tmpMatrix;
  83231. /**
  83232. * This function is called by the two RIG cameras.
  83233. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83234. * @hidden
  83235. */
  83236. _getWebVRViewMatrix(): Matrix;
  83237. /** @hidden */
  83238. _getWebVRProjectionMatrix(): Matrix;
  83239. private _onGamepadConnectedObserver;
  83240. private _onGamepadDisconnectedObserver;
  83241. private _updateCacheWhenTrackingDisabledObserver;
  83242. /**
  83243. * Initializes the controllers and their meshes
  83244. */
  83245. initControllers(): void;
  83246. }
  83247. }
  83248. declare module BABYLON {
  83249. /**
  83250. * Size options for a post process
  83251. */
  83252. export type PostProcessOptions = {
  83253. width: number;
  83254. height: number;
  83255. };
  83256. /**
  83257. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83258. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83259. */
  83260. export class PostProcess {
  83261. /** Name of the PostProcess. */
  83262. name: string;
  83263. /**
  83264. * Gets or sets the unique id of the post process
  83265. */
  83266. uniqueId: number;
  83267. /**
  83268. * Width of the texture to apply the post process on
  83269. */
  83270. width: number;
  83271. /**
  83272. * Height of the texture to apply the post process on
  83273. */
  83274. height: number;
  83275. /**
  83276. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83277. * @hidden
  83278. */
  83279. _outputTexture: Nullable<InternalTexture>;
  83280. /**
  83281. * Sampling mode used by the shader
  83282. * See https://doc.babylonjs.com/classes/3.1/texture
  83283. */
  83284. renderTargetSamplingMode: number;
  83285. /**
  83286. * Clear color to use when screen clearing
  83287. */
  83288. clearColor: Color4;
  83289. /**
  83290. * If the buffer needs to be cleared before applying the post process. (default: true)
  83291. * Should be set to false if shader will overwrite all previous pixels.
  83292. */
  83293. autoClear: boolean;
  83294. /**
  83295. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83296. */
  83297. alphaMode: number;
  83298. /**
  83299. * Sets the setAlphaBlendConstants of the babylon engine
  83300. */
  83301. alphaConstants: Color4;
  83302. /**
  83303. * Animations to be used for the post processing
  83304. */
  83305. animations: Animation[];
  83306. /**
  83307. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83308. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83309. */
  83310. enablePixelPerfectMode: boolean;
  83311. /**
  83312. * Force the postprocess to be applied without taking in account viewport
  83313. */
  83314. forceFullscreenViewport: boolean;
  83315. /**
  83316. * List of inspectable custom properties (used by the Inspector)
  83317. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83318. */
  83319. inspectableCustomProperties: IInspectable[];
  83320. /**
  83321. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83322. *
  83323. * | Value | Type | Description |
  83324. * | ----- | ----------------------------------- | ----------- |
  83325. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83326. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83327. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83328. *
  83329. */
  83330. scaleMode: number;
  83331. /**
  83332. * Force textures to be a power of two (default: false)
  83333. */
  83334. alwaysForcePOT: boolean;
  83335. private _samples;
  83336. /**
  83337. * Number of sample textures (default: 1)
  83338. */
  83339. samples: number;
  83340. /**
  83341. * Modify the scale of the post process to be the same as the viewport (default: false)
  83342. */
  83343. adaptScaleToCurrentViewport: boolean;
  83344. private _camera;
  83345. private _scene;
  83346. private _engine;
  83347. private _options;
  83348. private _reusable;
  83349. private _textureType;
  83350. /**
  83351. * Smart array of input and output textures for the post process.
  83352. * @hidden
  83353. */
  83354. _textures: SmartArray<InternalTexture>;
  83355. /**
  83356. * The index in _textures that corresponds to the output texture.
  83357. * @hidden
  83358. */
  83359. _currentRenderTextureInd: number;
  83360. private _effect;
  83361. private _samplers;
  83362. private _fragmentUrl;
  83363. private _vertexUrl;
  83364. private _parameters;
  83365. private _scaleRatio;
  83366. protected _indexParameters: any;
  83367. private _shareOutputWithPostProcess;
  83368. private _texelSize;
  83369. private _forcedOutputTexture;
  83370. /**
  83371. * Returns the fragment url or shader name used in the post process.
  83372. * @returns the fragment url or name in the shader store.
  83373. */
  83374. getEffectName(): string;
  83375. /**
  83376. * An event triggered when the postprocess is activated.
  83377. */
  83378. onActivateObservable: Observable<Camera>;
  83379. private _onActivateObserver;
  83380. /**
  83381. * A function that is added to the onActivateObservable
  83382. */
  83383. onActivate: Nullable<(camera: Camera) => void>;
  83384. /**
  83385. * An event triggered when the postprocess changes its size.
  83386. */
  83387. onSizeChangedObservable: Observable<PostProcess>;
  83388. private _onSizeChangedObserver;
  83389. /**
  83390. * A function that is added to the onSizeChangedObservable
  83391. */
  83392. onSizeChanged: (postProcess: PostProcess) => void;
  83393. /**
  83394. * An event triggered when the postprocess applies its effect.
  83395. */
  83396. onApplyObservable: Observable<Effect>;
  83397. private _onApplyObserver;
  83398. /**
  83399. * A function that is added to the onApplyObservable
  83400. */
  83401. onApply: (effect: Effect) => void;
  83402. /**
  83403. * An event triggered before rendering the postprocess
  83404. */
  83405. onBeforeRenderObservable: Observable<Effect>;
  83406. private _onBeforeRenderObserver;
  83407. /**
  83408. * A function that is added to the onBeforeRenderObservable
  83409. */
  83410. onBeforeRender: (effect: Effect) => void;
  83411. /**
  83412. * An event triggered after rendering the postprocess
  83413. */
  83414. onAfterRenderObservable: Observable<Effect>;
  83415. private _onAfterRenderObserver;
  83416. /**
  83417. * A function that is added to the onAfterRenderObservable
  83418. */
  83419. onAfterRender: (efect: Effect) => void;
  83420. /**
  83421. * 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
  83422. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83423. */
  83424. inputTexture: InternalTexture;
  83425. /**
  83426. * Gets the camera which post process is applied to.
  83427. * @returns The camera the post process is applied to.
  83428. */
  83429. getCamera(): Camera;
  83430. /**
  83431. * Gets the texel size of the postprocess.
  83432. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83433. */
  83434. readonly texelSize: Vector2;
  83435. /**
  83436. * Creates a new instance PostProcess
  83437. * @param name The name of the PostProcess.
  83438. * @param fragmentUrl The url of the fragment shader to be used.
  83439. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83440. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83441. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83442. * @param camera The camera to apply the render pass to.
  83443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83444. * @param engine The engine which the post process will be applied. (default: current engine)
  83445. * @param reusable If the post process can be reused on the same frame. (default: false)
  83446. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83447. * @param textureType Type of textures used when performing the post process. (default: 0)
  83448. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83449. * @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
  83450. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83451. */
  83452. constructor(
  83453. /** Name of the PostProcess. */
  83454. 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);
  83455. /**
  83456. * Gets a string idenfifying the name of the class
  83457. * @returns "PostProcess" string
  83458. */
  83459. getClassName(): string;
  83460. /**
  83461. * Gets the engine which this post process belongs to.
  83462. * @returns The engine the post process was enabled with.
  83463. */
  83464. getEngine(): Engine;
  83465. /**
  83466. * The effect that is created when initializing the post process.
  83467. * @returns The created effect corresponding the the postprocess.
  83468. */
  83469. getEffect(): Effect;
  83470. /**
  83471. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83472. * @param postProcess The post process to share the output with.
  83473. * @returns This post process.
  83474. */
  83475. shareOutputWith(postProcess: PostProcess): PostProcess;
  83476. /**
  83477. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83478. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83479. */
  83480. useOwnOutput(): void;
  83481. /**
  83482. * Updates the effect with the current post process compile time values and recompiles the shader.
  83483. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83484. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83485. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83486. * @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
  83487. * @param onCompiled Called when the shader has been compiled.
  83488. * @param onError Called if there is an error when compiling a shader.
  83489. */
  83490. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83491. /**
  83492. * The post process is reusable if it can be used multiple times within one frame.
  83493. * @returns If the post process is reusable
  83494. */
  83495. isReusable(): boolean;
  83496. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83497. markTextureDirty(): void;
  83498. /**
  83499. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83500. * 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.
  83501. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83502. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83503. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83504. * @returns The target texture that was bound to be written to.
  83505. */
  83506. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83507. /**
  83508. * If the post process is supported.
  83509. */
  83510. readonly isSupported: boolean;
  83511. /**
  83512. * The aspect ratio of the output texture.
  83513. */
  83514. readonly aspectRatio: number;
  83515. /**
  83516. * Get a value indicating if the post-process is ready to be used
  83517. * @returns true if the post-process is ready (shader is compiled)
  83518. */
  83519. isReady(): boolean;
  83520. /**
  83521. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83522. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83523. */
  83524. apply(): Nullable<Effect>;
  83525. private _disposeTextures;
  83526. /**
  83527. * Disposes the post process.
  83528. * @param camera The camera to dispose the post process on.
  83529. */
  83530. dispose(camera?: Camera): void;
  83531. }
  83532. }
  83533. declare module BABYLON {
  83534. /** @hidden */
  83535. export var kernelBlurVaryingDeclaration: {
  83536. name: string;
  83537. shader: string;
  83538. };
  83539. }
  83540. declare module BABYLON {
  83541. /** @hidden */
  83542. export var kernelBlurFragment: {
  83543. name: string;
  83544. shader: string;
  83545. };
  83546. }
  83547. declare module BABYLON {
  83548. /** @hidden */
  83549. export var kernelBlurFragment2: {
  83550. name: string;
  83551. shader: string;
  83552. };
  83553. }
  83554. declare module BABYLON {
  83555. /** @hidden */
  83556. export var kernelBlurPixelShader: {
  83557. name: string;
  83558. shader: string;
  83559. };
  83560. }
  83561. declare module BABYLON {
  83562. /** @hidden */
  83563. export var kernelBlurVertex: {
  83564. name: string;
  83565. shader: string;
  83566. };
  83567. }
  83568. declare module BABYLON {
  83569. /** @hidden */
  83570. export var kernelBlurVertexShader: {
  83571. name: string;
  83572. shader: string;
  83573. };
  83574. }
  83575. declare module BABYLON {
  83576. /**
  83577. * The Blur Post Process which blurs an image based on a kernel and direction.
  83578. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83579. */
  83580. export class BlurPostProcess extends PostProcess {
  83581. /** The direction in which to blur the image. */
  83582. direction: Vector2;
  83583. private blockCompilation;
  83584. protected _kernel: number;
  83585. protected _idealKernel: number;
  83586. protected _packedFloat: boolean;
  83587. private _staticDefines;
  83588. /**
  83589. * Sets the length in pixels of the blur sample region
  83590. */
  83591. /**
  83592. * Gets the length in pixels of the blur sample region
  83593. */
  83594. kernel: number;
  83595. /**
  83596. * Sets wether or not the blur needs to unpack/repack floats
  83597. */
  83598. /**
  83599. * Gets wether or not the blur is unpacking/repacking floats
  83600. */
  83601. packedFloat: boolean;
  83602. /**
  83603. * Creates a new instance BlurPostProcess
  83604. * @param name The name of the effect.
  83605. * @param direction The direction in which to blur the image.
  83606. * @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.
  83607. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83608. * @param camera The camera to apply the render pass to.
  83609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83610. * @param engine The engine which the post process will be applied. (default: current engine)
  83611. * @param reusable If the post process can be reused on the same frame. (default: false)
  83612. * @param textureType Type of textures used when performing the post process. (default: 0)
  83613. * @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)
  83614. */
  83615. constructor(name: string,
  83616. /** The direction in which to blur the image. */
  83617. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83618. /**
  83619. * Updates the effect with the current post process compile time values and recompiles the shader.
  83620. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83621. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83622. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83623. * @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
  83624. * @param onCompiled Called when the shader has been compiled.
  83625. * @param onError Called if there is an error when compiling a shader.
  83626. */
  83627. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83628. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83629. /**
  83630. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83631. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83632. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83633. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83634. * The gaps between physical kernels are compensated for in the weighting of the samples
  83635. * @param idealKernel Ideal blur kernel.
  83636. * @return Nearest best kernel.
  83637. */
  83638. protected _nearestBestKernel(idealKernel: number): number;
  83639. /**
  83640. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83641. * @param x The point on the Gaussian distribution to sample.
  83642. * @return the value of the Gaussian function at x.
  83643. */
  83644. protected _gaussianWeight(x: number): number;
  83645. /**
  83646. * Generates a string that can be used as a floating point number in GLSL.
  83647. * @param x Value to print.
  83648. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83649. * @return GLSL float string.
  83650. */
  83651. protected _glslFloat(x: number, decimalFigures?: number): string;
  83652. }
  83653. }
  83654. declare module BABYLON {
  83655. /**
  83656. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83657. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83658. * You can then easily use it as a reflectionTexture on a flat surface.
  83659. * In case the surface is not a plane, please consider relying on reflection probes.
  83660. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83661. */
  83662. export class MirrorTexture extends RenderTargetTexture {
  83663. private scene;
  83664. /**
  83665. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83666. * 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.
  83667. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83668. */
  83669. mirrorPlane: Plane;
  83670. /**
  83671. * Define the blur ratio used to blur the reflection if needed.
  83672. */
  83673. blurRatio: number;
  83674. /**
  83675. * Define the adaptive blur kernel used to blur the reflection if needed.
  83676. * This will autocompute the closest best match for the `blurKernel`
  83677. */
  83678. adaptiveBlurKernel: number;
  83679. /**
  83680. * Define the blur kernel used to blur the reflection if needed.
  83681. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83682. */
  83683. blurKernel: number;
  83684. /**
  83685. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83686. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83687. */
  83688. blurKernelX: number;
  83689. /**
  83690. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83691. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83692. */
  83693. blurKernelY: number;
  83694. private _autoComputeBlurKernel;
  83695. protected _onRatioRescale(): void;
  83696. private _updateGammaSpace;
  83697. private _imageProcessingConfigChangeObserver;
  83698. private _transformMatrix;
  83699. private _mirrorMatrix;
  83700. private _savedViewMatrix;
  83701. private _blurX;
  83702. private _blurY;
  83703. private _adaptiveBlurKernel;
  83704. private _blurKernelX;
  83705. private _blurKernelY;
  83706. private _blurRatio;
  83707. /**
  83708. * Instantiates a Mirror Texture.
  83709. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83710. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83711. * You can then easily use it as a reflectionTexture on a flat surface.
  83712. * In case the surface is not a plane, please consider relying on reflection probes.
  83713. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83714. * @param name
  83715. * @param size
  83716. * @param scene
  83717. * @param generateMipMaps
  83718. * @param type
  83719. * @param samplingMode
  83720. * @param generateDepthBuffer
  83721. */
  83722. constructor(name: string, size: number | {
  83723. width: number;
  83724. height: number;
  83725. } | {
  83726. ratio: number;
  83727. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83728. private _preparePostProcesses;
  83729. /**
  83730. * Clone the mirror texture.
  83731. * @returns the cloned texture
  83732. */
  83733. clone(): MirrorTexture;
  83734. /**
  83735. * Serialize the texture to a JSON representation you could use in Parse later on
  83736. * @returns the serialized JSON representation
  83737. */
  83738. serialize(): any;
  83739. /**
  83740. * Dispose the texture and release its associated resources.
  83741. */
  83742. dispose(): void;
  83743. }
  83744. }
  83745. declare module BABYLON {
  83746. /**
  83747. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83748. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83749. */
  83750. export class Texture extends BaseTexture {
  83751. /**
  83752. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83753. */
  83754. static SerializeBuffers: boolean;
  83755. /** @hidden */
  83756. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83757. /** @hidden */
  83758. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83759. /** @hidden */
  83760. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83761. /** nearest is mag = nearest and min = nearest and mip = linear */
  83762. static readonly NEAREST_SAMPLINGMODE: number;
  83763. /** nearest is mag = nearest and min = nearest and mip = linear */
  83764. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83765. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83766. static readonly BILINEAR_SAMPLINGMODE: number;
  83767. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83768. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83769. /** Trilinear is mag = linear and min = linear and mip = linear */
  83770. static readonly TRILINEAR_SAMPLINGMODE: number;
  83771. /** Trilinear is mag = linear and min = linear and mip = linear */
  83772. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83773. /** mag = nearest and min = nearest and mip = nearest */
  83774. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83775. /** mag = nearest and min = linear and mip = nearest */
  83776. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83777. /** mag = nearest and min = linear and mip = linear */
  83778. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83779. /** mag = nearest and min = linear and mip = none */
  83780. static readonly NEAREST_LINEAR: number;
  83781. /** mag = nearest and min = nearest and mip = none */
  83782. static readonly NEAREST_NEAREST: number;
  83783. /** mag = linear and min = nearest and mip = nearest */
  83784. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83785. /** mag = linear and min = nearest and mip = linear */
  83786. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83787. /** mag = linear and min = linear and mip = none */
  83788. static readonly LINEAR_LINEAR: number;
  83789. /** mag = linear and min = nearest and mip = none */
  83790. static readonly LINEAR_NEAREST: number;
  83791. /** Explicit coordinates mode */
  83792. static readonly EXPLICIT_MODE: number;
  83793. /** Spherical coordinates mode */
  83794. static readonly SPHERICAL_MODE: number;
  83795. /** Planar coordinates mode */
  83796. static readonly PLANAR_MODE: number;
  83797. /** Cubic coordinates mode */
  83798. static readonly CUBIC_MODE: number;
  83799. /** Projection coordinates mode */
  83800. static readonly PROJECTION_MODE: number;
  83801. /** Inverse Cubic coordinates mode */
  83802. static readonly SKYBOX_MODE: number;
  83803. /** Inverse Cubic coordinates mode */
  83804. static readonly INVCUBIC_MODE: number;
  83805. /** Equirectangular coordinates mode */
  83806. static readonly EQUIRECTANGULAR_MODE: number;
  83807. /** Equirectangular Fixed coordinates mode */
  83808. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83809. /** Equirectangular Fixed Mirrored coordinates mode */
  83810. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83811. /** Texture is not repeating outside of 0..1 UVs */
  83812. static readonly CLAMP_ADDRESSMODE: number;
  83813. /** Texture is repeating outside of 0..1 UVs */
  83814. static readonly WRAP_ADDRESSMODE: number;
  83815. /** Texture is repeating and mirrored */
  83816. static readonly MIRROR_ADDRESSMODE: number;
  83817. /**
  83818. * 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
  83819. */
  83820. static UseSerializedUrlIfAny: boolean;
  83821. /**
  83822. * Define the url of the texture.
  83823. */
  83824. url: Nullable<string>;
  83825. /**
  83826. * Define an offset on the texture to offset the u coordinates of the UVs
  83827. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83828. */
  83829. uOffset: number;
  83830. /**
  83831. * Define an offset on the texture to offset the v coordinates of the UVs
  83832. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83833. */
  83834. vOffset: number;
  83835. /**
  83836. * Define an offset on the texture to scale the u coordinates of the UVs
  83837. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83838. */
  83839. uScale: number;
  83840. /**
  83841. * Define an offset on the texture to scale the v coordinates of the UVs
  83842. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83843. */
  83844. vScale: number;
  83845. /**
  83846. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83847. * @see http://doc.babylonjs.com/how_to/more_materials
  83848. */
  83849. uAng: number;
  83850. /**
  83851. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83852. * @see http://doc.babylonjs.com/how_to/more_materials
  83853. */
  83854. vAng: number;
  83855. /**
  83856. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83857. * @see http://doc.babylonjs.com/how_to/more_materials
  83858. */
  83859. wAng: number;
  83860. /**
  83861. * Defines the center of rotation (U)
  83862. */
  83863. uRotationCenter: number;
  83864. /**
  83865. * Defines the center of rotation (V)
  83866. */
  83867. vRotationCenter: number;
  83868. /**
  83869. * Defines the center of rotation (W)
  83870. */
  83871. wRotationCenter: number;
  83872. /**
  83873. * Are mip maps generated for this texture or not.
  83874. */
  83875. readonly noMipmap: boolean;
  83876. /**
  83877. * List of inspectable custom properties (used by the Inspector)
  83878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83879. */
  83880. inspectableCustomProperties: Nullable<IInspectable[]>;
  83881. private _noMipmap;
  83882. /** @hidden */
  83883. _invertY: boolean;
  83884. private _rowGenerationMatrix;
  83885. private _cachedTextureMatrix;
  83886. private _projectionModeMatrix;
  83887. private _t0;
  83888. private _t1;
  83889. private _t2;
  83890. private _cachedUOffset;
  83891. private _cachedVOffset;
  83892. private _cachedUScale;
  83893. private _cachedVScale;
  83894. private _cachedUAng;
  83895. private _cachedVAng;
  83896. private _cachedWAng;
  83897. private _cachedProjectionMatrixId;
  83898. private _cachedCoordinatesMode;
  83899. /** @hidden */
  83900. protected _initialSamplingMode: number;
  83901. /** @hidden */
  83902. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83903. private _deleteBuffer;
  83904. protected _format: Nullable<number>;
  83905. private _delayedOnLoad;
  83906. private _delayedOnError;
  83907. private _mimeType?;
  83908. /**
  83909. * Observable triggered once the texture has been loaded.
  83910. */
  83911. onLoadObservable: Observable<Texture>;
  83912. protected _isBlocking: boolean;
  83913. /**
  83914. * Is the texture preventing material to render while loading.
  83915. * If false, a default texture will be used instead of the loading one during the preparation step.
  83916. */
  83917. isBlocking: boolean;
  83918. /**
  83919. * Get the current sampling mode associated with the texture.
  83920. */
  83921. readonly samplingMode: number;
  83922. /**
  83923. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83924. */
  83925. readonly invertY: boolean;
  83926. /**
  83927. * Instantiates a new texture.
  83928. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83929. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83930. * @param url defines the url of the picture to load as a texture
  83931. * @param scene defines the scene or engine the texture will belong to
  83932. * @param noMipmap defines if the texture will require mip maps or not
  83933. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83934. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83935. * @param onLoad defines a callback triggered when the texture has been loaded
  83936. * @param onError defines a callback triggered when an error occurred during the loading session
  83937. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83938. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83939. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83940. * @param mimeType defines an optional mime type information
  83941. */
  83942. 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);
  83943. /**
  83944. * Update the url (and optional buffer) of this texture if url was null during construction.
  83945. * @param url the url of the texture
  83946. * @param buffer the buffer of the texture (defaults to null)
  83947. * @param onLoad callback called when the texture is loaded (defaults to null)
  83948. */
  83949. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83950. /**
  83951. * Finish the loading sequence of a texture flagged as delayed load.
  83952. * @hidden
  83953. */
  83954. delayLoad(): void;
  83955. private _prepareRowForTextureGeneration;
  83956. /**
  83957. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83958. * @returns the transform matrix of the texture.
  83959. */
  83960. getTextureMatrix(): Matrix;
  83961. /**
  83962. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83963. * @returns The reflection texture transform
  83964. */
  83965. getReflectionTextureMatrix(): Matrix;
  83966. /**
  83967. * Clones the texture.
  83968. * @returns the cloned texture
  83969. */
  83970. clone(): Texture;
  83971. /**
  83972. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83973. * @returns The JSON representation of the texture
  83974. */
  83975. serialize(): any;
  83976. /**
  83977. * Get the current class name of the texture useful for serialization or dynamic coding.
  83978. * @returns "Texture"
  83979. */
  83980. getClassName(): string;
  83981. /**
  83982. * Dispose the texture and release its associated resources.
  83983. */
  83984. dispose(): void;
  83985. /**
  83986. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83987. * @param parsedTexture Define the JSON representation of the texture
  83988. * @param scene Define the scene the parsed texture should be instantiated in
  83989. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83990. * @returns The parsed texture if successful
  83991. */
  83992. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83993. /**
  83994. * Creates a texture from its base 64 representation.
  83995. * @param data Define the base64 payload without the data: prefix
  83996. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83997. * @param scene Define the scene the texture should belong to
  83998. * @param noMipmap Forces the texture to not create mip map information if true
  83999. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84000. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84001. * @param onLoad define a callback triggered when the texture has been loaded
  84002. * @param onError define a callback triggered when an error occurred during the loading session
  84003. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84004. * @returns the created texture
  84005. */
  84006. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84007. /**
  84008. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84009. * @param data Define the base64 payload without the data: prefix
  84010. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84011. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84012. * @param scene Define the scene the texture should belong to
  84013. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84014. * @param noMipmap Forces the texture to not create mip map information if true
  84015. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84016. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84017. * @param onLoad define a callback triggered when the texture has been loaded
  84018. * @param onError define a callback triggered when an error occurred during the loading session
  84019. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84020. * @returns the created texture
  84021. */
  84022. 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;
  84023. }
  84024. }
  84025. declare module BABYLON {
  84026. /**
  84027. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84028. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84029. */
  84030. export class PostProcessManager {
  84031. private _scene;
  84032. private _indexBuffer;
  84033. private _vertexBuffers;
  84034. /**
  84035. * Creates a new instance PostProcess
  84036. * @param scene The scene that the post process is associated with.
  84037. */
  84038. constructor(scene: Scene);
  84039. private _prepareBuffers;
  84040. private _buildIndexBuffer;
  84041. /**
  84042. * Rebuilds the vertex buffers of the manager.
  84043. * @hidden
  84044. */
  84045. _rebuild(): void;
  84046. /**
  84047. * Prepares a frame to be run through a post process.
  84048. * @param sourceTexture The input texture to the post procesess. (default: null)
  84049. * @param postProcesses An array of post processes to be run. (default: null)
  84050. * @returns True if the post processes were able to be run.
  84051. * @hidden
  84052. */
  84053. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84054. /**
  84055. * Manually render a set of post processes to a texture.
  84056. * @param postProcesses An array of post processes to be run.
  84057. * @param targetTexture The target texture to render to.
  84058. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84059. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84060. * @param lodLevel defines which lod of the texture to render to
  84061. */
  84062. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84063. /**
  84064. * Finalize the result of the output of the postprocesses.
  84065. * @param doNotPresent If true the result will not be displayed to the screen.
  84066. * @param targetTexture The target texture to render to.
  84067. * @param faceIndex The index of the face to bind the target texture to.
  84068. * @param postProcesses The array of post processes to render.
  84069. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84070. * @hidden
  84071. */
  84072. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84073. /**
  84074. * Disposes of the post process manager.
  84075. */
  84076. dispose(): void;
  84077. }
  84078. }
  84079. declare module BABYLON {
  84080. /** Interface used by value gradients (color, factor, ...) */
  84081. export interface IValueGradient {
  84082. /**
  84083. * Gets or sets the gradient value (between 0 and 1)
  84084. */
  84085. gradient: number;
  84086. }
  84087. /** Class used to store color4 gradient */
  84088. export class ColorGradient implements IValueGradient {
  84089. /**
  84090. * Gets or sets the gradient value (between 0 and 1)
  84091. */
  84092. gradient: number;
  84093. /**
  84094. * Gets or sets first associated color
  84095. */
  84096. color1: Color4;
  84097. /**
  84098. * Gets or sets second associated color
  84099. */
  84100. color2?: Color4;
  84101. /**
  84102. * Will get a color picked randomly between color1 and color2.
  84103. * If color2 is undefined then color1 will be used
  84104. * @param result defines the target Color4 to store the result in
  84105. */
  84106. getColorToRef(result: Color4): void;
  84107. }
  84108. /** Class used to store color 3 gradient */
  84109. export class Color3Gradient implements IValueGradient {
  84110. /**
  84111. * Gets or sets the gradient value (between 0 and 1)
  84112. */
  84113. gradient: number;
  84114. /**
  84115. * Gets or sets the associated color
  84116. */
  84117. color: Color3;
  84118. }
  84119. /** Class used to store factor gradient */
  84120. export class FactorGradient implements IValueGradient {
  84121. /**
  84122. * Gets or sets the gradient value (between 0 and 1)
  84123. */
  84124. gradient: number;
  84125. /**
  84126. * Gets or sets first associated factor
  84127. */
  84128. factor1: number;
  84129. /**
  84130. * Gets or sets second associated factor
  84131. */
  84132. factor2?: number;
  84133. /**
  84134. * Will get a number picked randomly between factor1 and factor2.
  84135. * If factor2 is undefined then factor1 will be used
  84136. * @returns the picked number
  84137. */
  84138. getFactor(): number;
  84139. }
  84140. /**
  84141. * Helper used to simplify some generic gradient tasks
  84142. */
  84143. export class GradientHelper {
  84144. /**
  84145. * Gets the current gradient from an array of IValueGradient
  84146. * @param ratio defines the current ratio to get
  84147. * @param gradients defines the array of IValueGradient
  84148. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84149. */
  84150. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84151. }
  84152. }
  84153. declare module BABYLON {
  84154. interface ThinEngine {
  84155. /**
  84156. * Creates a dynamic texture
  84157. * @param width defines the width of the texture
  84158. * @param height defines the height of the texture
  84159. * @param generateMipMaps defines if the engine should generate the mip levels
  84160. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84161. * @returns the dynamic texture inside an InternalTexture
  84162. */
  84163. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84164. /**
  84165. * Update the content of a dynamic texture
  84166. * @param texture defines the texture to update
  84167. * @param canvas defines the canvas containing the source
  84168. * @param invertY defines if data must be stored with Y axis inverted
  84169. * @param premulAlpha defines if alpha is stored as premultiplied
  84170. * @param format defines the format of the data
  84171. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84172. */
  84173. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84174. }
  84175. }
  84176. declare module BABYLON {
  84177. /**
  84178. * Helper class used to generate a canvas to manipulate images
  84179. */
  84180. export class CanvasGenerator {
  84181. /**
  84182. * Create a new canvas (or offscreen canvas depending on the context)
  84183. * @param width defines the expected width
  84184. * @param height defines the expected height
  84185. * @return a new canvas or offscreen canvas
  84186. */
  84187. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84188. }
  84189. }
  84190. declare module BABYLON {
  84191. /**
  84192. * A class extending Texture allowing drawing on a texture
  84193. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84194. */
  84195. export class DynamicTexture extends Texture {
  84196. private _generateMipMaps;
  84197. private _canvas;
  84198. private _context;
  84199. private _engine;
  84200. /**
  84201. * Creates a DynamicTexture
  84202. * @param name defines the name of the texture
  84203. * @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
  84204. * @param scene defines the scene where you want the texture
  84205. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84206. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84207. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84208. */
  84209. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84210. /**
  84211. * Get the current class name of the texture useful for serialization or dynamic coding.
  84212. * @returns "DynamicTexture"
  84213. */
  84214. getClassName(): string;
  84215. /**
  84216. * Gets the current state of canRescale
  84217. */
  84218. readonly canRescale: boolean;
  84219. private _recreate;
  84220. /**
  84221. * Scales the texture
  84222. * @param ratio the scale factor to apply to both width and height
  84223. */
  84224. scale(ratio: number): void;
  84225. /**
  84226. * Resizes the texture
  84227. * @param width the new width
  84228. * @param height the new height
  84229. */
  84230. scaleTo(width: number, height: number): void;
  84231. /**
  84232. * Gets the context of the canvas used by the texture
  84233. * @returns the canvas context of the dynamic texture
  84234. */
  84235. getContext(): CanvasRenderingContext2D;
  84236. /**
  84237. * Clears the texture
  84238. */
  84239. clear(): void;
  84240. /**
  84241. * Updates the texture
  84242. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84243. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84244. */
  84245. update(invertY?: boolean, premulAlpha?: boolean): void;
  84246. /**
  84247. * Draws text onto the texture
  84248. * @param text defines the text to be drawn
  84249. * @param x defines the placement of the text from the left
  84250. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84251. * @param font defines the font to be used with font-style, font-size, font-name
  84252. * @param color defines the color used for the text
  84253. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84254. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84255. * @param update defines whether texture is immediately update (default is true)
  84256. */
  84257. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84258. /**
  84259. * Clones the texture
  84260. * @returns the clone of the texture.
  84261. */
  84262. clone(): DynamicTexture;
  84263. /**
  84264. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84265. * @returns a serialized dynamic texture object
  84266. */
  84267. serialize(): any;
  84268. /** @hidden */
  84269. _rebuild(): void;
  84270. }
  84271. }
  84272. declare module BABYLON {
  84273. interface AbstractScene {
  84274. /**
  84275. * The list of procedural textures added to the scene
  84276. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84277. */
  84278. proceduralTextures: Array<ProceduralTexture>;
  84279. }
  84280. /**
  84281. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84282. * in a given scene.
  84283. */
  84284. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84285. /**
  84286. * The component name helpfull to identify the component in the list of scene components.
  84287. */
  84288. readonly name: string;
  84289. /**
  84290. * The scene the component belongs to.
  84291. */
  84292. scene: Scene;
  84293. /**
  84294. * Creates a new instance of the component for the given scene
  84295. * @param scene Defines the scene to register the component in
  84296. */
  84297. constructor(scene: Scene);
  84298. /**
  84299. * Registers the component in a given scene
  84300. */
  84301. register(): void;
  84302. /**
  84303. * Rebuilds the elements related to this component in case of
  84304. * context lost for instance.
  84305. */
  84306. rebuild(): void;
  84307. /**
  84308. * Disposes the component and the associated ressources.
  84309. */
  84310. dispose(): void;
  84311. private _beforeClear;
  84312. }
  84313. }
  84314. declare module BABYLON {
  84315. interface ThinEngine {
  84316. /**
  84317. * Creates a new render target cube texture
  84318. * @param size defines the size of the texture
  84319. * @param options defines the options used to create the texture
  84320. * @returns a new render target cube texture stored in an InternalTexture
  84321. */
  84322. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84323. }
  84324. }
  84325. declare module BABYLON {
  84326. /** @hidden */
  84327. export var proceduralVertexShader: {
  84328. name: string;
  84329. shader: string;
  84330. };
  84331. }
  84332. declare module BABYLON {
  84333. /**
  84334. * 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.
  84335. * This is the base class of any Procedural texture and contains most of the shareable code.
  84336. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84337. */
  84338. export class ProceduralTexture extends Texture {
  84339. isCube: boolean;
  84340. /**
  84341. * Define if the texture is enabled or not (disabled texture will not render)
  84342. */
  84343. isEnabled: boolean;
  84344. /**
  84345. * Define if the texture must be cleared before rendering (default is true)
  84346. */
  84347. autoClear: boolean;
  84348. /**
  84349. * Callback called when the texture is generated
  84350. */
  84351. onGenerated: () => void;
  84352. /**
  84353. * Event raised when the texture is generated
  84354. */
  84355. onGeneratedObservable: Observable<ProceduralTexture>;
  84356. /** @hidden */
  84357. _generateMipMaps: boolean;
  84358. /** @hidden **/
  84359. _effect: Effect;
  84360. /** @hidden */
  84361. _textures: {
  84362. [key: string]: Texture;
  84363. };
  84364. private _size;
  84365. private _currentRefreshId;
  84366. private _refreshRate;
  84367. private _vertexBuffers;
  84368. private _indexBuffer;
  84369. private _uniforms;
  84370. private _samplers;
  84371. private _fragment;
  84372. private _floats;
  84373. private _ints;
  84374. private _floatsArrays;
  84375. private _colors3;
  84376. private _colors4;
  84377. private _vectors2;
  84378. private _vectors3;
  84379. private _matrices;
  84380. private _fallbackTexture;
  84381. private _fallbackTextureUsed;
  84382. private _engine;
  84383. private _cachedDefines;
  84384. private _contentUpdateId;
  84385. private _contentData;
  84386. /**
  84387. * Instantiates a new procedural texture.
  84388. * 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.
  84389. * This is the base class of any Procedural texture and contains most of the shareable code.
  84390. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84391. * @param name Define the name of the texture
  84392. * @param size Define the size of the texture to create
  84393. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84394. * @param scene Define the scene the texture belongs to
  84395. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84396. * @param generateMipMaps Define if the texture should creates mip maps or not
  84397. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84398. */
  84399. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84400. /**
  84401. * The effect that is created when initializing the post process.
  84402. * @returns The created effect corresponding the the postprocess.
  84403. */
  84404. getEffect(): Effect;
  84405. /**
  84406. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84407. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84408. */
  84409. getContent(): Nullable<ArrayBufferView>;
  84410. private _createIndexBuffer;
  84411. /** @hidden */
  84412. _rebuild(): void;
  84413. /**
  84414. * Resets the texture in order to recreate its associated resources.
  84415. * This can be called in case of context loss
  84416. */
  84417. reset(): void;
  84418. protected _getDefines(): string;
  84419. /**
  84420. * Is the texture ready to be used ? (rendered at least once)
  84421. * @returns true if ready, otherwise, false.
  84422. */
  84423. isReady(): boolean;
  84424. /**
  84425. * Resets the refresh counter of the texture and start bak from scratch.
  84426. * Could be useful to regenerate the texture if it is setup to render only once.
  84427. */
  84428. resetRefreshCounter(): void;
  84429. /**
  84430. * Set the fragment shader to use in order to render the texture.
  84431. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84432. */
  84433. setFragment(fragment: any): void;
  84434. /**
  84435. * Define the refresh rate of the texture or the rendering frequency.
  84436. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84437. */
  84438. refreshRate: number;
  84439. /** @hidden */
  84440. _shouldRender(): boolean;
  84441. /**
  84442. * Get the size the texture is rendering at.
  84443. * @returns the size (texture is always squared)
  84444. */
  84445. getRenderSize(): number;
  84446. /**
  84447. * Resize the texture to new value.
  84448. * @param size Define the new size the texture should have
  84449. * @param generateMipMaps Define whether the new texture should create mip maps
  84450. */
  84451. resize(size: number, generateMipMaps: boolean): void;
  84452. private _checkUniform;
  84453. /**
  84454. * Set a texture in the shader program used to render.
  84455. * @param name Define the name of the uniform samplers as defined in the shader
  84456. * @param texture Define the texture to bind to this sampler
  84457. * @return the texture itself allowing "fluent" like uniform updates
  84458. */
  84459. setTexture(name: string, texture: Texture): ProceduralTexture;
  84460. /**
  84461. * Set a float in the shader.
  84462. * @param name Define the name of the uniform as defined in the shader
  84463. * @param value Define the value to give to the uniform
  84464. * @return the texture itself allowing "fluent" like uniform updates
  84465. */
  84466. setFloat(name: string, value: number): ProceduralTexture;
  84467. /**
  84468. * Set a int in the shader.
  84469. * @param name Define the name of the uniform as defined in the shader
  84470. * @param value Define the value to give to the uniform
  84471. * @return the texture itself allowing "fluent" like uniform updates
  84472. */
  84473. setInt(name: string, value: number): ProceduralTexture;
  84474. /**
  84475. * Set an array of floats in the shader.
  84476. * @param name Define the name of the uniform as defined in the shader
  84477. * @param value Define the value to give to the uniform
  84478. * @return the texture itself allowing "fluent" like uniform updates
  84479. */
  84480. setFloats(name: string, value: number[]): ProceduralTexture;
  84481. /**
  84482. * Set a vec3 in the shader from a Color3.
  84483. * @param name Define the name of the uniform as defined in the shader
  84484. * @param value Define the value to give to the uniform
  84485. * @return the texture itself allowing "fluent" like uniform updates
  84486. */
  84487. setColor3(name: string, value: Color3): ProceduralTexture;
  84488. /**
  84489. * Set a vec4 in the shader from a Color4.
  84490. * @param name Define the name of the uniform as defined in the shader
  84491. * @param value Define the value to give to the uniform
  84492. * @return the texture itself allowing "fluent" like uniform updates
  84493. */
  84494. setColor4(name: string, value: Color4): ProceduralTexture;
  84495. /**
  84496. * Set a vec2 in the shader from a Vector2.
  84497. * @param name Define the name of the uniform as defined in the shader
  84498. * @param value Define the value to give to the uniform
  84499. * @return the texture itself allowing "fluent" like uniform updates
  84500. */
  84501. setVector2(name: string, value: Vector2): ProceduralTexture;
  84502. /**
  84503. * Set a vec3 in the shader from a Vector3.
  84504. * @param name Define the name of the uniform as defined in the shader
  84505. * @param value Define the value to give to the uniform
  84506. * @return the texture itself allowing "fluent" like uniform updates
  84507. */
  84508. setVector3(name: string, value: Vector3): ProceduralTexture;
  84509. /**
  84510. * Set a mat4 in the shader from a MAtrix.
  84511. * @param name Define the name of the uniform as defined in the shader
  84512. * @param value Define the value to give to the uniform
  84513. * @return the texture itself allowing "fluent" like uniform updates
  84514. */
  84515. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84516. /**
  84517. * Render the texture to its associated render target.
  84518. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84519. */
  84520. render(useCameraPostProcess?: boolean): void;
  84521. /**
  84522. * Clone the texture.
  84523. * @returns the cloned texture
  84524. */
  84525. clone(): ProceduralTexture;
  84526. /**
  84527. * Dispose the texture and release its asoociated resources.
  84528. */
  84529. dispose(): void;
  84530. }
  84531. }
  84532. declare module BABYLON {
  84533. /**
  84534. * This represents the base class for particle system in Babylon.
  84535. * 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.
  84536. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84537. * @example https://doc.babylonjs.com/babylon101/particles
  84538. */
  84539. export class BaseParticleSystem {
  84540. /**
  84541. * Source color is added to the destination color without alpha affecting the result
  84542. */
  84543. static BLENDMODE_ONEONE: number;
  84544. /**
  84545. * Blend current color and particle color using particle’s alpha
  84546. */
  84547. static BLENDMODE_STANDARD: number;
  84548. /**
  84549. * Add current color and particle color multiplied by particle’s alpha
  84550. */
  84551. static BLENDMODE_ADD: number;
  84552. /**
  84553. * Multiply current color with particle color
  84554. */
  84555. static BLENDMODE_MULTIPLY: number;
  84556. /**
  84557. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84558. */
  84559. static BLENDMODE_MULTIPLYADD: number;
  84560. /**
  84561. * List of animations used by the particle system.
  84562. */
  84563. animations: Animation[];
  84564. /**
  84565. * The id of the Particle system.
  84566. */
  84567. id: string;
  84568. /**
  84569. * The friendly name of the Particle system.
  84570. */
  84571. name: string;
  84572. /**
  84573. * The rendering group used by the Particle system to chose when to render.
  84574. */
  84575. renderingGroupId: number;
  84576. /**
  84577. * The emitter represents the Mesh or position we are attaching the particle system to.
  84578. */
  84579. emitter: Nullable<AbstractMesh | Vector3>;
  84580. /**
  84581. * The maximum number of particles to emit per frame
  84582. */
  84583. emitRate: number;
  84584. /**
  84585. * If you want to launch only a few particles at once, that can be done, as well.
  84586. */
  84587. manualEmitCount: number;
  84588. /**
  84589. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84590. */
  84591. updateSpeed: number;
  84592. /**
  84593. * The amount of time the particle system is running (depends of the overall update speed).
  84594. */
  84595. targetStopDuration: number;
  84596. /**
  84597. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84598. */
  84599. disposeOnStop: boolean;
  84600. /**
  84601. * Minimum power of emitting particles.
  84602. */
  84603. minEmitPower: number;
  84604. /**
  84605. * Maximum power of emitting particles.
  84606. */
  84607. maxEmitPower: number;
  84608. /**
  84609. * Minimum life time of emitting particles.
  84610. */
  84611. minLifeTime: number;
  84612. /**
  84613. * Maximum life time of emitting particles.
  84614. */
  84615. maxLifeTime: number;
  84616. /**
  84617. * Minimum Size of emitting particles.
  84618. */
  84619. minSize: number;
  84620. /**
  84621. * Maximum Size of emitting particles.
  84622. */
  84623. maxSize: number;
  84624. /**
  84625. * Minimum scale of emitting particles on X axis.
  84626. */
  84627. minScaleX: number;
  84628. /**
  84629. * Maximum scale of emitting particles on X axis.
  84630. */
  84631. maxScaleX: number;
  84632. /**
  84633. * Minimum scale of emitting particles on Y axis.
  84634. */
  84635. minScaleY: number;
  84636. /**
  84637. * Maximum scale of emitting particles on Y axis.
  84638. */
  84639. maxScaleY: number;
  84640. /**
  84641. * Gets or sets the minimal initial rotation in radians.
  84642. */
  84643. minInitialRotation: number;
  84644. /**
  84645. * Gets or sets the maximal initial rotation in radians.
  84646. */
  84647. maxInitialRotation: number;
  84648. /**
  84649. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84650. */
  84651. minAngularSpeed: number;
  84652. /**
  84653. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84654. */
  84655. maxAngularSpeed: number;
  84656. /**
  84657. * The texture used to render each particle. (this can be a spritesheet)
  84658. */
  84659. particleTexture: Nullable<Texture>;
  84660. /**
  84661. * The layer mask we are rendering the particles through.
  84662. */
  84663. layerMask: number;
  84664. /**
  84665. * This can help using your own shader to render the particle system.
  84666. * The according effect will be created
  84667. */
  84668. customShader: any;
  84669. /**
  84670. * By default particle system starts as soon as they are created. This prevents the
  84671. * automatic start to happen and let you decide when to start emitting particles.
  84672. */
  84673. preventAutoStart: boolean;
  84674. private _noiseTexture;
  84675. /**
  84676. * Gets or sets a texture used to add random noise to particle positions
  84677. */
  84678. noiseTexture: Nullable<ProceduralTexture>;
  84679. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84680. noiseStrength: Vector3;
  84681. /**
  84682. * Callback triggered when the particle animation is ending.
  84683. */
  84684. onAnimationEnd: Nullable<() => void>;
  84685. /**
  84686. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84687. */
  84688. blendMode: number;
  84689. /**
  84690. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84691. * to override the particles.
  84692. */
  84693. forceDepthWrite: boolean;
  84694. /** 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 */
  84695. preWarmCycles: number;
  84696. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84697. preWarmStepOffset: number;
  84698. /**
  84699. * 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)
  84700. */
  84701. spriteCellChangeSpeed: number;
  84702. /**
  84703. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84704. */
  84705. startSpriteCellID: number;
  84706. /**
  84707. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84708. */
  84709. endSpriteCellID: number;
  84710. /**
  84711. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84712. */
  84713. spriteCellWidth: number;
  84714. /**
  84715. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84716. */
  84717. spriteCellHeight: number;
  84718. /**
  84719. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84720. */
  84721. spriteRandomStartCell: boolean;
  84722. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84723. translationPivot: Vector2;
  84724. /** @hidden */
  84725. protected _isAnimationSheetEnabled: boolean;
  84726. /**
  84727. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84728. */
  84729. beginAnimationOnStart: boolean;
  84730. /**
  84731. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84732. */
  84733. beginAnimationFrom: number;
  84734. /**
  84735. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84736. */
  84737. beginAnimationTo: number;
  84738. /**
  84739. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84740. */
  84741. beginAnimationLoop: boolean;
  84742. /**
  84743. * Gets or sets a world offset applied to all particles
  84744. */
  84745. worldOffset: Vector3;
  84746. /**
  84747. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84748. */
  84749. isAnimationSheetEnabled: boolean;
  84750. /**
  84751. * Get hosting scene
  84752. * @returns the scene
  84753. */
  84754. getScene(): Scene;
  84755. /**
  84756. * You can use gravity if you want to give an orientation to your particles.
  84757. */
  84758. gravity: Vector3;
  84759. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84760. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84761. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84762. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84763. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84764. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84765. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84766. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84767. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84768. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84769. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84770. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84771. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84772. /**
  84773. * Defines the delay in milliseconds before starting the system (0 by default)
  84774. */
  84775. startDelay: number;
  84776. /**
  84777. * Gets the current list of drag gradients.
  84778. * You must use addDragGradient and removeDragGradient to udpate this list
  84779. * @returns the list of drag gradients
  84780. */
  84781. getDragGradients(): Nullable<Array<FactorGradient>>;
  84782. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84783. limitVelocityDamping: number;
  84784. /**
  84785. * Gets the current list of limit velocity gradients.
  84786. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84787. * @returns the list of limit velocity gradients
  84788. */
  84789. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84790. /**
  84791. * Gets the current list of color gradients.
  84792. * You must use addColorGradient and removeColorGradient to udpate this list
  84793. * @returns the list of color gradients
  84794. */
  84795. getColorGradients(): Nullable<Array<ColorGradient>>;
  84796. /**
  84797. * Gets the current list of size gradients.
  84798. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84799. * @returns the list of size gradients
  84800. */
  84801. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84802. /**
  84803. * Gets the current list of color remap gradients.
  84804. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84805. * @returns the list of color remap gradients
  84806. */
  84807. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84808. /**
  84809. * Gets the current list of alpha remap gradients.
  84810. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84811. * @returns the list of alpha remap gradients
  84812. */
  84813. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84814. /**
  84815. * Gets the current list of life time gradients.
  84816. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84817. * @returns the list of life time gradients
  84818. */
  84819. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84820. /**
  84821. * Gets the current list of angular speed gradients.
  84822. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84823. * @returns the list of angular speed gradients
  84824. */
  84825. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84826. /**
  84827. * Gets the current list of velocity gradients.
  84828. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84829. * @returns the list of velocity gradients
  84830. */
  84831. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84832. /**
  84833. * Gets the current list of start size gradients.
  84834. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84835. * @returns the list of start size gradients
  84836. */
  84837. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84838. /**
  84839. * Gets the current list of emit rate gradients.
  84840. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84841. * @returns the list of emit rate gradients
  84842. */
  84843. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84844. /**
  84845. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84846. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84847. */
  84848. direction1: Vector3;
  84849. /**
  84850. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84851. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84852. */
  84853. direction2: Vector3;
  84854. /**
  84855. * 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.
  84856. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84857. */
  84858. minEmitBox: Vector3;
  84859. /**
  84860. * 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.
  84861. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84862. */
  84863. maxEmitBox: Vector3;
  84864. /**
  84865. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84866. */
  84867. color1: Color4;
  84868. /**
  84869. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84870. */
  84871. color2: Color4;
  84872. /**
  84873. * Color the particle will have at the end of its lifetime
  84874. */
  84875. colorDead: Color4;
  84876. /**
  84877. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84878. */
  84879. textureMask: Color4;
  84880. /**
  84881. * The particle emitter type defines the emitter used by the particle system.
  84882. * It can be for example box, sphere, or cone...
  84883. */
  84884. particleEmitterType: IParticleEmitterType;
  84885. /** @hidden */
  84886. _isSubEmitter: boolean;
  84887. /**
  84888. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84889. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84890. */
  84891. billboardMode: number;
  84892. protected _isBillboardBased: boolean;
  84893. /**
  84894. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84895. */
  84896. isBillboardBased: boolean;
  84897. /**
  84898. * The scene the particle system belongs to.
  84899. */
  84900. protected _scene: Scene;
  84901. /**
  84902. * Local cache of defines for image processing.
  84903. */
  84904. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84905. /**
  84906. * Default configuration related to image processing available in the standard Material.
  84907. */
  84908. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84909. /**
  84910. * Gets the image processing configuration used either in this material.
  84911. */
  84912. /**
  84913. * Sets the Default image processing configuration used either in the this material.
  84914. *
  84915. * If sets to null, the scene one is in use.
  84916. */
  84917. imageProcessingConfiguration: ImageProcessingConfiguration;
  84918. /**
  84919. * Attaches a new image processing configuration to the Standard Material.
  84920. * @param configuration
  84921. */
  84922. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84923. /** @hidden */
  84924. protected _reset(): void;
  84925. /** @hidden */
  84926. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84927. /**
  84928. * Instantiates a particle system.
  84929. * 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.
  84930. * @param name The name of the particle system
  84931. */
  84932. constructor(name: string);
  84933. /**
  84934. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84935. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84936. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84937. * @returns the emitter
  84938. */
  84939. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84940. /**
  84941. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84942. * @param radius The radius of the hemisphere to emit from
  84943. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84944. * @returns the emitter
  84945. */
  84946. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84947. /**
  84948. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84949. * @param radius The radius of the sphere to emit from
  84950. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84951. * @returns the emitter
  84952. */
  84953. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84954. /**
  84955. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84956. * @param radius The radius of the sphere to emit from
  84957. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84958. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84959. * @returns the emitter
  84960. */
  84961. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84962. /**
  84963. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84964. * @param radius The radius of the emission cylinder
  84965. * @param height The height of the emission cylinder
  84966. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84967. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84968. * @returns the emitter
  84969. */
  84970. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84971. /**
  84972. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84973. * @param radius The radius of the cylinder to emit from
  84974. * @param height The height of the emission cylinder
  84975. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84976. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84977. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84978. * @returns the emitter
  84979. */
  84980. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84981. /**
  84982. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84983. * @param radius The radius of the cone to emit from
  84984. * @param angle The base angle of the cone
  84985. * @returns the emitter
  84986. */
  84987. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84988. /**
  84989. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84992. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84993. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84994. * @returns the emitter
  84995. */
  84996. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84997. }
  84998. }
  84999. declare module BABYLON {
  85000. /**
  85001. * Type of sub emitter
  85002. */
  85003. export enum SubEmitterType {
  85004. /**
  85005. * Attached to the particle over it's lifetime
  85006. */
  85007. ATTACHED = 0,
  85008. /**
  85009. * Created when the particle dies
  85010. */
  85011. END = 1
  85012. }
  85013. /**
  85014. * Sub emitter class used to emit particles from an existing particle
  85015. */
  85016. export class SubEmitter {
  85017. /**
  85018. * the particle system to be used by the sub emitter
  85019. */
  85020. particleSystem: ParticleSystem;
  85021. /**
  85022. * Type of the submitter (Default: END)
  85023. */
  85024. type: SubEmitterType;
  85025. /**
  85026. * 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)
  85027. * Note: This only is supported when using an emitter of type Mesh
  85028. */
  85029. inheritDirection: boolean;
  85030. /**
  85031. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85032. */
  85033. inheritedVelocityAmount: number;
  85034. /**
  85035. * Creates a sub emitter
  85036. * @param particleSystem the particle system to be used by the sub emitter
  85037. */
  85038. constructor(
  85039. /**
  85040. * the particle system to be used by the sub emitter
  85041. */
  85042. particleSystem: ParticleSystem);
  85043. /**
  85044. * Clones the sub emitter
  85045. * @returns the cloned sub emitter
  85046. */
  85047. clone(): SubEmitter;
  85048. /**
  85049. * Serialize current object to a JSON object
  85050. * @returns the serialized object
  85051. */
  85052. serialize(): any;
  85053. /** @hidden */
  85054. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85055. /**
  85056. * Creates a new SubEmitter from a serialized JSON version
  85057. * @param serializationObject defines the JSON object to read from
  85058. * @param scene defines the hosting scene
  85059. * @param rootUrl defines the rootUrl for data loading
  85060. * @returns a new SubEmitter
  85061. */
  85062. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85063. /** Release associated resources */
  85064. dispose(): void;
  85065. }
  85066. }
  85067. declare module BABYLON {
  85068. /** @hidden */
  85069. export var clipPlaneFragmentDeclaration: {
  85070. name: string;
  85071. shader: string;
  85072. };
  85073. }
  85074. declare module BABYLON {
  85075. /** @hidden */
  85076. export var imageProcessingDeclaration: {
  85077. name: string;
  85078. shader: string;
  85079. };
  85080. }
  85081. declare module BABYLON {
  85082. /** @hidden */
  85083. export var imageProcessingFunctions: {
  85084. name: string;
  85085. shader: string;
  85086. };
  85087. }
  85088. declare module BABYLON {
  85089. /** @hidden */
  85090. export var clipPlaneFragment: {
  85091. name: string;
  85092. shader: string;
  85093. };
  85094. }
  85095. declare module BABYLON {
  85096. /** @hidden */
  85097. export var particlesPixelShader: {
  85098. name: string;
  85099. shader: string;
  85100. };
  85101. }
  85102. declare module BABYLON {
  85103. /** @hidden */
  85104. export var clipPlaneVertexDeclaration: {
  85105. name: string;
  85106. shader: string;
  85107. };
  85108. }
  85109. declare module BABYLON {
  85110. /** @hidden */
  85111. export var clipPlaneVertex: {
  85112. name: string;
  85113. shader: string;
  85114. };
  85115. }
  85116. declare module BABYLON {
  85117. /** @hidden */
  85118. export var particlesVertexShader: {
  85119. name: string;
  85120. shader: string;
  85121. };
  85122. }
  85123. declare module BABYLON {
  85124. /**
  85125. * This represents a particle system in Babylon.
  85126. * 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.
  85127. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85128. * @example https://doc.babylonjs.com/babylon101/particles
  85129. */
  85130. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85131. /**
  85132. * Billboard mode will only apply to Y axis
  85133. */
  85134. static readonly BILLBOARDMODE_Y: number;
  85135. /**
  85136. * Billboard mode will apply to all axes
  85137. */
  85138. static readonly BILLBOARDMODE_ALL: number;
  85139. /**
  85140. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85141. */
  85142. static readonly BILLBOARDMODE_STRETCHED: number;
  85143. /**
  85144. * This function can be defined to provide custom update for active particles.
  85145. * This function will be called instead of regular update (age, position, color, etc.).
  85146. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85147. */
  85148. updateFunction: (particles: Particle[]) => void;
  85149. private _emitterWorldMatrix;
  85150. /**
  85151. * This function can be defined to specify initial direction for every new particle.
  85152. * It by default use the emitterType defined function
  85153. */
  85154. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85155. /**
  85156. * This function can be defined to specify initial position for every new particle.
  85157. * It by default use the emitterType defined function
  85158. */
  85159. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85160. /**
  85161. * @hidden
  85162. */
  85163. _inheritedVelocityOffset: Vector3;
  85164. /**
  85165. * An event triggered when the system is disposed
  85166. */
  85167. onDisposeObservable: Observable<ParticleSystem>;
  85168. private _onDisposeObserver;
  85169. /**
  85170. * Sets a callback that will be triggered when the system is disposed
  85171. */
  85172. onDispose: () => void;
  85173. private _particles;
  85174. private _epsilon;
  85175. private _capacity;
  85176. private _stockParticles;
  85177. private _newPartsExcess;
  85178. private _vertexData;
  85179. private _vertexBuffer;
  85180. private _vertexBuffers;
  85181. private _spriteBuffer;
  85182. private _indexBuffer;
  85183. private _effect;
  85184. private _customEffect;
  85185. private _cachedDefines;
  85186. private _scaledColorStep;
  85187. private _colorDiff;
  85188. private _scaledDirection;
  85189. private _scaledGravity;
  85190. private _currentRenderId;
  85191. private _alive;
  85192. private _useInstancing;
  85193. private _started;
  85194. private _stopped;
  85195. private _actualFrame;
  85196. private _scaledUpdateSpeed;
  85197. private _vertexBufferSize;
  85198. /** @hidden */
  85199. _currentEmitRateGradient: Nullable<FactorGradient>;
  85200. /** @hidden */
  85201. _currentEmitRate1: number;
  85202. /** @hidden */
  85203. _currentEmitRate2: number;
  85204. /** @hidden */
  85205. _currentStartSizeGradient: Nullable<FactorGradient>;
  85206. /** @hidden */
  85207. _currentStartSize1: number;
  85208. /** @hidden */
  85209. _currentStartSize2: number;
  85210. private readonly _rawTextureWidth;
  85211. private _rampGradientsTexture;
  85212. private _useRampGradients;
  85213. /** Gets or sets a boolean indicating that ramp gradients must be used
  85214. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85215. */
  85216. useRampGradients: boolean;
  85217. /**
  85218. * 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.
  85219. * 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: [])
  85220. */
  85221. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85222. private _subEmitters;
  85223. /**
  85224. * @hidden
  85225. * If the particle systems emitter should be disposed when the particle system is disposed
  85226. */
  85227. _disposeEmitterOnDispose: boolean;
  85228. /**
  85229. * The current active Sub-systems, this property is used by the root particle system only.
  85230. */
  85231. activeSubSystems: Array<ParticleSystem>;
  85232. private _rootParticleSystem;
  85233. /**
  85234. * Gets the current list of active particles
  85235. */
  85236. readonly particles: Particle[];
  85237. /**
  85238. * Returns the string "ParticleSystem"
  85239. * @returns a string containing the class name
  85240. */
  85241. getClassName(): string;
  85242. /**
  85243. * Instantiates a particle system.
  85244. * 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.
  85245. * @param name The name of the particle system
  85246. * @param capacity The max number of particles alive at the same time
  85247. * @param scene The scene the particle system belongs to
  85248. * @param customEffect a custom effect used to change the way particles are rendered by default
  85249. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85250. * @param epsilon Offset used to render the particles
  85251. */
  85252. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85253. private _addFactorGradient;
  85254. private _removeFactorGradient;
  85255. /**
  85256. * Adds a new life time gradient
  85257. * @param gradient defines the gradient to use (between 0 and 1)
  85258. * @param factor defines the life time factor to affect to the specified gradient
  85259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85260. * @returns the current particle system
  85261. */
  85262. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85263. /**
  85264. * Remove a specific life time gradient
  85265. * @param gradient defines the gradient to remove
  85266. * @returns the current particle system
  85267. */
  85268. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85269. /**
  85270. * Adds a new size gradient
  85271. * @param gradient defines the gradient to use (between 0 and 1)
  85272. * @param factor defines the size factor to affect to the specified gradient
  85273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85274. * @returns the current particle system
  85275. */
  85276. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85277. /**
  85278. * Remove a specific size gradient
  85279. * @param gradient defines the gradient to remove
  85280. * @returns the current particle system
  85281. */
  85282. removeSizeGradient(gradient: number): IParticleSystem;
  85283. /**
  85284. * Adds a new color remap gradient
  85285. * @param gradient defines the gradient to use (between 0 and 1)
  85286. * @param min defines the color remap minimal range
  85287. * @param max defines the color remap maximal range
  85288. * @returns the current particle system
  85289. */
  85290. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85291. /**
  85292. * Remove a specific color remap gradient
  85293. * @param gradient defines the gradient to remove
  85294. * @returns the current particle system
  85295. */
  85296. removeColorRemapGradient(gradient: number): IParticleSystem;
  85297. /**
  85298. * Adds a new alpha remap gradient
  85299. * @param gradient defines the gradient to use (between 0 and 1)
  85300. * @param min defines the alpha remap minimal range
  85301. * @param max defines the alpha remap maximal range
  85302. * @returns the current particle system
  85303. */
  85304. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85305. /**
  85306. * Remove a specific alpha remap gradient
  85307. * @param gradient defines the gradient to remove
  85308. * @returns the current particle system
  85309. */
  85310. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85311. /**
  85312. * Adds a new angular speed gradient
  85313. * @param gradient defines the gradient to use (between 0 and 1)
  85314. * @param factor defines the angular speed to affect to the specified gradient
  85315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85316. * @returns the current particle system
  85317. */
  85318. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85319. /**
  85320. * Remove a specific angular speed gradient
  85321. * @param gradient defines the gradient to remove
  85322. * @returns the current particle system
  85323. */
  85324. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85325. /**
  85326. * Adds a new velocity gradient
  85327. * @param gradient defines the gradient to use (between 0 and 1)
  85328. * @param factor defines the velocity to affect to the specified gradient
  85329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85330. * @returns the current particle system
  85331. */
  85332. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85333. /**
  85334. * Remove a specific velocity gradient
  85335. * @param gradient defines the gradient to remove
  85336. * @returns the current particle system
  85337. */
  85338. removeVelocityGradient(gradient: number): IParticleSystem;
  85339. /**
  85340. * Adds a new limit velocity gradient
  85341. * @param gradient defines the gradient to use (between 0 and 1)
  85342. * @param factor defines the limit velocity value to affect to the specified gradient
  85343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85344. * @returns the current particle system
  85345. */
  85346. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85347. /**
  85348. * Remove a specific limit velocity gradient
  85349. * @param gradient defines the gradient to remove
  85350. * @returns the current particle system
  85351. */
  85352. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85353. /**
  85354. * Adds a new drag gradient
  85355. * @param gradient defines the gradient to use (between 0 and 1)
  85356. * @param factor defines the drag value to affect to the specified gradient
  85357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85358. * @returns the current particle system
  85359. */
  85360. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85361. /**
  85362. * Remove a specific drag gradient
  85363. * @param gradient defines the gradient to remove
  85364. * @returns the current particle system
  85365. */
  85366. removeDragGradient(gradient: number): IParticleSystem;
  85367. /**
  85368. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85369. * @param gradient defines the gradient to use (between 0 and 1)
  85370. * @param factor defines the emit rate value to affect to the specified gradient
  85371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85372. * @returns the current particle system
  85373. */
  85374. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85375. /**
  85376. * Remove a specific emit rate gradient
  85377. * @param gradient defines the gradient to remove
  85378. * @returns the current particle system
  85379. */
  85380. removeEmitRateGradient(gradient: number): IParticleSystem;
  85381. /**
  85382. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85383. * @param gradient defines the gradient to use (between 0 and 1)
  85384. * @param factor defines the start size value to affect to the specified gradient
  85385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85386. * @returns the current particle system
  85387. */
  85388. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85389. /**
  85390. * Remove a specific start size gradient
  85391. * @param gradient defines the gradient to remove
  85392. * @returns the current particle system
  85393. */
  85394. removeStartSizeGradient(gradient: number): IParticleSystem;
  85395. private _createRampGradientTexture;
  85396. /**
  85397. * Gets the current list of ramp gradients.
  85398. * You must use addRampGradient and removeRampGradient to udpate this list
  85399. * @returns the list of ramp gradients
  85400. */
  85401. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85402. /**
  85403. * Adds a new ramp gradient used to remap particle colors
  85404. * @param gradient defines the gradient to use (between 0 and 1)
  85405. * @param color defines the color to affect to the specified gradient
  85406. * @returns the current particle system
  85407. */
  85408. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85409. /**
  85410. * Remove a specific ramp gradient
  85411. * @param gradient defines the gradient to remove
  85412. * @returns the current particle system
  85413. */
  85414. removeRampGradient(gradient: number): ParticleSystem;
  85415. /**
  85416. * Adds a new color gradient
  85417. * @param gradient defines the gradient to use (between 0 and 1)
  85418. * @param color1 defines the color to affect to the specified gradient
  85419. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85420. * @returns this particle system
  85421. */
  85422. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85423. /**
  85424. * Remove a specific color gradient
  85425. * @param gradient defines the gradient to remove
  85426. * @returns this particle system
  85427. */
  85428. removeColorGradient(gradient: number): IParticleSystem;
  85429. private _fetchR;
  85430. protected _reset(): void;
  85431. private _resetEffect;
  85432. private _createVertexBuffers;
  85433. private _createIndexBuffer;
  85434. /**
  85435. * Gets the maximum number of particles active at the same time.
  85436. * @returns The max number of active particles.
  85437. */
  85438. getCapacity(): number;
  85439. /**
  85440. * Gets whether there are still active particles in the system.
  85441. * @returns True if it is alive, otherwise false.
  85442. */
  85443. isAlive(): boolean;
  85444. /**
  85445. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85446. * @returns True if it has been started, otherwise false.
  85447. */
  85448. isStarted(): boolean;
  85449. private _prepareSubEmitterInternalArray;
  85450. /**
  85451. * Starts the particle system and begins to emit
  85452. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85453. */
  85454. start(delay?: number): void;
  85455. /**
  85456. * Stops the particle system.
  85457. * @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.
  85458. */
  85459. stop(stopSubEmitters?: boolean): void;
  85460. /**
  85461. * Remove all active particles
  85462. */
  85463. reset(): void;
  85464. /**
  85465. * @hidden (for internal use only)
  85466. */
  85467. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85468. /**
  85469. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85470. * Its lifetime will start back at 0.
  85471. */
  85472. recycleParticle: (particle: Particle) => void;
  85473. private _stopSubEmitters;
  85474. private _createParticle;
  85475. private _removeFromRoot;
  85476. private _emitFromParticle;
  85477. private _update;
  85478. /** @hidden */
  85479. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85480. /** @hidden */
  85481. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85482. /** @hidden */
  85483. private _getEffect;
  85484. /**
  85485. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85486. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85487. */
  85488. animate(preWarmOnly?: boolean): void;
  85489. private _appendParticleVertices;
  85490. /**
  85491. * Rebuilds the particle system.
  85492. */
  85493. rebuild(): void;
  85494. /**
  85495. * Is this system ready to be used/rendered
  85496. * @return true if the system is ready
  85497. */
  85498. isReady(): boolean;
  85499. private _render;
  85500. /**
  85501. * Renders the particle system in its current state.
  85502. * @returns the current number of particles
  85503. */
  85504. render(): number;
  85505. /**
  85506. * Disposes the particle system and free the associated resources
  85507. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85508. */
  85509. dispose(disposeTexture?: boolean): void;
  85510. /**
  85511. * Clones the particle system.
  85512. * @param name The name of the cloned object
  85513. * @param newEmitter The new emitter to use
  85514. * @returns the cloned particle system
  85515. */
  85516. clone(name: string, newEmitter: any): ParticleSystem;
  85517. /**
  85518. * Serializes the particle system to a JSON object.
  85519. * @returns the JSON object
  85520. */
  85521. serialize(): any;
  85522. /** @hidden */
  85523. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85524. /** @hidden */
  85525. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85526. /**
  85527. * Parses a JSON object to create a particle system.
  85528. * @param parsedParticleSystem The JSON object to parse
  85529. * @param scene The scene to create the particle system in
  85530. * @param rootUrl The root url to use to load external dependencies like texture
  85531. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85532. * @returns the Parsed particle system
  85533. */
  85534. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85535. }
  85536. }
  85537. declare module BABYLON {
  85538. /**
  85539. * A particle represents one of the element emitted by a particle system.
  85540. * This is mainly define by its coordinates, direction, velocity and age.
  85541. */
  85542. export class Particle {
  85543. /**
  85544. * The particle system the particle belongs to.
  85545. */
  85546. particleSystem: ParticleSystem;
  85547. private static _Count;
  85548. /**
  85549. * Unique ID of the particle
  85550. */
  85551. id: number;
  85552. /**
  85553. * The world position of the particle in the scene.
  85554. */
  85555. position: Vector3;
  85556. /**
  85557. * The world direction of the particle in the scene.
  85558. */
  85559. direction: Vector3;
  85560. /**
  85561. * The color of the particle.
  85562. */
  85563. color: Color4;
  85564. /**
  85565. * The color change of the particle per step.
  85566. */
  85567. colorStep: Color4;
  85568. /**
  85569. * Defines how long will the life of the particle be.
  85570. */
  85571. lifeTime: number;
  85572. /**
  85573. * The current age of the particle.
  85574. */
  85575. age: number;
  85576. /**
  85577. * The current size of the particle.
  85578. */
  85579. size: number;
  85580. /**
  85581. * The current scale of the particle.
  85582. */
  85583. scale: Vector2;
  85584. /**
  85585. * The current angle of the particle.
  85586. */
  85587. angle: number;
  85588. /**
  85589. * Defines how fast is the angle changing.
  85590. */
  85591. angularSpeed: number;
  85592. /**
  85593. * Defines the cell index used by the particle to be rendered from a sprite.
  85594. */
  85595. cellIndex: number;
  85596. /**
  85597. * The information required to support color remapping
  85598. */
  85599. remapData: Vector4;
  85600. /** @hidden */
  85601. _randomCellOffset?: number;
  85602. /** @hidden */
  85603. _initialDirection: Nullable<Vector3>;
  85604. /** @hidden */
  85605. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85606. /** @hidden */
  85607. _initialStartSpriteCellID: number;
  85608. /** @hidden */
  85609. _initialEndSpriteCellID: number;
  85610. /** @hidden */
  85611. _currentColorGradient: Nullable<ColorGradient>;
  85612. /** @hidden */
  85613. _currentColor1: Color4;
  85614. /** @hidden */
  85615. _currentColor2: Color4;
  85616. /** @hidden */
  85617. _currentSizeGradient: Nullable<FactorGradient>;
  85618. /** @hidden */
  85619. _currentSize1: number;
  85620. /** @hidden */
  85621. _currentSize2: number;
  85622. /** @hidden */
  85623. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85624. /** @hidden */
  85625. _currentAngularSpeed1: number;
  85626. /** @hidden */
  85627. _currentAngularSpeed2: number;
  85628. /** @hidden */
  85629. _currentVelocityGradient: Nullable<FactorGradient>;
  85630. /** @hidden */
  85631. _currentVelocity1: number;
  85632. /** @hidden */
  85633. _currentVelocity2: number;
  85634. /** @hidden */
  85635. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85636. /** @hidden */
  85637. _currentLimitVelocity1: number;
  85638. /** @hidden */
  85639. _currentLimitVelocity2: number;
  85640. /** @hidden */
  85641. _currentDragGradient: Nullable<FactorGradient>;
  85642. /** @hidden */
  85643. _currentDrag1: number;
  85644. /** @hidden */
  85645. _currentDrag2: number;
  85646. /** @hidden */
  85647. _randomNoiseCoordinates1: Vector3;
  85648. /** @hidden */
  85649. _randomNoiseCoordinates2: Vector3;
  85650. /**
  85651. * Creates a new instance Particle
  85652. * @param particleSystem the particle system the particle belongs to
  85653. */
  85654. constructor(
  85655. /**
  85656. * The particle system the particle belongs to.
  85657. */
  85658. particleSystem: ParticleSystem);
  85659. private updateCellInfoFromSystem;
  85660. /**
  85661. * Defines how the sprite cell index is updated for the particle
  85662. */
  85663. updateCellIndex(): void;
  85664. /** @hidden */
  85665. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85666. /** @hidden */
  85667. _inheritParticleInfoToSubEmitters(): void;
  85668. /** @hidden */
  85669. _reset(): void;
  85670. /**
  85671. * Copy the properties of particle to another one.
  85672. * @param other the particle to copy the information to.
  85673. */
  85674. copyTo(other: Particle): void;
  85675. }
  85676. }
  85677. declare module BABYLON {
  85678. /**
  85679. * Particle emitter represents a volume emitting particles.
  85680. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85681. */
  85682. export interface IParticleEmitterType {
  85683. /**
  85684. * Called by the particle System when the direction is computed for the created particle.
  85685. * @param worldMatrix is the world matrix of the particle system
  85686. * @param directionToUpdate is the direction vector to update with the result
  85687. * @param particle is the particle we are computed the direction for
  85688. */
  85689. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85690. /**
  85691. * Called by the particle System when the position is computed for the created particle.
  85692. * @param worldMatrix is the world matrix of the particle system
  85693. * @param positionToUpdate is the position vector to update with the result
  85694. * @param particle is the particle we are computed the position for
  85695. */
  85696. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85697. /**
  85698. * Clones the current emitter and returns a copy of it
  85699. * @returns the new emitter
  85700. */
  85701. clone(): IParticleEmitterType;
  85702. /**
  85703. * Called by the GPUParticleSystem to setup the update shader
  85704. * @param effect defines the update shader
  85705. */
  85706. applyToShader(effect: Effect): void;
  85707. /**
  85708. * Returns a string to use to update the GPU particles update shader
  85709. * @returns the effect defines string
  85710. */
  85711. getEffectDefines(): string;
  85712. /**
  85713. * Returns a string representing the class name
  85714. * @returns a string containing the class name
  85715. */
  85716. getClassName(): string;
  85717. /**
  85718. * Serializes the particle system to a JSON object.
  85719. * @returns the JSON object
  85720. */
  85721. serialize(): any;
  85722. /**
  85723. * Parse properties from a JSON object
  85724. * @param serializationObject defines the JSON object
  85725. */
  85726. parse(serializationObject: any): void;
  85727. }
  85728. }
  85729. declare module BABYLON {
  85730. /**
  85731. * Particle emitter emitting particles from the inside of a box.
  85732. * It emits the particles randomly between 2 given directions.
  85733. */
  85734. export class BoxParticleEmitter implements IParticleEmitterType {
  85735. /**
  85736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85737. */
  85738. direction1: Vector3;
  85739. /**
  85740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85741. */
  85742. direction2: Vector3;
  85743. /**
  85744. * 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.
  85745. */
  85746. minEmitBox: Vector3;
  85747. /**
  85748. * 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.
  85749. */
  85750. maxEmitBox: Vector3;
  85751. /**
  85752. * Creates a new instance BoxParticleEmitter
  85753. */
  85754. constructor();
  85755. /**
  85756. * Called by the particle System when the direction is computed for the created particle.
  85757. * @param worldMatrix is the world matrix of the particle system
  85758. * @param directionToUpdate is the direction vector to update with the result
  85759. * @param particle is the particle we are computed the direction for
  85760. */
  85761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85762. /**
  85763. * Called by the particle System when the position is computed for the created particle.
  85764. * @param worldMatrix is the world matrix of the particle system
  85765. * @param positionToUpdate is the position vector to update with the result
  85766. * @param particle is the particle we are computed the position for
  85767. */
  85768. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85769. /**
  85770. * Clones the current emitter and returns a copy of it
  85771. * @returns the new emitter
  85772. */
  85773. clone(): BoxParticleEmitter;
  85774. /**
  85775. * Called by the GPUParticleSystem to setup the update shader
  85776. * @param effect defines the update shader
  85777. */
  85778. applyToShader(effect: Effect): void;
  85779. /**
  85780. * Returns a string to use to update the GPU particles update shader
  85781. * @returns a string containng the defines string
  85782. */
  85783. getEffectDefines(): string;
  85784. /**
  85785. * Returns the string "BoxParticleEmitter"
  85786. * @returns a string containing the class name
  85787. */
  85788. getClassName(): string;
  85789. /**
  85790. * Serializes the particle system to a JSON object.
  85791. * @returns the JSON object
  85792. */
  85793. serialize(): any;
  85794. /**
  85795. * Parse properties from a JSON object
  85796. * @param serializationObject defines the JSON object
  85797. */
  85798. parse(serializationObject: any): void;
  85799. }
  85800. }
  85801. declare module BABYLON {
  85802. /**
  85803. * Particle emitter emitting particles from the inside of a cone.
  85804. * It emits the particles alongside the cone volume from the base to the particle.
  85805. * The emission direction might be randomized.
  85806. */
  85807. export class ConeParticleEmitter implements IParticleEmitterType {
  85808. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85809. directionRandomizer: number;
  85810. private _radius;
  85811. private _angle;
  85812. private _height;
  85813. /**
  85814. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85815. */
  85816. radiusRange: number;
  85817. /**
  85818. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85819. */
  85820. heightRange: number;
  85821. /**
  85822. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85823. */
  85824. emitFromSpawnPointOnly: boolean;
  85825. /**
  85826. * Gets or sets the radius of the emission cone
  85827. */
  85828. radius: number;
  85829. /**
  85830. * Gets or sets the angle of the emission cone
  85831. */
  85832. angle: number;
  85833. private _buildHeight;
  85834. /**
  85835. * Creates a new instance ConeParticleEmitter
  85836. * @param radius the radius of the emission cone (1 by default)
  85837. * @param angle the cone base angle (PI by default)
  85838. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85839. */
  85840. constructor(radius?: number, angle?: number,
  85841. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85842. directionRandomizer?: number);
  85843. /**
  85844. * Called by the particle System when the direction is computed for the created particle.
  85845. * @param worldMatrix is the world matrix of the particle system
  85846. * @param directionToUpdate is the direction vector to update with the result
  85847. * @param particle is the particle we are computed the direction for
  85848. */
  85849. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85850. /**
  85851. * Called by the particle System when the position is computed for the created particle.
  85852. * @param worldMatrix is the world matrix of the particle system
  85853. * @param positionToUpdate is the position vector to update with the result
  85854. * @param particle is the particle we are computed the position for
  85855. */
  85856. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85857. /**
  85858. * Clones the current emitter and returns a copy of it
  85859. * @returns the new emitter
  85860. */
  85861. clone(): ConeParticleEmitter;
  85862. /**
  85863. * Called by the GPUParticleSystem to setup the update shader
  85864. * @param effect defines the update shader
  85865. */
  85866. applyToShader(effect: Effect): void;
  85867. /**
  85868. * Returns a string to use to update the GPU particles update shader
  85869. * @returns a string containng the defines string
  85870. */
  85871. getEffectDefines(): string;
  85872. /**
  85873. * Returns the string "ConeParticleEmitter"
  85874. * @returns a string containing the class name
  85875. */
  85876. getClassName(): string;
  85877. /**
  85878. * Serializes the particle system to a JSON object.
  85879. * @returns the JSON object
  85880. */
  85881. serialize(): any;
  85882. /**
  85883. * Parse properties from a JSON object
  85884. * @param serializationObject defines the JSON object
  85885. */
  85886. parse(serializationObject: any): void;
  85887. }
  85888. }
  85889. declare module BABYLON {
  85890. /**
  85891. * Particle emitter emitting particles from the inside of a cylinder.
  85892. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85893. */
  85894. export class CylinderParticleEmitter implements IParticleEmitterType {
  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. * Creates a new instance CylinderParticleEmitter
  85913. * @param radius the radius of the emission cylinder (1 by default)
  85914. * @param height the height of the emission cylinder (1 by default)
  85915. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85916. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85917. */
  85918. constructor(
  85919. /**
  85920. * The radius of the emission cylinder.
  85921. */
  85922. radius?: number,
  85923. /**
  85924. * The height of the emission cylinder.
  85925. */
  85926. height?: number,
  85927. /**
  85928. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85929. */
  85930. radiusRange?: number,
  85931. /**
  85932. * How much to randomize the particle direction [0-1].
  85933. */
  85934. directionRandomizer?: number);
  85935. /**
  85936. * Called by the particle System when the direction is computed for the created particle.
  85937. * @param worldMatrix is the world matrix of the particle system
  85938. * @param directionToUpdate is the direction vector to update with the result
  85939. * @param particle is the particle we are computed the direction for
  85940. */
  85941. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85942. /**
  85943. * Called by the particle System when the position is computed for the created particle.
  85944. * @param worldMatrix is the world matrix of the particle system
  85945. * @param positionToUpdate is the position vector to update with the result
  85946. * @param particle is the particle we are computed the position for
  85947. */
  85948. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85949. /**
  85950. * Clones the current emitter and returns a copy of it
  85951. * @returns the new emitter
  85952. */
  85953. clone(): CylinderParticleEmitter;
  85954. /**
  85955. * Called by the GPUParticleSystem to setup the update shader
  85956. * @param effect defines the update shader
  85957. */
  85958. applyToShader(effect: Effect): void;
  85959. /**
  85960. * Returns a string to use to update the GPU particles update shader
  85961. * @returns a string containng the defines string
  85962. */
  85963. getEffectDefines(): string;
  85964. /**
  85965. * Returns the string "CylinderParticleEmitter"
  85966. * @returns a string containing the class name
  85967. */
  85968. getClassName(): string;
  85969. /**
  85970. * Serializes the particle system to a JSON object.
  85971. * @returns the JSON object
  85972. */
  85973. serialize(): any;
  85974. /**
  85975. * Parse properties from a JSON object
  85976. * @param serializationObject defines the JSON object
  85977. */
  85978. parse(serializationObject: any): void;
  85979. }
  85980. /**
  85981. * Particle emitter emitting particles from the inside of a cylinder.
  85982. * It emits the particles randomly between two vectors.
  85983. */
  85984. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85985. /**
  85986. * The min limit of the emission direction.
  85987. */
  85988. direction1: Vector3;
  85989. /**
  85990. * The max limit of the emission direction.
  85991. */
  85992. direction2: Vector3;
  85993. /**
  85994. * Creates a new instance CylinderDirectedParticleEmitter
  85995. * @param radius the radius of the emission cylinder (1 by default)
  85996. * @param height the height of the emission cylinder (1 by default)
  85997. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85998. * @param direction1 the min limit of the emission direction (up vector by default)
  85999. * @param direction2 the max limit of the emission direction (up vector by default)
  86000. */
  86001. constructor(radius?: number, height?: number, radiusRange?: number,
  86002. /**
  86003. * The min limit of the emission direction.
  86004. */
  86005. direction1?: Vector3,
  86006. /**
  86007. * The max limit of the emission direction.
  86008. */
  86009. direction2?: Vector3);
  86010. /**
  86011. * Called by the particle System when the direction is computed for the created particle.
  86012. * @param worldMatrix is the world matrix of the particle system
  86013. * @param directionToUpdate is the direction vector to update with the result
  86014. * @param particle is the particle we are computed the direction for
  86015. */
  86016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86017. /**
  86018. * Clones the current emitter and returns a copy of it
  86019. * @returns the new emitter
  86020. */
  86021. clone(): CylinderDirectedParticleEmitter;
  86022. /**
  86023. * Called by the GPUParticleSystem to setup the update shader
  86024. * @param effect defines the update shader
  86025. */
  86026. applyToShader(effect: Effect): void;
  86027. /**
  86028. * Returns a string to use to update the GPU particles update shader
  86029. * @returns a string containng the defines string
  86030. */
  86031. getEffectDefines(): string;
  86032. /**
  86033. * Returns the string "CylinderDirectedParticleEmitter"
  86034. * @returns a string containing the class name
  86035. */
  86036. getClassName(): string;
  86037. /**
  86038. * Serializes the particle system to a JSON object.
  86039. * @returns the JSON object
  86040. */
  86041. serialize(): any;
  86042. /**
  86043. * Parse properties from a JSON object
  86044. * @param serializationObject defines the JSON object
  86045. */
  86046. parse(serializationObject: any): void;
  86047. }
  86048. }
  86049. declare module BABYLON {
  86050. /**
  86051. * Particle emitter emitting particles from the inside of a hemisphere.
  86052. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86053. */
  86054. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86055. /**
  86056. * The radius of the emission hemisphere.
  86057. */
  86058. radius: number;
  86059. /**
  86060. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86061. */
  86062. radiusRange: number;
  86063. /**
  86064. * How much to randomize the particle direction [0-1].
  86065. */
  86066. directionRandomizer: number;
  86067. /**
  86068. * Creates a new instance HemisphericParticleEmitter
  86069. * @param radius the radius of the emission hemisphere (1 by default)
  86070. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86071. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86072. */
  86073. constructor(
  86074. /**
  86075. * The radius of the emission hemisphere.
  86076. */
  86077. radius?: number,
  86078. /**
  86079. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86080. */
  86081. radiusRange?: number,
  86082. /**
  86083. * How much to randomize the particle direction [0-1].
  86084. */
  86085. directionRandomizer?: number);
  86086. /**
  86087. * Called by the particle System when the direction is computed for the created particle.
  86088. * @param worldMatrix is the world matrix of the particle system
  86089. * @param directionToUpdate is the direction vector to update with the result
  86090. * @param particle is the particle we are computed the direction for
  86091. */
  86092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86093. /**
  86094. * Called by the particle System when the position is computed for the created particle.
  86095. * @param worldMatrix is the world matrix of the particle system
  86096. * @param positionToUpdate is the position vector to update with the result
  86097. * @param particle is the particle we are computed the position for
  86098. */
  86099. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86100. /**
  86101. * Clones the current emitter and returns a copy of it
  86102. * @returns the new emitter
  86103. */
  86104. clone(): HemisphericParticleEmitter;
  86105. /**
  86106. * Called by the GPUParticleSystem to setup the update shader
  86107. * @param effect defines the update shader
  86108. */
  86109. applyToShader(effect: Effect): void;
  86110. /**
  86111. * Returns a string to use to update the GPU particles update shader
  86112. * @returns a string containng the defines string
  86113. */
  86114. getEffectDefines(): string;
  86115. /**
  86116. * Returns the string "HemisphericParticleEmitter"
  86117. * @returns a string containing the class name
  86118. */
  86119. getClassName(): string;
  86120. /**
  86121. * Serializes the particle system to a JSON object.
  86122. * @returns the JSON object
  86123. */
  86124. serialize(): any;
  86125. /**
  86126. * Parse properties from a JSON object
  86127. * @param serializationObject defines the JSON object
  86128. */
  86129. parse(serializationObject: any): void;
  86130. }
  86131. }
  86132. declare module BABYLON {
  86133. /**
  86134. * Particle emitter emitting particles from a point.
  86135. * It emits the particles randomly between 2 given directions.
  86136. */
  86137. export class PointParticleEmitter implements IParticleEmitterType {
  86138. /**
  86139. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86140. */
  86141. direction1: Vector3;
  86142. /**
  86143. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86144. */
  86145. direction2: Vector3;
  86146. /**
  86147. * Creates a new instance PointParticleEmitter
  86148. */
  86149. constructor();
  86150. /**
  86151. * Called by the particle System when the direction is computed for the created particle.
  86152. * @param worldMatrix is the world matrix of the particle system
  86153. * @param directionToUpdate is the direction vector to update with the result
  86154. * @param particle is the particle we are computed the direction for
  86155. */
  86156. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86157. /**
  86158. * Called by the particle System when the position is computed for the created particle.
  86159. * @param worldMatrix is the world matrix of the particle system
  86160. * @param positionToUpdate is the position vector to update with the result
  86161. * @param particle is the particle we are computed the position for
  86162. */
  86163. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86164. /**
  86165. * Clones the current emitter and returns a copy of it
  86166. * @returns the new emitter
  86167. */
  86168. clone(): PointParticleEmitter;
  86169. /**
  86170. * Called by the GPUParticleSystem to setup the update shader
  86171. * @param effect defines the update shader
  86172. */
  86173. applyToShader(effect: Effect): void;
  86174. /**
  86175. * Returns a string to use to update the GPU particles update shader
  86176. * @returns a string containng the defines string
  86177. */
  86178. getEffectDefines(): string;
  86179. /**
  86180. * Returns the string "PointParticleEmitter"
  86181. * @returns a string containing the class name
  86182. */
  86183. getClassName(): string;
  86184. /**
  86185. * Serializes the particle system to a JSON object.
  86186. * @returns the JSON object
  86187. */
  86188. serialize(): any;
  86189. /**
  86190. * Parse properties from a JSON object
  86191. * @param serializationObject defines the JSON object
  86192. */
  86193. parse(serializationObject: any): void;
  86194. }
  86195. }
  86196. declare module BABYLON {
  86197. /**
  86198. * Particle emitter emitting particles from the inside of a sphere.
  86199. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86200. */
  86201. export class SphereParticleEmitter implements IParticleEmitterType {
  86202. /**
  86203. * The radius of the emission sphere.
  86204. */
  86205. radius: number;
  86206. /**
  86207. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86208. */
  86209. radiusRange: number;
  86210. /**
  86211. * How much to randomize the particle direction [0-1].
  86212. */
  86213. directionRandomizer: number;
  86214. /**
  86215. * Creates a new instance SphereParticleEmitter
  86216. * @param radius the radius of the emission sphere (1 by default)
  86217. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86218. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86219. */
  86220. constructor(
  86221. /**
  86222. * The radius of the emission sphere.
  86223. */
  86224. radius?: number,
  86225. /**
  86226. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86227. */
  86228. radiusRange?: number,
  86229. /**
  86230. * How much to randomize the particle direction [0-1].
  86231. */
  86232. directionRandomizer?: number);
  86233. /**
  86234. * Called by the particle System when the direction is computed for the created particle.
  86235. * @param worldMatrix is the world matrix of the particle system
  86236. * @param directionToUpdate is the direction vector to update with the result
  86237. * @param particle is the particle we are computed the direction for
  86238. */
  86239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86240. /**
  86241. * Called by the particle System when the position is computed for the created particle.
  86242. * @param worldMatrix is the world matrix of the particle system
  86243. * @param positionToUpdate is the position vector to update with the result
  86244. * @param particle is the particle we are computed the position for
  86245. */
  86246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86247. /**
  86248. * Clones the current emitter and returns a copy of it
  86249. * @returns the new emitter
  86250. */
  86251. clone(): SphereParticleEmitter;
  86252. /**
  86253. * Called by the GPUParticleSystem to setup the update shader
  86254. * @param effect defines the update shader
  86255. */
  86256. applyToShader(effect: Effect): void;
  86257. /**
  86258. * Returns a string to use to update the GPU particles update shader
  86259. * @returns a string containng the defines string
  86260. */
  86261. getEffectDefines(): string;
  86262. /**
  86263. * Returns the string "SphereParticleEmitter"
  86264. * @returns a string containing the class name
  86265. */
  86266. getClassName(): string;
  86267. /**
  86268. * Serializes the particle system to a JSON object.
  86269. * @returns the JSON object
  86270. */
  86271. serialize(): any;
  86272. /**
  86273. * Parse properties from a JSON object
  86274. * @param serializationObject defines the JSON object
  86275. */
  86276. parse(serializationObject: any): void;
  86277. }
  86278. /**
  86279. * Particle emitter emitting particles from the inside of a sphere.
  86280. * It emits the particles randomly between two vectors.
  86281. */
  86282. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86283. /**
  86284. * The min limit of the emission direction.
  86285. */
  86286. direction1: Vector3;
  86287. /**
  86288. * The max limit of the emission direction.
  86289. */
  86290. direction2: Vector3;
  86291. /**
  86292. * Creates a new instance SphereDirectedParticleEmitter
  86293. * @param radius the radius of the emission sphere (1 by default)
  86294. * @param direction1 the min limit of the emission direction (up vector by default)
  86295. * @param direction2 the max limit of the emission direction (up vector by default)
  86296. */
  86297. constructor(radius?: number,
  86298. /**
  86299. * The min limit of the emission direction.
  86300. */
  86301. direction1?: Vector3,
  86302. /**
  86303. * The max limit of the emission direction.
  86304. */
  86305. direction2?: Vector3);
  86306. /**
  86307. * Called by the particle System when the direction is computed for the created particle.
  86308. * @param worldMatrix is the world matrix of the particle system
  86309. * @param directionToUpdate is the direction vector to update with the result
  86310. * @param particle is the particle we are computed the direction for
  86311. */
  86312. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86313. /**
  86314. * Clones the current emitter and returns a copy of it
  86315. * @returns the new emitter
  86316. */
  86317. clone(): SphereDirectedParticleEmitter;
  86318. /**
  86319. * Called by the GPUParticleSystem to setup the update shader
  86320. * @param effect defines the update shader
  86321. */
  86322. applyToShader(effect: Effect): void;
  86323. /**
  86324. * Returns a string to use to update the GPU particles update shader
  86325. * @returns a string containng the defines string
  86326. */
  86327. getEffectDefines(): string;
  86328. /**
  86329. * Returns the string "SphereDirectedParticleEmitter"
  86330. * @returns a string containing the class name
  86331. */
  86332. getClassName(): string;
  86333. /**
  86334. * Serializes the particle system to a JSON object.
  86335. * @returns the JSON object
  86336. */
  86337. serialize(): any;
  86338. /**
  86339. * Parse properties from a JSON object
  86340. * @param serializationObject defines the JSON object
  86341. */
  86342. parse(serializationObject: any): void;
  86343. }
  86344. }
  86345. declare module BABYLON {
  86346. /**
  86347. * Interface representing a particle system in Babylon.js.
  86348. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86349. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86350. */
  86351. export interface IParticleSystem {
  86352. /**
  86353. * List of animations used by the particle system.
  86354. */
  86355. animations: Animation[];
  86356. /**
  86357. * The id of the Particle system.
  86358. */
  86359. id: string;
  86360. /**
  86361. * The name of the Particle system.
  86362. */
  86363. name: string;
  86364. /**
  86365. * The emitter represents the Mesh or position we are attaching the particle system to.
  86366. */
  86367. emitter: Nullable<AbstractMesh | Vector3>;
  86368. /**
  86369. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86370. */
  86371. isBillboardBased: boolean;
  86372. /**
  86373. * The rendering group used by the Particle system to chose when to render.
  86374. */
  86375. renderingGroupId: number;
  86376. /**
  86377. * The layer mask we are rendering the particles through.
  86378. */
  86379. layerMask: number;
  86380. /**
  86381. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86382. */
  86383. updateSpeed: number;
  86384. /**
  86385. * The amount of time the particle system is running (depends of the overall update speed).
  86386. */
  86387. targetStopDuration: number;
  86388. /**
  86389. * The texture used to render each particle. (this can be a spritesheet)
  86390. */
  86391. particleTexture: Nullable<Texture>;
  86392. /**
  86393. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86394. */
  86395. blendMode: number;
  86396. /**
  86397. * Minimum life time of emitting particles.
  86398. */
  86399. minLifeTime: number;
  86400. /**
  86401. * Maximum life time of emitting particles.
  86402. */
  86403. maxLifeTime: number;
  86404. /**
  86405. * Minimum Size of emitting particles.
  86406. */
  86407. minSize: number;
  86408. /**
  86409. * Maximum Size of emitting particles.
  86410. */
  86411. maxSize: number;
  86412. /**
  86413. * Minimum scale of emitting particles on X axis.
  86414. */
  86415. minScaleX: number;
  86416. /**
  86417. * Maximum scale of emitting particles on X axis.
  86418. */
  86419. maxScaleX: number;
  86420. /**
  86421. * Minimum scale of emitting particles on Y axis.
  86422. */
  86423. minScaleY: number;
  86424. /**
  86425. * Maximum scale of emitting particles on Y axis.
  86426. */
  86427. maxScaleY: number;
  86428. /**
  86429. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86430. */
  86431. color1: Color4;
  86432. /**
  86433. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86434. */
  86435. color2: Color4;
  86436. /**
  86437. * Color the particle will have at the end of its lifetime.
  86438. */
  86439. colorDead: Color4;
  86440. /**
  86441. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86442. */
  86443. emitRate: number;
  86444. /**
  86445. * You can use gravity if you want to give an orientation to your particles.
  86446. */
  86447. gravity: Vector3;
  86448. /**
  86449. * Minimum power of emitting particles.
  86450. */
  86451. minEmitPower: number;
  86452. /**
  86453. * Maximum power of emitting particles.
  86454. */
  86455. maxEmitPower: number;
  86456. /**
  86457. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86458. */
  86459. minAngularSpeed: number;
  86460. /**
  86461. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86462. */
  86463. maxAngularSpeed: number;
  86464. /**
  86465. * Gets or sets the minimal initial rotation in radians.
  86466. */
  86467. minInitialRotation: number;
  86468. /**
  86469. * Gets or sets the maximal initial rotation in radians.
  86470. */
  86471. maxInitialRotation: number;
  86472. /**
  86473. * The particle emitter type defines the emitter used by the particle system.
  86474. * It can be for example box, sphere, or cone...
  86475. */
  86476. particleEmitterType: Nullable<IParticleEmitterType>;
  86477. /**
  86478. * Defines the delay in milliseconds before starting the system (0 by default)
  86479. */
  86480. startDelay: number;
  86481. /**
  86482. * 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
  86483. */
  86484. preWarmCycles: number;
  86485. /**
  86486. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86487. */
  86488. preWarmStepOffset: number;
  86489. /**
  86490. * 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)
  86491. */
  86492. spriteCellChangeSpeed: number;
  86493. /**
  86494. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86495. */
  86496. startSpriteCellID: number;
  86497. /**
  86498. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86499. */
  86500. endSpriteCellID: number;
  86501. /**
  86502. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86503. */
  86504. spriteCellWidth: number;
  86505. /**
  86506. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86507. */
  86508. spriteCellHeight: number;
  86509. /**
  86510. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86511. */
  86512. spriteRandomStartCell: boolean;
  86513. /**
  86514. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86515. */
  86516. isAnimationSheetEnabled: boolean;
  86517. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86518. translationPivot: Vector2;
  86519. /**
  86520. * Gets or sets a texture used to add random noise to particle positions
  86521. */
  86522. noiseTexture: Nullable<BaseTexture>;
  86523. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86524. noiseStrength: Vector3;
  86525. /**
  86526. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86527. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86528. */
  86529. billboardMode: number;
  86530. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86531. limitVelocityDamping: number;
  86532. /**
  86533. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86534. */
  86535. beginAnimationOnStart: boolean;
  86536. /**
  86537. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86538. */
  86539. beginAnimationFrom: number;
  86540. /**
  86541. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86542. */
  86543. beginAnimationTo: number;
  86544. /**
  86545. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86546. */
  86547. beginAnimationLoop: boolean;
  86548. /**
  86549. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86550. */
  86551. disposeOnStop: boolean;
  86552. /**
  86553. * Gets the maximum number of particles active at the same time.
  86554. * @returns The max number of active particles.
  86555. */
  86556. getCapacity(): number;
  86557. /**
  86558. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86559. * @returns True if it has been started, otherwise false.
  86560. */
  86561. isStarted(): boolean;
  86562. /**
  86563. * Animates the particle system for this frame.
  86564. */
  86565. animate(): void;
  86566. /**
  86567. * Renders the particle system in its current state.
  86568. * @returns the current number of particles
  86569. */
  86570. render(): number;
  86571. /**
  86572. * Dispose the particle system and frees its associated resources.
  86573. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86574. */
  86575. dispose(disposeTexture?: boolean): void;
  86576. /**
  86577. * Clones the particle system.
  86578. * @param name The name of the cloned object
  86579. * @param newEmitter The new emitter to use
  86580. * @returns the cloned particle system
  86581. */
  86582. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86583. /**
  86584. * Serializes the particle system to a JSON object.
  86585. * @returns the JSON object
  86586. */
  86587. serialize(): any;
  86588. /**
  86589. * Rebuild the particle system
  86590. */
  86591. rebuild(): void;
  86592. /**
  86593. * Starts the particle system and begins to emit
  86594. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86595. */
  86596. start(delay?: number): void;
  86597. /**
  86598. * Stops the particle system.
  86599. */
  86600. stop(): void;
  86601. /**
  86602. * Remove all active particles
  86603. */
  86604. reset(): void;
  86605. /**
  86606. * Is this system ready to be used/rendered
  86607. * @return true if the system is ready
  86608. */
  86609. isReady(): boolean;
  86610. /**
  86611. * Adds a new color gradient
  86612. * @param gradient defines the gradient to use (between 0 and 1)
  86613. * @param color1 defines the color to affect to the specified gradient
  86614. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86615. * @returns the current particle system
  86616. */
  86617. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86618. /**
  86619. * Remove a specific color gradient
  86620. * @param gradient defines the gradient to remove
  86621. * @returns the current particle system
  86622. */
  86623. removeColorGradient(gradient: number): IParticleSystem;
  86624. /**
  86625. * Adds a new size gradient
  86626. * @param gradient defines the gradient to use (between 0 and 1)
  86627. * @param factor defines the size factor to affect to the specified gradient
  86628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86629. * @returns the current particle system
  86630. */
  86631. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86632. /**
  86633. * Remove a specific size gradient
  86634. * @param gradient defines the gradient to remove
  86635. * @returns the current particle system
  86636. */
  86637. removeSizeGradient(gradient: number): IParticleSystem;
  86638. /**
  86639. * Gets the current list of color gradients.
  86640. * You must use addColorGradient and removeColorGradient to udpate this list
  86641. * @returns the list of color gradients
  86642. */
  86643. getColorGradients(): Nullable<Array<ColorGradient>>;
  86644. /**
  86645. * Gets the current list of size gradients.
  86646. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86647. * @returns the list of size gradients
  86648. */
  86649. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86650. /**
  86651. * Gets the current list of angular speed gradients.
  86652. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86653. * @returns the list of angular speed gradients
  86654. */
  86655. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86656. /**
  86657. * Adds a new angular speed gradient
  86658. * @param gradient defines the gradient to use (between 0 and 1)
  86659. * @param factor defines the angular speed to affect to the specified gradient
  86660. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86661. * @returns the current particle system
  86662. */
  86663. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86664. /**
  86665. * Remove a specific angular speed gradient
  86666. * @param gradient defines the gradient to remove
  86667. * @returns the current particle system
  86668. */
  86669. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86670. /**
  86671. * Gets the current list of velocity gradients.
  86672. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86673. * @returns the list of velocity gradients
  86674. */
  86675. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86676. /**
  86677. * Adds a new velocity gradient
  86678. * @param gradient defines the gradient to use (between 0 and 1)
  86679. * @param factor defines the velocity to affect to the specified gradient
  86680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86681. * @returns the current particle system
  86682. */
  86683. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86684. /**
  86685. * Remove a specific velocity gradient
  86686. * @param gradient defines the gradient to remove
  86687. * @returns the current particle system
  86688. */
  86689. removeVelocityGradient(gradient: number): IParticleSystem;
  86690. /**
  86691. * Gets the current list of limit velocity gradients.
  86692. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86693. * @returns the list of limit velocity gradients
  86694. */
  86695. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86696. /**
  86697. * Adds a new limit velocity gradient
  86698. * @param gradient defines the gradient to use (between 0 and 1)
  86699. * @param factor defines the limit velocity to affect to the specified gradient
  86700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86701. * @returns the current particle system
  86702. */
  86703. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86704. /**
  86705. * Remove a specific limit velocity gradient
  86706. * @param gradient defines the gradient to remove
  86707. * @returns the current particle system
  86708. */
  86709. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86710. /**
  86711. * Adds a new drag gradient
  86712. * @param gradient defines the gradient to use (between 0 and 1)
  86713. * @param factor defines the drag to affect to the specified gradient
  86714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86715. * @returns the current particle system
  86716. */
  86717. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86718. /**
  86719. * Remove a specific drag gradient
  86720. * @param gradient defines the gradient to remove
  86721. * @returns the current particle system
  86722. */
  86723. removeDragGradient(gradient: number): IParticleSystem;
  86724. /**
  86725. * Gets the current list of drag gradients.
  86726. * You must use addDragGradient and removeDragGradient to udpate this list
  86727. * @returns the list of drag gradients
  86728. */
  86729. getDragGradients(): Nullable<Array<FactorGradient>>;
  86730. /**
  86731. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86732. * @param gradient defines the gradient to use (between 0 and 1)
  86733. * @param factor defines the emit rate to affect to the specified gradient
  86734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86735. * @returns the current particle system
  86736. */
  86737. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86738. /**
  86739. * Remove a specific emit rate gradient
  86740. * @param gradient defines the gradient to remove
  86741. * @returns the current particle system
  86742. */
  86743. removeEmitRateGradient(gradient: number): IParticleSystem;
  86744. /**
  86745. * Gets the current list of emit rate gradients.
  86746. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86747. * @returns the list of emit rate gradients
  86748. */
  86749. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86750. /**
  86751. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86752. * @param gradient defines the gradient to use (between 0 and 1)
  86753. * @param factor defines the start size to affect to the specified gradient
  86754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86755. * @returns the current particle system
  86756. */
  86757. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86758. /**
  86759. * Remove a specific start size gradient
  86760. * @param gradient defines the gradient to remove
  86761. * @returns the current particle system
  86762. */
  86763. removeStartSizeGradient(gradient: number): IParticleSystem;
  86764. /**
  86765. * Gets the current list of start size gradients.
  86766. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86767. * @returns the list of start size gradients
  86768. */
  86769. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86770. /**
  86771. * Adds a new life time gradient
  86772. * @param gradient defines the gradient to use (between 0 and 1)
  86773. * @param factor defines the life time factor to affect to the specified gradient
  86774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86775. * @returns the current particle system
  86776. */
  86777. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86778. /**
  86779. * Remove a specific life time gradient
  86780. * @param gradient defines the gradient to remove
  86781. * @returns the current particle system
  86782. */
  86783. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86784. /**
  86785. * Gets the current list of life time gradients.
  86786. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86787. * @returns the list of life time gradients
  86788. */
  86789. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86790. /**
  86791. * Gets the current list of color gradients.
  86792. * You must use addColorGradient and removeColorGradient to udpate this list
  86793. * @returns the list of color gradients
  86794. */
  86795. getColorGradients(): Nullable<Array<ColorGradient>>;
  86796. /**
  86797. * Adds a new ramp gradient used to remap particle colors
  86798. * @param gradient defines the gradient to use (between 0 and 1)
  86799. * @param color defines the color to affect to the specified gradient
  86800. * @returns the current particle system
  86801. */
  86802. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86803. /**
  86804. * Gets the current list of ramp gradients.
  86805. * You must use addRampGradient and removeRampGradient to udpate this list
  86806. * @returns the list of ramp gradients
  86807. */
  86808. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86809. /** Gets or sets a boolean indicating that ramp gradients must be used
  86810. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86811. */
  86812. useRampGradients: boolean;
  86813. /**
  86814. * Adds a new color remap gradient
  86815. * @param gradient defines the gradient to use (between 0 and 1)
  86816. * @param min defines the color remap minimal range
  86817. * @param max defines the color remap maximal range
  86818. * @returns the current particle system
  86819. */
  86820. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86821. /**
  86822. * Gets the current list of color remap gradients.
  86823. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86824. * @returns the list of color remap gradients
  86825. */
  86826. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86827. /**
  86828. * Adds a new alpha remap gradient
  86829. * @param gradient defines the gradient to use (between 0 and 1)
  86830. * @param min defines the alpha remap minimal range
  86831. * @param max defines the alpha remap maximal range
  86832. * @returns the current particle system
  86833. */
  86834. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86835. /**
  86836. * Gets the current list of alpha remap gradients.
  86837. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86838. * @returns the list of alpha remap gradients
  86839. */
  86840. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86841. /**
  86842. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86843. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86844. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86845. * @returns the emitter
  86846. */
  86847. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86848. /**
  86849. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86850. * @param radius The radius of the hemisphere to emit from
  86851. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86852. * @returns the emitter
  86853. */
  86854. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86855. /**
  86856. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86857. * @param radius The radius of the sphere to emit from
  86858. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86859. * @returns the emitter
  86860. */
  86861. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86862. /**
  86863. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86864. * @param radius The radius of the sphere to emit from
  86865. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86866. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86867. * @returns the emitter
  86868. */
  86869. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86870. /**
  86871. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86872. * @param radius The radius of the emission cylinder
  86873. * @param height The height of the emission cylinder
  86874. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86875. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86876. * @returns the emitter
  86877. */
  86878. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86879. /**
  86880. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86881. * @param radius The radius of the cylinder to emit from
  86882. * @param height The height of the emission cylinder
  86883. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86884. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86885. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86886. * @returns the emitter
  86887. */
  86888. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86889. /**
  86890. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86891. * @param radius The radius of the cone to emit from
  86892. * @param angle The base angle of the cone
  86893. * @returns the emitter
  86894. */
  86895. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86896. /**
  86897. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86898. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86899. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86900. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86901. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86902. * @returns the emitter
  86903. */
  86904. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86905. /**
  86906. * Get hosting scene
  86907. * @returns the scene
  86908. */
  86909. getScene(): Scene;
  86910. }
  86911. }
  86912. declare module BABYLON {
  86913. /**
  86914. * Creates an instance based on a source mesh.
  86915. */
  86916. export class InstancedMesh extends AbstractMesh {
  86917. private _sourceMesh;
  86918. private _currentLOD;
  86919. /** @hidden */
  86920. _indexInSourceMeshInstanceArray: number;
  86921. constructor(name: string, source: Mesh);
  86922. /**
  86923. * Returns the string "InstancedMesh".
  86924. */
  86925. getClassName(): string;
  86926. /** Gets the list of lights affecting that mesh */
  86927. readonly lightSources: Light[];
  86928. _resyncLightSources(): void;
  86929. _resyncLighSource(light: Light): void;
  86930. _removeLightSource(light: Light, dispose: boolean): void;
  86931. /**
  86932. * If the source mesh receives shadows
  86933. */
  86934. readonly receiveShadows: boolean;
  86935. /**
  86936. * The material of the source mesh
  86937. */
  86938. readonly material: Nullable<Material>;
  86939. /**
  86940. * Visibility of the source mesh
  86941. */
  86942. readonly visibility: number;
  86943. /**
  86944. * Skeleton of the source mesh
  86945. */
  86946. readonly skeleton: Nullable<Skeleton>;
  86947. /**
  86948. * Rendering ground id of the source mesh
  86949. */
  86950. renderingGroupId: number;
  86951. /**
  86952. * Returns the total number of vertices (integer).
  86953. */
  86954. getTotalVertices(): number;
  86955. /**
  86956. * Returns a positive integer : the total number of indices in this mesh geometry.
  86957. * @returns the numner of indices or zero if the mesh has no geometry.
  86958. */
  86959. getTotalIndices(): number;
  86960. /**
  86961. * The source mesh of the instance
  86962. */
  86963. readonly sourceMesh: Mesh;
  86964. /**
  86965. * Is this node ready to be used/rendered
  86966. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86967. * @return {boolean} is it ready
  86968. */
  86969. isReady(completeCheck?: boolean): boolean;
  86970. /**
  86971. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86972. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86973. * @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.
  86974. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86975. */
  86976. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86977. /**
  86978. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86979. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86980. * The `data` are either a numeric array either a Float32Array.
  86981. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86982. * 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).
  86983. * Note that a new underlying VertexBuffer object is created each call.
  86984. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86985. *
  86986. * Possible `kind` values :
  86987. * - VertexBuffer.PositionKind
  86988. * - VertexBuffer.UVKind
  86989. * - VertexBuffer.UV2Kind
  86990. * - VertexBuffer.UV3Kind
  86991. * - VertexBuffer.UV4Kind
  86992. * - VertexBuffer.UV5Kind
  86993. * - VertexBuffer.UV6Kind
  86994. * - VertexBuffer.ColorKind
  86995. * - VertexBuffer.MatricesIndicesKind
  86996. * - VertexBuffer.MatricesIndicesExtraKind
  86997. * - VertexBuffer.MatricesWeightsKind
  86998. * - VertexBuffer.MatricesWeightsExtraKind
  86999. *
  87000. * Returns the Mesh.
  87001. */
  87002. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87003. /**
  87004. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87005. * If the mesh has no geometry, it is simply returned as it is.
  87006. * The `data` are either a numeric array either a Float32Array.
  87007. * No new underlying VertexBuffer object is created.
  87008. * 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.
  87009. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87010. *
  87011. * Possible `kind` values :
  87012. * - VertexBuffer.PositionKind
  87013. * - VertexBuffer.UVKind
  87014. * - VertexBuffer.UV2Kind
  87015. * - VertexBuffer.UV3Kind
  87016. * - VertexBuffer.UV4Kind
  87017. * - VertexBuffer.UV5Kind
  87018. * - VertexBuffer.UV6Kind
  87019. * - VertexBuffer.ColorKind
  87020. * - VertexBuffer.MatricesIndicesKind
  87021. * - VertexBuffer.MatricesIndicesExtraKind
  87022. * - VertexBuffer.MatricesWeightsKind
  87023. * - VertexBuffer.MatricesWeightsExtraKind
  87024. *
  87025. * Returns the Mesh.
  87026. */
  87027. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87028. /**
  87029. * Sets the mesh indices.
  87030. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87031. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87032. * This method creates a new index buffer each call.
  87033. * Returns the Mesh.
  87034. */
  87035. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87036. /**
  87037. * Boolean : True if the mesh owns the requested kind of data.
  87038. */
  87039. isVerticesDataPresent(kind: string): boolean;
  87040. /**
  87041. * Returns an array of indices (IndicesArray).
  87042. */
  87043. getIndices(): Nullable<IndicesArray>;
  87044. readonly _positions: Nullable<Vector3[]>;
  87045. /**
  87046. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87047. * This means the mesh underlying bounding box and sphere are recomputed.
  87048. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87049. * @returns the current mesh
  87050. */
  87051. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87052. /** @hidden */
  87053. _preActivate(): InstancedMesh;
  87054. /** @hidden */
  87055. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87056. /** @hidden */
  87057. _postActivate(): void;
  87058. getWorldMatrix(): Matrix;
  87059. readonly isAnInstance: boolean;
  87060. /**
  87061. * Returns the current associated LOD AbstractMesh.
  87062. */
  87063. getLOD(camera: Camera): AbstractMesh;
  87064. /** @hidden */
  87065. _syncSubMeshes(): InstancedMesh;
  87066. /** @hidden */
  87067. _generatePointsArray(): boolean;
  87068. /**
  87069. * Creates a new InstancedMesh from the current mesh.
  87070. * - name (string) : the cloned mesh name
  87071. * - newParent (optional Node) : the optional Node to parent the clone to.
  87072. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87073. *
  87074. * Returns the clone.
  87075. */
  87076. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87077. /**
  87078. * Disposes the InstancedMesh.
  87079. * Returns nothing.
  87080. */
  87081. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87082. }
  87083. interface Mesh {
  87084. /**
  87085. * Register a custom buffer that will be instanced
  87086. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87087. * @param kind defines the buffer kind
  87088. * @param stride defines the stride in floats
  87089. */
  87090. registerInstancedBuffer(kind: string, stride: number): void;
  87091. /** @hidden */
  87092. _userInstancedBuffersStorage: {
  87093. data: {
  87094. [key: string]: Float32Array;
  87095. };
  87096. sizes: {
  87097. [key: string]: number;
  87098. };
  87099. vertexBuffers: {
  87100. [key: string]: Nullable<VertexBuffer>;
  87101. };
  87102. strides: {
  87103. [key: string]: number;
  87104. };
  87105. };
  87106. }
  87107. interface AbstractMesh {
  87108. /**
  87109. * Object used to store instanced buffers defined by user
  87110. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87111. */
  87112. instancedBuffers: {
  87113. [key: string]: any;
  87114. };
  87115. }
  87116. }
  87117. declare module BABYLON {
  87118. /**
  87119. * Defines the options associated with the creation of a shader material.
  87120. */
  87121. export interface IShaderMaterialOptions {
  87122. /**
  87123. * Does the material work in alpha blend mode
  87124. */
  87125. needAlphaBlending: boolean;
  87126. /**
  87127. * Does the material work in alpha test mode
  87128. */
  87129. needAlphaTesting: boolean;
  87130. /**
  87131. * The list of attribute names used in the shader
  87132. */
  87133. attributes: string[];
  87134. /**
  87135. * The list of unifrom names used in the shader
  87136. */
  87137. uniforms: string[];
  87138. /**
  87139. * The list of UBO names used in the shader
  87140. */
  87141. uniformBuffers: string[];
  87142. /**
  87143. * The list of sampler names used in the shader
  87144. */
  87145. samplers: string[];
  87146. /**
  87147. * The list of defines used in the shader
  87148. */
  87149. defines: string[];
  87150. }
  87151. /**
  87152. * 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.
  87153. *
  87154. * This returned material effects how the mesh will look based on the code in the shaders.
  87155. *
  87156. * @see http://doc.babylonjs.com/how_to/shader_material
  87157. */
  87158. export class ShaderMaterial extends Material {
  87159. private _shaderPath;
  87160. private _options;
  87161. private _textures;
  87162. private _textureArrays;
  87163. private _floats;
  87164. private _ints;
  87165. private _floatsArrays;
  87166. private _colors3;
  87167. private _colors3Arrays;
  87168. private _colors4;
  87169. private _colors4Arrays;
  87170. private _vectors2;
  87171. private _vectors3;
  87172. private _vectors4;
  87173. private _matrices;
  87174. private _matrixArrays;
  87175. private _matrices3x3;
  87176. private _matrices2x2;
  87177. private _vectors2Arrays;
  87178. private _vectors3Arrays;
  87179. private _vectors4Arrays;
  87180. private _cachedWorldViewMatrix;
  87181. private _cachedWorldViewProjectionMatrix;
  87182. private _renderId;
  87183. /**
  87184. * Instantiate a new shader material.
  87185. * 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.
  87186. * This returned material effects how the mesh will look based on the code in the shaders.
  87187. * @see http://doc.babylonjs.com/how_to/shader_material
  87188. * @param name Define the name of the material in the scene
  87189. * @param scene Define the scene the material belongs to
  87190. * @param shaderPath Defines the route to the shader code in one of three ways:
  87191. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87192. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87193. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87194. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87195. * @param options Define the options used to create the shader
  87196. */
  87197. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87198. /**
  87199. * Gets the shader path used to define the shader code
  87200. * It can be modified to trigger a new compilation
  87201. */
  87202. /**
  87203. * Sets the shader path used to define the shader code
  87204. * It can be modified to trigger a new compilation
  87205. */
  87206. shaderPath: any;
  87207. /**
  87208. * Gets the options used to compile the shader.
  87209. * They can be modified to trigger a new compilation
  87210. */
  87211. readonly options: IShaderMaterialOptions;
  87212. /**
  87213. * Gets the current class name of the material e.g. "ShaderMaterial"
  87214. * Mainly use in serialization.
  87215. * @returns the class name
  87216. */
  87217. getClassName(): string;
  87218. /**
  87219. * Specifies if the material will require alpha blending
  87220. * @returns a boolean specifying if alpha blending is needed
  87221. */
  87222. needAlphaBlending(): boolean;
  87223. /**
  87224. * Specifies if this material should be rendered in alpha test mode
  87225. * @returns a boolean specifying if an alpha test is needed.
  87226. */
  87227. needAlphaTesting(): boolean;
  87228. private _checkUniform;
  87229. /**
  87230. * Set a texture in the shader.
  87231. * @param name Define the name of the uniform samplers as defined in the shader
  87232. * @param texture Define the texture to bind to this sampler
  87233. * @return the material itself allowing "fluent" like uniform updates
  87234. */
  87235. setTexture(name: string, texture: Texture): ShaderMaterial;
  87236. /**
  87237. * Set a texture array in the shader.
  87238. * @param name Define the name of the uniform sampler array as defined in the shader
  87239. * @param textures Define the list of textures to bind to this sampler
  87240. * @return the material itself allowing "fluent" like uniform updates
  87241. */
  87242. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87243. /**
  87244. * Set a float in the shader.
  87245. * @param name Define the name of the uniform as defined in the shader
  87246. * @param value Define the value to give to the uniform
  87247. * @return the material itself allowing "fluent" like uniform updates
  87248. */
  87249. setFloat(name: string, value: number): ShaderMaterial;
  87250. /**
  87251. * Set a int in the shader.
  87252. * @param name Define the name of the uniform as defined in the shader
  87253. * @param value Define the value to give to the uniform
  87254. * @return the material itself allowing "fluent" like uniform updates
  87255. */
  87256. setInt(name: string, value: number): ShaderMaterial;
  87257. /**
  87258. * Set an array of floats in the shader.
  87259. * @param name Define the name of the uniform as defined in the shader
  87260. * @param value Define the value to give to the uniform
  87261. * @return the material itself allowing "fluent" like uniform updates
  87262. */
  87263. setFloats(name: string, value: number[]): ShaderMaterial;
  87264. /**
  87265. * Set a vec3 in the shader from a Color3.
  87266. * @param name Define the name of the uniform as defined in the shader
  87267. * @param value Define the value to give to the uniform
  87268. * @return the material itself allowing "fluent" like uniform updates
  87269. */
  87270. setColor3(name: string, value: Color3): ShaderMaterial;
  87271. /**
  87272. * Set a vec3 array in the shader from a Color3 array.
  87273. * @param name Define the name of the uniform as defined in the shader
  87274. * @param value Define the value to give to the uniform
  87275. * @return the material itself allowing "fluent" like uniform updates
  87276. */
  87277. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87278. /**
  87279. * Set a vec4 in the shader from a Color4.
  87280. * @param name Define the name of the uniform as defined in the shader
  87281. * @param value Define the value to give to the uniform
  87282. * @return the material itself allowing "fluent" like uniform updates
  87283. */
  87284. setColor4(name: string, value: Color4): ShaderMaterial;
  87285. /**
  87286. * Set a vec4 array in the shader from a Color4 array.
  87287. * @param name Define the name of the uniform as defined in the shader
  87288. * @param value Define the value to give to the uniform
  87289. * @return the material itself allowing "fluent" like uniform updates
  87290. */
  87291. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87292. /**
  87293. * Set a vec2 in the shader from a Vector2.
  87294. * @param name Define the name of the uniform as defined in the shader
  87295. * @param value Define the value to give to the uniform
  87296. * @return the material itself allowing "fluent" like uniform updates
  87297. */
  87298. setVector2(name: string, value: Vector2): ShaderMaterial;
  87299. /**
  87300. * Set a vec3 in the shader from a Vector3.
  87301. * @param name Define the name of the uniform as defined in the shader
  87302. * @param value Define the value to give to the uniform
  87303. * @return the material itself allowing "fluent" like uniform updates
  87304. */
  87305. setVector3(name: string, value: Vector3): ShaderMaterial;
  87306. /**
  87307. * Set a vec4 in the shader from a Vector4.
  87308. * @param name Define the name of the uniform as defined in the shader
  87309. * @param value Define the value to give to the uniform
  87310. * @return the material itself allowing "fluent" like uniform updates
  87311. */
  87312. setVector4(name: string, value: Vector4): ShaderMaterial;
  87313. /**
  87314. * Set a mat4 in the shader from a Matrix.
  87315. * @param name Define the name of the uniform as defined in the shader
  87316. * @param value Define the value to give to the uniform
  87317. * @return the material itself allowing "fluent" like uniform updates
  87318. */
  87319. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87320. /**
  87321. * Set a float32Array in the shader from a matrix array.
  87322. * @param name Define the name of the uniform as defined in the shader
  87323. * @param value Define the value to give to the uniform
  87324. * @return the material itself allowing "fluent" like uniform updates
  87325. */
  87326. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87327. /**
  87328. * Set a mat3 in the shader from a Float32Array.
  87329. * @param name Define the name of the uniform as defined in the shader
  87330. * @param value Define the value to give to the uniform
  87331. * @return the material itself allowing "fluent" like uniform updates
  87332. */
  87333. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87334. /**
  87335. * Set a mat2 in the shader from a Float32Array.
  87336. * @param name Define the name of the uniform as defined in the shader
  87337. * @param value Define the value to give to the uniform
  87338. * @return the material itself allowing "fluent" like uniform updates
  87339. */
  87340. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87341. /**
  87342. * Set a vec2 array in the shader from a number array.
  87343. * @param name Define the name of the uniform as defined in the shader
  87344. * @param value Define the value to give to the uniform
  87345. * @return the material itself allowing "fluent" like uniform updates
  87346. */
  87347. setArray2(name: string, value: number[]): ShaderMaterial;
  87348. /**
  87349. * Set a vec3 array in the shader from a number array.
  87350. * @param name Define the name of the uniform as defined in the shader
  87351. * @param value Define the value to give to the uniform
  87352. * @return the material itself allowing "fluent" like uniform updates
  87353. */
  87354. setArray3(name: string, value: number[]): ShaderMaterial;
  87355. /**
  87356. * Set a vec4 array in the shader from a number array.
  87357. * @param name Define the name of the uniform as defined in the shader
  87358. * @param value Define the value to give to the uniform
  87359. * @return the material itself allowing "fluent" like uniform updates
  87360. */
  87361. setArray4(name: string, value: number[]): ShaderMaterial;
  87362. private _checkCache;
  87363. /**
  87364. * Specifies that the submesh is ready to be used
  87365. * @param mesh defines the mesh to check
  87366. * @param subMesh defines which submesh to check
  87367. * @param useInstances specifies that instances should be used
  87368. * @returns a boolean indicating that the submesh is ready or not
  87369. */
  87370. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87371. /**
  87372. * Checks if the material is ready to render the requested mesh
  87373. * @param mesh Define the mesh to render
  87374. * @param useInstances Define whether or not the material is used with instances
  87375. * @returns true if ready, otherwise false
  87376. */
  87377. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87378. /**
  87379. * Binds the world matrix to the material
  87380. * @param world defines the world transformation matrix
  87381. */
  87382. bindOnlyWorldMatrix(world: Matrix): void;
  87383. /**
  87384. * Binds the material to the mesh
  87385. * @param world defines the world transformation matrix
  87386. * @param mesh defines the mesh to bind the material to
  87387. */
  87388. bind(world: Matrix, mesh?: Mesh): void;
  87389. /**
  87390. * Gets the active textures from the material
  87391. * @returns an array of textures
  87392. */
  87393. getActiveTextures(): BaseTexture[];
  87394. /**
  87395. * Specifies if the material uses a texture
  87396. * @param texture defines the texture to check against the material
  87397. * @returns a boolean specifying if the material uses the texture
  87398. */
  87399. hasTexture(texture: BaseTexture): boolean;
  87400. /**
  87401. * Makes a duplicate of the material, and gives it a new name
  87402. * @param name defines the new name for the duplicated material
  87403. * @returns the cloned material
  87404. */
  87405. clone(name: string): ShaderMaterial;
  87406. /**
  87407. * Disposes the material
  87408. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87409. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87410. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87411. */
  87412. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87413. /**
  87414. * Serializes this material in a JSON representation
  87415. * @returns the serialized material object
  87416. */
  87417. serialize(): any;
  87418. /**
  87419. * Creates a shader material from parsed shader material data
  87420. * @param source defines the JSON represnetation of the material
  87421. * @param scene defines the hosting scene
  87422. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87423. * @returns a new material
  87424. */
  87425. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87426. }
  87427. }
  87428. declare module BABYLON {
  87429. /** @hidden */
  87430. export var colorPixelShader: {
  87431. name: string;
  87432. shader: string;
  87433. };
  87434. }
  87435. declare module BABYLON {
  87436. /** @hidden */
  87437. export var colorVertexShader: {
  87438. name: string;
  87439. shader: string;
  87440. };
  87441. }
  87442. declare module BABYLON {
  87443. /**
  87444. * Line mesh
  87445. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87446. */
  87447. export class LinesMesh extends Mesh {
  87448. /**
  87449. * If vertex color should be applied to the mesh
  87450. */
  87451. readonly useVertexColor?: boolean | undefined;
  87452. /**
  87453. * If vertex alpha should be applied to the mesh
  87454. */
  87455. readonly useVertexAlpha?: boolean | undefined;
  87456. /**
  87457. * Color of the line (Default: White)
  87458. */
  87459. color: Color3;
  87460. /**
  87461. * Alpha of the line (Default: 1)
  87462. */
  87463. alpha: number;
  87464. /**
  87465. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87466. * This margin is expressed in world space coordinates, so its value may vary.
  87467. * Default value is 0.1
  87468. */
  87469. intersectionThreshold: number;
  87470. private _colorShader;
  87471. private color4;
  87472. /**
  87473. * Creates a new LinesMesh
  87474. * @param name defines the name
  87475. * @param scene defines the hosting scene
  87476. * @param parent defines the parent mesh if any
  87477. * @param source defines the optional source LinesMesh used to clone data from
  87478. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87479. * When false, achieved by calling a clone(), also passing False.
  87480. * This will make creation of children, recursive.
  87481. * @param useVertexColor defines if this LinesMesh supports vertex color
  87482. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87483. */
  87484. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87485. /**
  87486. * If vertex color should be applied to the mesh
  87487. */
  87488. useVertexColor?: boolean | undefined,
  87489. /**
  87490. * If vertex alpha should be applied to the mesh
  87491. */
  87492. useVertexAlpha?: boolean | undefined);
  87493. private _addClipPlaneDefine;
  87494. private _removeClipPlaneDefine;
  87495. isReady(): boolean;
  87496. /**
  87497. * Returns the string "LineMesh"
  87498. */
  87499. getClassName(): string;
  87500. /**
  87501. * @hidden
  87502. */
  87503. /**
  87504. * @hidden
  87505. */
  87506. material: Material;
  87507. /**
  87508. * @hidden
  87509. */
  87510. readonly checkCollisions: boolean;
  87511. /** @hidden */
  87512. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87513. /** @hidden */
  87514. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87515. /**
  87516. * Disposes of the line mesh
  87517. * @param doNotRecurse If children should be disposed
  87518. */
  87519. dispose(doNotRecurse?: boolean): void;
  87520. /**
  87521. * Returns a new LineMesh object cloned from the current one.
  87522. */
  87523. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87524. /**
  87525. * Creates a new InstancedLinesMesh object from the mesh model.
  87526. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87527. * @param name defines the name of the new instance
  87528. * @returns a new InstancedLinesMesh
  87529. */
  87530. createInstance(name: string): InstancedLinesMesh;
  87531. }
  87532. /**
  87533. * Creates an instance based on a source LinesMesh
  87534. */
  87535. export class InstancedLinesMesh extends InstancedMesh {
  87536. /**
  87537. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87538. * This margin is expressed in world space coordinates, so its value may vary.
  87539. * Initilized with the intersectionThreshold value of the source LinesMesh
  87540. */
  87541. intersectionThreshold: number;
  87542. constructor(name: string, source: LinesMesh);
  87543. /**
  87544. * Returns the string "InstancedLinesMesh".
  87545. */
  87546. getClassName(): string;
  87547. }
  87548. }
  87549. declare module BABYLON {
  87550. /** @hidden */
  87551. export var linePixelShader: {
  87552. name: string;
  87553. shader: string;
  87554. };
  87555. }
  87556. declare module BABYLON {
  87557. /** @hidden */
  87558. export var lineVertexShader: {
  87559. name: string;
  87560. shader: string;
  87561. };
  87562. }
  87563. declare module BABYLON {
  87564. interface AbstractMesh {
  87565. /**
  87566. * Gets the edgesRenderer associated with the mesh
  87567. */
  87568. edgesRenderer: Nullable<EdgesRenderer>;
  87569. }
  87570. interface LinesMesh {
  87571. /**
  87572. * Enables the edge rendering mode on the mesh.
  87573. * This mode makes the mesh edges visible
  87574. * @param epsilon defines the maximal distance between two angles to detect a face
  87575. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87576. * @returns the currentAbstractMesh
  87577. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87578. */
  87579. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87580. }
  87581. interface InstancedLinesMesh {
  87582. /**
  87583. * Enables the edge rendering mode on the mesh.
  87584. * This mode makes the mesh edges visible
  87585. * @param epsilon defines the maximal distance between two angles to detect a face
  87586. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87587. * @returns the current InstancedLinesMesh
  87588. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87589. */
  87590. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87591. }
  87592. /**
  87593. * Defines the minimum contract an Edges renderer should follow.
  87594. */
  87595. export interface IEdgesRenderer extends IDisposable {
  87596. /**
  87597. * Gets or sets a boolean indicating if the edgesRenderer is active
  87598. */
  87599. isEnabled: boolean;
  87600. /**
  87601. * Renders the edges of the attached mesh,
  87602. */
  87603. render(): void;
  87604. /**
  87605. * Checks wether or not the edges renderer is ready to render.
  87606. * @return true if ready, otherwise false.
  87607. */
  87608. isReady(): boolean;
  87609. }
  87610. /**
  87611. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87612. */
  87613. export class EdgesRenderer implements IEdgesRenderer {
  87614. /**
  87615. * Define the size of the edges with an orthographic camera
  87616. */
  87617. edgesWidthScalerForOrthographic: number;
  87618. /**
  87619. * Define the size of the edges with a perspective camera
  87620. */
  87621. edgesWidthScalerForPerspective: number;
  87622. protected _source: AbstractMesh;
  87623. protected _linesPositions: number[];
  87624. protected _linesNormals: number[];
  87625. protected _linesIndices: number[];
  87626. protected _epsilon: number;
  87627. protected _indicesCount: number;
  87628. protected _lineShader: ShaderMaterial;
  87629. protected _ib: DataBuffer;
  87630. protected _buffers: {
  87631. [key: string]: Nullable<VertexBuffer>;
  87632. };
  87633. protected _checkVerticesInsteadOfIndices: boolean;
  87634. private _meshRebuildObserver;
  87635. private _meshDisposeObserver;
  87636. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87637. isEnabled: boolean;
  87638. /**
  87639. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87640. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87641. * @param source Mesh used to create edges
  87642. * @param epsilon sum of angles in adjacency to check for edge
  87643. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87644. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87645. */
  87646. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87647. protected _prepareRessources(): void;
  87648. /** @hidden */
  87649. _rebuild(): void;
  87650. /**
  87651. * Releases the required resources for the edges renderer
  87652. */
  87653. dispose(): void;
  87654. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87655. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87656. /**
  87657. * Checks if the pair of p0 and p1 is en edge
  87658. * @param faceIndex
  87659. * @param edge
  87660. * @param faceNormals
  87661. * @param p0
  87662. * @param p1
  87663. * @private
  87664. */
  87665. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87666. /**
  87667. * push line into the position, normal and index buffer
  87668. * @protected
  87669. */
  87670. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87671. /**
  87672. * Generates lines edges from adjacencjes
  87673. * @private
  87674. */
  87675. _generateEdgesLines(): void;
  87676. /**
  87677. * Checks wether or not the edges renderer is ready to render.
  87678. * @return true if ready, otherwise false.
  87679. */
  87680. isReady(): boolean;
  87681. /**
  87682. * Renders the edges of the attached mesh,
  87683. */
  87684. render(): void;
  87685. }
  87686. /**
  87687. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87688. */
  87689. export class LineEdgesRenderer extends EdgesRenderer {
  87690. /**
  87691. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87692. * @param source LineMesh used to generate edges
  87693. * @param epsilon not important (specified angle for edge detection)
  87694. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87695. */
  87696. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87697. /**
  87698. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87699. */
  87700. _generateEdgesLines(): void;
  87701. }
  87702. }
  87703. declare module BABYLON {
  87704. /**
  87705. * This represents the object necessary to create a rendering group.
  87706. * This is exclusively used and created by the rendering manager.
  87707. * To modify the behavior, you use the available helpers in your scene or meshes.
  87708. * @hidden
  87709. */
  87710. export class RenderingGroup {
  87711. index: number;
  87712. private static _zeroVector;
  87713. private _scene;
  87714. private _opaqueSubMeshes;
  87715. private _transparentSubMeshes;
  87716. private _alphaTestSubMeshes;
  87717. private _depthOnlySubMeshes;
  87718. private _particleSystems;
  87719. private _spriteManagers;
  87720. private _opaqueSortCompareFn;
  87721. private _alphaTestSortCompareFn;
  87722. private _transparentSortCompareFn;
  87723. private _renderOpaque;
  87724. private _renderAlphaTest;
  87725. private _renderTransparent;
  87726. /** @hidden */
  87727. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87728. onBeforeTransparentRendering: () => void;
  87729. /**
  87730. * Set the opaque sort comparison function.
  87731. * If null the sub meshes will be render in the order they were created
  87732. */
  87733. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87734. /**
  87735. * Set the alpha test sort comparison function.
  87736. * If null the sub meshes will be render in the order they were created
  87737. */
  87738. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87739. /**
  87740. * Set the transparent sort comparison function.
  87741. * If null the sub meshes will be render in the order they were created
  87742. */
  87743. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87744. /**
  87745. * Creates a new rendering group.
  87746. * @param index The rendering group index
  87747. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87748. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87749. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87750. */
  87751. 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>);
  87752. /**
  87753. * Render all the sub meshes contained in the group.
  87754. * @param customRenderFunction Used to override the default render behaviour of the group.
  87755. * @returns true if rendered some submeshes.
  87756. */
  87757. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87758. /**
  87759. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87760. * @param subMeshes The submeshes to render
  87761. */
  87762. private renderOpaqueSorted;
  87763. /**
  87764. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87765. * @param subMeshes The submeshes to render
  87766. */
  87767. private renderAlphaTestSorted;
  87768. /**
  87769. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87770. * @param subMeshes The submeshes to render
  87771. */
  87772. private renderTransparentSorted;
  87773. /**
  87774. * Renders the submeshes in a specified order.
  87775. * @param subMeshes The submeshes to sort before render
  87776. * @param sortCompareFn The comparison function use to sort
  87777. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87778. * @param transparent Specifies to activate blending if true
  87779. */
  87780. private static renderSorted;
  87781. /**
  87782. * Renders the submeshes in the order they were dispatched (no sort applied).
  87783. * @param subMeshes The submeshes to render
  87784. */
  87785. private static renderUnsorted;
  87786. /**
  87787. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87788. * are rendered back to front if in the same alpha index.
  87789. *
  87790. * @param a The first submesh
  87791. * @param b The second submesh
  87792. * @returns The result of the comparison
  87793. */
  87794. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87795. /**
  87796. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87797. * are rendered back to front.
  87798. *
  87799. * @param a The first submesh
  87800. * @param b The second submesh
  87801. * @returns The result of the comparison
  87802. */
  87803. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87804. /**
  87805. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87806. * are rendered front to back (prevent overdraw).
  87807. *
  87808. * @param a The first submesh
  87809. * @param b The second submesh
  87810. * @returns The result of the comparison
  87811. */
  87812. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87813. /**
  87814. * Resets the different lists of submeshes to prepare a new frame.
  87815. */
  87816. prepare(): void;
  87817. dispose(): void;
  87818. /**
  87819. * Inserts the submesh in its correct queue depending on its material.
  87820. * @param subMesh The submesh to dispatch
  87821. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87822. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87823. */
  87824. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87825. dispatchSprites(spriteManager: ISpriteManager): void;
  87826. dispatchParticles(particleSystem: IParticleSystem): void;
  87827. private _renderParticles;
  87828. private _renderSprites;
  87829. }
  87830. }
  87831. declare module BABYLON {
  87832. /**
  87833. * Interface describing the different options available in the rendering manager
  87834. * regarding Auto Clear between groups.
  87835. */
  87836. export interface IRenderingManagerAutoClearSetup {
  87837. /**
  87838. * Defines whether or not autoclear is enable.
  87839. */
  87840. autoClear: boolean;
  87841. /**
  87842. * Defines whether or not to autoclear the depth buffer.
  87843. */
  87844. depth: boolean;
  87845. /**
  87846. * Defines whether or not to autoclear the stencil buffer.
  87847. */
  87848. stencil: boolean;
  87849. }
  87850. /**
  87851. * This class is used by the onRenderingGroupObservable
  87852. */
  87853. export class RenderingGroupInfo {
  87854. /**
  87855. * The Scene that being rendered
  87856. */
  87857. scene: Scene;
  87858. /**
  87859. * The camera currently used for the rendering pass
  87860. */
  87861. camera: Nullable<Camera>;
  87862. /**
  87863. * The ID of the renderingGroup being processed
  87864. */
  87865. renderingGroupId: number;
  87866. }
  87867. /**
  87868. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87869. * It is enable to manage the different groups as well as the different necessary sort functions.
  87870. * This should not be used directly aside of the few static configurations
  87871. */
  87872. export class RenderingManager {
  87873. /**
  87874. * The max id used for rendering groups (not included)
  87875. */
  87876. static MAX_RENDERINGGROUPS: number;
  87877. /**
  87878. * The min id used for rendering groups (included)
  87879. */
  87880. static MIN_RENDERINGGROUPS: number;
  87881. /**
  87882. * Used to globally prevent autoclearing scenes.
  87883. */
  87884. static AUTOCLEAR: boolean;
  87885. /**
  87886. * @hidden
  87887. */
  87888. _useSceneAutoClearSetup: boolean;
  87889. private _scene;
  87890. private _renderingGroups;
  87891. private _depthStencilBufferAlreadyCleaned;
  87892. private _autoClearDepthStencil;
  87893. private _customOpaqueSortCompareFn;
  87894. private _customAlphaTestSortCompareFn;
  87895. private _customTransparentSortCompareFn;
  87896. private _renderingGroupInfo;
  87897. /**
  87898. * Instantiates a new rendering group for a particular scene
  87899. * @param scene Defines the scene the groups belongs to
  87900. */
  87901. constructor(scene: Scene);
  87902. private _clearDepthStencilBuffer;
  87903. /**
  87904. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87905. * @hidden
  87906. */
  87907. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87908. /**
  87909. * Resets the different information of the group to prepare a new frame
  87910. * @hidden
  87911. */
  87912. reset(): void;
  87913. /**
  87914. * Dispose and release the group and its associated resources.
  87915. * @hidden
  87916. */
  87917. dispose(): void;
  87918. /**
  87919. * Clear the info related to rendering groups preventing retention points during dispose.
  87920. */
  87921. freeRenderingGroups(): void;
  87922. private _prepareRenderingGroup;
  87923. /**
  87924. * Add a sprite manager to the rendering manager in order to render it this frame.
  87925. * @param spriteManager Define the sprite manager to render
  87926. */
  87927. dispatchSprites(spriteManager: ISpriteManager): void;
  87928. /**
  87929. * Add a particle system to the rendering manager in order to render it this frame.
  87930. * @param particleSystem Define the particle system to render
  87931. */
  87932. dispatchParticles(particleSystem: IParticleSystem): void;
  87933. /**
  87934. * Add a submesh to the manager in order to render it this frame
  87935. * @param subMesh The submesh to dispatch
  87936. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87937. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87938. */
  87939. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87940. /**
  87941. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87942. * This allowed control for front to back rendering or reversly depending of the special needs.
  87943. *
  87944. * @param renderingGroupId The rendering group id corresponding to its index
  87945. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87946. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87947. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87948. */
  87949. 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;
  87950. /**
  87951. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87952. *
  87953. * @param renderingGroupId The rendering group id corresponding to its index
  87954. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87955. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87956. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87957. */
  87958. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87959. /**
  87960. * Gets the current auto clear configuration for one rendering group of the rendering
  87961. * manager.
  87962. * @param index the rendering group index to get the information for
  87963. * @returns The auto clear setup for the requested rendering group
  87964. */
  87965. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87966. }
  87967. }
  87968. declare module BABYLON {
  87969. /**
  87970. * This Helps creating a texture that will be created from a camera in your scene.
  87971. * It is basically a dynamic texture that could be used to create special effects for instance.
  87972. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87973. */
  87974. export class RenderTargetTexture extends Texture {
  87975. isCube: boolean;
  87976. /**
  87977. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87978. */
  87979. static readonly REFRESHRATE_RENDER_ONCE: number;
  87980. /**
  87981. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87982. */
  87983. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87984. /**
  87985. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87986. * the central point of your effect and can save a lot of performances.
  87987. */
  87988. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87989. /**
  87990. * Use this predicate to dynamically define the list of mesh you want to render.
  87991. * If set, the renderList property will be overwritten.
  87992. */
  87993. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87994. private _renderList;
  87995. /**
  87996. * Use this list to define the list of mesh you want to render.
  87997. */
  87998. renderList: Nullable<Array<AbstractMesh>>;
  87999. private _hookArray;
  88000. /**
  88001. * Define if particles should be rendered in your texture.
  88002. */
  88003. renderParticles: boolean;
  88004. /**
  88005. * Define if sprites should be rendered in your texture.
  88006. */
  88007. renderSprites: boolean;
  88008. /**
  88009. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88010. */
  88011. coordinatesMode: number;
  88012. /**
  88013. * Define the camera used to render the texture.
  88014. */
  88015. activeCamera: Nullable<Camera>;
  88016. /**
  88017. * Override the render function of the texture with your own one.
  88018. */
  88019. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88020. /**
  88021. * Define if camera post processes should be use while rendering the texture.
  88022. */
  88023. useCameraPostProcesses: boolean;
  88024. /**
  88025. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88026. */
  88027. ignoreCameraViewport: boolean;
  88028. private _postProcessManager;
  88029. private _postProcesses;
  88030. private _resizeObserver;
  88031. /**
  88032. * An event triggered when the texture is unbind.
  88033. */
  88034. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88035. /**
  88036. * An event triggered when the texture is unbind.
  88037. */
  88038. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88039. private _onAfterUnbindObserver;
  88040. /**
  88041. * Set a after unbind callback in the texture.
  88042. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88043. */
  88044. onAfterUnbind: () => void;
  88045. /**
  88046. * An event triggered before rendering the texture
  88047. */
  88048. onBeforeRenderObservable: Observable<number>;
  88049. private _onBeforeRenderObserver;
  88050. /**
  88051. * Set a before render callback in the texture.
  88052. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88053. */
  88054. onBeforeRender: (faceIndex: number) => void;
  88055. /**
  88056. * An event triggered after rendering the texture
  88057. */
  88058. onAfterRenderObservable: Observable<number>;
  88059. private _onAfterRenderObserver;
  88060. /**
  88061. * Set a after render callback in the texture.
  88062. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88063. */
  88064. onAfterRender: (faceIndex: number) => void;
  88065. /**
  88066. * An event triggered after the texture clear
  88067. */
  88068. onClearObservable: Observable<Engine>;
  88069. private _onClearObserver;
  88070. /**
  88071. * Set a clear callback in the texture.
  88072. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88073. */
  88074. onClear: (Engine: Engine) => void;
  88075. /**
  88076. * An event triggered when the texture is resized.
  88077. */
  88078. onResizeObservable: Observable<RenderTargetTexture>;
  88079. /**
  88080. * Define the clear color of the Render Target if it should be different from the scene.
  88081. */
  88082. clearColor: Color4;
  88083. protected _size: number | {
  88084. width: number;
  88085. height: number;
  88086. };
  88087. protected _initialSizeParameter: number | {
  88088. width: number;
  88089. height: number;
  88090. } | {
  88091. ratio: number;
  88092. };
  88093. protected _sizeRatio: Nullable<number>;
  88094. /** @hidden */
  88095. _generateMipMaps: boolean;
  88096. protected _renderingManager: RenderingManager;
  88097. /** @hidden */
  88098. _waitingRenderList: string[];
  88099. protected _doNotChangeAspectRatio: boolean;
  88100. protected _currentRefreshId: number;
  88101. protected _refreshRate: number;
  88102. protected _textureMatrix: Matrix;
  88103. protected _samples: number;
  88104. protected _renderTargetOptions: RenderTargetCreationOptions;
  88105. /**
  88106. * Gets render target creation options that were used.
  88107. */
  88108. readonly renderTargetOptions: RenderTargetCreationOptions;
  88109. protected _engine: Engine;
  88110. protected _onRatioRescale(): void;
  88111. /**
  88112. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88113. * It must define where the camera used to render the texture is set
  88114. */
  88115. boundingBoxPosition: Vector3;
  88116. private _boundingBoxSize;
  88117. /**
  88118. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88119. * When defined, the cubemap will switch to local mode
  88120. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88121. * @example https://www.babylonjs-playground.com/#RNASML
  88122. */
  88123. boundingBoxSize: Vector3;
  88124. /**
  88125. * In case the RTT has been created with a depth texture, get the associated
  88126. * depth texture.
  88127. * Otherwise, return null.
  88128. */
  88129. depthStencilTexture: Nullable<InternalTexture>;
  88130. /**
  88131. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88132. * or used a shadow, depth texture...
  88133. * @param name The friendly name of the texture
  88134. * @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)
  88135. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88136. * @param generateMipMaps True if mip maps need to be generated after render.
  88137. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88138. * @param type The type of the buffer in the RTT (int, half float, float...)
  88139. * @param isCube True if a cube texture needs to be created
  88140. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88141. * @param generateDepthBuffer True to generate a depth buffer
  88142. * @param generateStencilBuffer True to generate a stencil buffer
  88143. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88144. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88145. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88146. */
  88147. constructor(name: string, size: number | {
  88148. width: number;
  88149. height: number;
  88150. } | {
  88151. ratio: number;
  88152. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88153. /**
  88154. * Creates a depth stencil texture.
  88155. * This is only available in WebGL 2 or with the depth texture extension available.
  88156. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88157. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88158. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88159. */
  88160. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88161. private _processSizeParameter;
  88162. /**
  88163. * Define the number of samples to use in case of MSAA.
  88164. * It defaults to one meaning no MSAA has been enabled.
  88165. */
  88166. samples: number;
  88167. /**
  88168. * Resets the refresh counter of the texture and start bak from scratch.
  88169. * Could be useful to regenerate the texture if it is setup to render only once.
  88170. */
  88171. resetRefreshCounter(): void;
  88172. /**
  88173. * Define the refresh rate of the texture or the rendering frequency.
  88174. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88175. */
  88176. refreshRate: number;
  88177. /**
  88178. * Adds a post process to the render target rendering passes.
  88179. * @param postProcess define the post process to add
  88180. */
  88181. addPostProcess(postProcess: PostProcess): void;
  88182. /**
  88183. * Clear all the post processes attached to the render target
  88184. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88185. */
  88186. clearPostProcesses(dispose?: boolean): void;
  88187. /**
  88188. * Remove one of the post process from the list of attached post processes to the texture
  88189. * @param postProcess define the post process to remove from the list
  88190. */
  88191. removePostProcess(postProcess: PostProcess): void;
  88192. /** @hidden */
  88193. _shouldRender(): boolean;
  88194. /**
  88195. * Gets the actual render size of the texture.
  88196. * @returns the width of the render size
  88197. */
  88198. getRenderSize(): number;
  88199. /**
  88200. * Gets the actual render width of the texture.
  88201. * @returns the width of the render size
  88202. */
  88203. getRenderWidth(): number;
  88204. /**
  88205. * Gets the actual render height of the texture.
  88206. * @returns the height of the render size
  88207. */
  88208. getRenderHeight(): number;
  88209. /**
  88210. * Get if the texture can be rescaled or not.
  88211. */
  88212. readonly canRescale: boolean;
  88213. /**
  88214. * Resize the texture using a ratio.
  88215. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88216. */
  88217. scale(ratio: number): void;
  88218. /**
  88219. * Get the texture reflection matrix used to rotate/transform the reflection.
  88220. * @returns the reflection matrix
  88221. */
  88222. getReflectionTextureMatrix(): Matrix;
  88223. /**
  88224. * Resize the texture to a new desired size.
  88225. * Be carrefull as it will recreate all the data in the new texture.
  88226. * @param size Define the new size. It can be:
  88227. * - a number for squared texture,
  88228. * - an object containing { width: number, height: number }
  88229. * - or an object containing a ratio { ratio: number }
  88230. */
  88231. resize(size: number | {
  88232. width: number;
  88233. height: number;
  88234. } | {
  88235. ratio: number;
  88236. }): void;
  88237. /**
  88238. * Renders all the objects from the render list into the texture.
  88239. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88240. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88241. */
  88242. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88243. private _bestReflectionRenderTargetDimension;
  88244. /**
  88245. * @hidden
  88246. * @param faceIndex face index to bind to if this is a cubetexture
  88247. */
  88248. _bindFrameBuffer(faceIndex?: number): void;
  88249. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88250. private renderToTarget;
  88251. /**
  88252. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88253. * This allowed control for front to back rendering or reversly depending of the special needs.
  88254. *
  88255. * @param renderingGroupId The rendering group id corresponding to its index
  88256. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88257. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88258. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88259. */
  88260. 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;
  88261. /**
  88262. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88263. *
  88264. * @param renderingGroupId The rendering group id corresponding to its index
  88265. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88266. */
  88267. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88268. /**
  88269. * Clones the texture.
  88270. * @returns the cloned texture
  88271. */
  88272. clone(): RenderTargetTexture;
  88273. /**
  88274. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88275. * @returns The JSON representation of the texture
  88276. */
  88277. serialize(): any;
  88278. /**
  88279. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88280. */
  88281. disposeFramebufferObjects(): void;
  88282. /**
  88283. * Dispose the texture and release its associated resources.
  88284. */
  88285. dispose(): void;
  88286. /** @hidden */
  88287. _rebuild(): void;
  88288. /**
  88289. * Clear the info related to rendering groups preventing retention point in material dispose.
  88290. */
  88291. freeRenderingGroups(): void;
  88292. /**
  88293. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88294. * @returns the view count
  88295. */
  88296. getViewCount(): number;
  88297. }
  88298. }
  88299. declare module BABYLON {
  88300. /**
  88301. * Options for compiling materials.
  88302. */
  88303. export interface IMaterialCompilationOptions {
  88304. /**
  88305. * Defines whether clip planes are enabled.
  88306. */
  88307. clipPlane: boolean;
  88308. /**
  88309. * Defines whether instances are enabled.
  88310. */
  88311. useInstances: boolean;
  88312. }
  88313. /**
  88314. * Base class for the main features of a material in Babylon.js
  88315. */
  88316. export class Material implements IAnimatable {
  88317. /**
  88318. * Returns the triangle fill mode
  88319. */
  88320. static readonly TriangleFillMode: number;
  88321. /**
  88322. * Returns the wireframe mode
  88323. */
  88324. static readonly WireFrameFillMode: number;
  88325. /**
  88326. * Returns the point fill mode
  88327. */
  88328. static readonly PointFillMode: number;
  88329. /**
  88330. * Returns the point list draw mode
  88331. */
  88332. static readonly PointListDrawMode: number;
  88333. /**
  88334. * Returns the line list draw mode
  88335. */
  88336. static readonly LineListDrawMode: number;
  88337. /**
  88338. * Returns the line loop draw mode
  88339. */
  88340. static readonly LineLoopDrawMode: number;
  88341. /**
  88342. * Returns the line strip draw mode
  88343. */
  88344. static readonly LineStripDrawMode: number;
  88345. /**
  88346. * Returns the triangle strip draw mode
  88347. */
  88348. static readonly TriangleStripDrawMode: number;
  88349. /**
  88350. * Returns the triangle fan draw mode
  88351. */
  88352. static readonly TriangleFanDrawMode: number;
  88353. /**
  88354. * Stores the clock-wise side orientation
  88355. */
  88356. static readonly ClockWiseSideOrientation: number;
  88357. /**
  88358. * Stores the counter clock-wise side orientation
  88359. */
  88360. static readonly CounterClockWiseSideOrientation: number;
  88361. /**
  88362. * The dirty texture flag value
  88363. */
  88364. static readonly TextureDirtyFlag: number;
  88365. /**
  88366. * The dirty light flag value
  88367. */
  88368. static readonly LightDirtyFlag: number;
  88369. /**
  88370. * The dirty fresnel flag value
  88371. */
  88372. static readonly FresnelDirtyFlag: number;
  88373. /**
  88374. * The dirty attribute flag value
  88375. */
  88376. static readonly AttributesDirtyFlag: number;
  88377. /**
  88378. * The dirty misc flag value
  88379. */
  88380. static readonly MiscDirtyFlag: number;
  88381. /**
  88382. * The all dirty flag value
  88383. */
  88384. static readonly AllDirtyFlag: number;
  88385. /**
  88386. * The ID of the material
  88387. */
  88388. id: string;
  88389. /**
  88390. * Gets or sets the unique id of the material
  88391. */
  88392. uniqueId: number;
  88393. /**
  88394. * The name of the material
  88395. */
  88396. name: string;
  88397. /**
  88398. * Gets or sets user defined metadata
  88399. */
  88400. metadata: any;
  88401. /**
  88402. * For internal use only. Please do not use.
  88403. */
  88404. reservedDataStore: any;
  88405. /**
  88406. * Specifies if the ready state should be checked on each call
  88407. */
  88408. checkReadyOnEveryCall: boolean;
  88409. /**
  88410. * Specifies if the ready state should be checked once
  88411. */
  88412. checkReadyOnlyOnce: boolean;
  88413. /**
  88414. * The state of the material
  88415. */
  88416. state: string;
  88417. /**
  88418. * The alpha value of the material
  88419. */
  88420. protected _alpha: number;
  88421. /**
  88422. * List of inspectable custom properties (used by the Inspector)
  88423. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88424. */
  88425. inspectableCustomProperties: IInspectable[];
  88426. /**
  88427. * Sets the alpha value of the material
  88428. */
  88429. /**
  88430. * Gets the alpha value of the material
  88431. */
  88432. alpha: number;
  88433. /**
  88434. * Specifies if back face culling is enabled
  88435. */
  88436. protected _backFaceCulling: boolean;
  88437. /**
  88438. * Sets the back-face culling state
  88439. */
  88440. /**
  88441. * Gets the back-face culling state
  88442. */
  88443. backFaceCulling: boolean;
  88444. /**
  88445. * Stores the value for side orientation
  88446. */
  88447. sideOrientation: number;
  88448. /**
  88449. * Callback triggered when the material is compiled
  88450. */
  88451. onCompiled: Nullable<(effect: Effect) => void>;
  88452. /**
  88453. * Callback triggered when an error occurs
  88454. */
  88455. onError: Nullable<(effect: Effect, errors: string) => void>;
  88456. /**
  88457. * Callback triggered to get the render target textures
  88458. */
  88459. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88460. /**
  88461. * Gets a boolean indicating that current material needs to register RTT
  88462. */
  88463. readonly hasRenderTargetTextures: boolean;
  88464. /**
  88465. * Specifies if the material should be serialized
  88466. */
  88467. doNotSerialize: boolean;
  88468. /**
  88469. * @hidden
  88470. */
  88471. _storeEffectOnSubMeshes: boolean;
  88472. /**
  88473. * Stores the animations for the material
  88474. */
  88475. animations: Nullable<Array<Animation>>;
  88476. /**
  88477. * An event triggered when the material is disposed
  88478. */
  88479. onDisposeObservable: Observable<Material>;
  88480. /**
  88481. * An observer which watches for dispose events
  88482. */
  88483. private _onDisposeObserver;
  88484. private _onUnBindObservable;
  88485. /**
  88486. * Called during a dispose event
  88487. */
  88488. onDispose: () => void;
  88489. private _onBindObservable;
  88490. /**
  88491. * An event triggered when the material is bound
  88492. */
  88493. readonly onBindObservable: Observable<AbstractMesh>;
  88494. /**
  88495. * An observer which watches for bind events
  88496. */
  88497. private _onBindObserver;
  88498. /**
  88499. * Called during a bind event
  88500. */
  88501. onBind: (Mesh: AbstractMesh) => void;
  88502. /**
  88503. * An event triggered when the material is unbound
  88504. */
  88505. readonly onUnBindObservable: Observable<Material>;
  88506. /**
  88507. * Stores the value of the alpha mode
  88508. */
  88509. private _alphaMode;
  88510. /**
  88511. * Sets the value of the alpha mode.
  88512. *
  88513. * | Value | Type | Description |
  88514. * | --- | --- | --- |
  88515. * | 0 | ALPHA_DISABLE | |
  88516. * | 1 | ALPHA_ADD | |
  88517. * | 2 | ALPHA_COMBINE | |
  88518. * | 3 | ALPHA_SUBTRACT | |
  88519. * | 4 | ALPHA_MULTIPLY | |
  88520. * | 5 | ALPHA_MAXIMIZED | |
  88521. * | 6 | ALPHA_ONEONE | |
  88522. * | 7 | ALPHA_PREMULTIPLIED | |
  88523. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88524. * | 9 | ALPHA_INTERPOLATE | |
  88525. * | 10 | ALPHA_SCREENMODE | |
  88526. *
  88527. */
  88528. /**
  88529. * Gets the value of the alpha mode
  88530. */
  88531. alphaMode: number;
  88532. /**
  88533. * Stores the state of the need depth pre-pass value
  88534. */
  88535. private _needDepthPrePass;
  88536. /**
  88537. * Sets the need depth pre-pass value
  88538. */
  88539. /**
  88540. * Gets the depth pre-pass value
  88541. */
  88542. needDepthPrePass: boolean;
  88543. /**
  88544. * Specifies if depth writing should be disabled
  88545. */
  88546. disableDepthWrite: boolean;
  88547. /**
  88548. * Specifies if depth writing should be forced
  88549. */
  88550. forceDepthWrite: boolean;
  88551. /**
  88552. * Specifies if there should be a separate pass for culling
  88553. */
  88554. separateCullingPass: boolean;
  88555. /**
  88556. * Stores the state specifing if fog should be enabled
  88557. */
  88558. private _fogEnabled;
  88559. /**
  88560. * Sets the state for enabling fog
  88561. */
  88562. /**
  88563. * Gets the value of the fog enabled state
  88564. */
  88565. fogEnabled: boolean;
  88566. /**
  88567. * Stores the size of points
  88568. */
  88569. pointSize: number;
  88570. /**
  88571. * Stores the z offset value
  88572. */
  88573. zOffset: number;
  88574. /**
  88575. * Gets a value specifying if wireframe mode is enabled
  88576. */
  88577. /**
  88578. * Sets the state of wireframe mode
  88579. */
  88580. wireframe: boolean;
  88581. /**
  88582. * Gets the value specifying if point clouds are enabled
  88583. */
  88584. /**
  88585. * Sets the state of point cloud mode
  88586. */
  88587. pointsCloud: boolean;
  88588. /**
  88589. * Gets the material fill mode
  88590. */
  88591. /**
  88592. * Sets the material fill mode
  88593. */
  88594. fillMode: number;
  88595. /**
  88596. * @hidden
  88597. * Stores the effects for the material
  88598. */
  88599. _effect: Nullable<Effect>;
  88600. /**
  88601. * @hidden
  88602. * Specifies if the material was previously ready
  88603. */
  88604. _wasPreviouslyReady: boolean;
  88605. /**
  88606. * Specifies if uniform buffers should be used
  88607. */
  88608. private _useUBO;
  88609. /**
  88610. * Stores a reference to the scene
  88611. */
  88612. private _scene;
  88613. /**
  88614. * Stores the fill mode state
  88615. */
  88616. private _fillMode;
  88617. /**
  88618. * Specifies if the depth write state should be cached
  88619. */
  88620. private _cachedDepthWriteState;
  88621. /**
  88622. * Stores the uniform buffer
  88623. */
  88624. protected _uniformBuffer: UniformBuffer;
  88625. /** @hidden */
  88626. _indexInSceneMaterialArray: number;
  88627. /** @hidden */
  88628. meshMap: Nullable<{
  88629. [id: string]: AbstractMesh | undefined;
  88630. }>;
  88631. /**
  88632. * Creates a material instance
  88633. * @param name defines the name of the material
  88634. * @param scene defines the scene to reference
  88635. * @param doNotAdd specifies if the material should be added to the scene
  88636. */
  88637. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88638. /**
  88639. * Returns a string representation of the current material
  88640. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88641. * @returns a string with material information
  88642. */
  88643. toString(fullDetails?: boolean): string;
  88644. /**
  88645. * Gets the class name of the material
  88646. * @returns a string with the class name of the material
  88647. */
  88648. getClassName(): string;
  88649. /**
  88650. * Specifies if updates for the material been locked
  88651. */
  88652. readonly isFrozen: boolean;
  88653. /**
  88654. * Locks updates for the material
  88655. */
  88656. freeze(): void;
  88657. /**
  88658. * Unlocks updates for the material
  88659. */
  88660. unfreeze(): void;
  88661. /**
  88662. * Specifies if the material is ready to be used
  88663. * @param mesh defines the mesh to check
  88664. * @param useInstances specifies if instances should be used
  88665. * @returns a boolean indicating if the material is ready to be used
  88666. */
  88667. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88668. /**
  88669. * Specifies that the submesh is ready to be used
  88670. * @param mesh defines the mesh to check
  88671. * @param subMesh defines which submesh to check
  88672. * @param useInstances specifies that instances should be used
  88673. * @returns a boolean indicating that the submesh is ready or not
  88674. */
  88675. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88676. /**
  88677. * Returns the material effect
  88678. * @returns the effect associated with the material
  88679. */
  88680. getEffect(): Nullable<Effect>;
  88681. /**
  88682. * Returns the current scene
  88683. * @returns a Scene
  88684. */
  88685. getScene(): Scene;
  88686. /**
  88687. * Specifies if the material will require alpha blending
  88688. * @returns a boolean specifying if alpha blending is needed
  88689. */
  88690. needAlphaBlending(): boolean;
  88691. /**
  88692. * Specifies if the mesh will require alpha blending
  88693. * @param mesh defines the mesh to check
  88694. * @returns a boolean specifying if alpha blending is needed for the mesh
  88695. */
  88696. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88697. /**
  88698. * Specifies if this material should be rendered in alpha test mode
  88699. * @returns a boolean specifying if an alpha test is needed.
  88700. */
  88701. needAlphaTesting(): boolean;
  88702. /**
  88703. * Gets the texture used for the alpha test
  88704. * @returns the texture to use for alpha testing
  88705. */
  88706. getAlphaTestTexture(): Nullable<BaseTexture>;
  88707. /**
  88708. * Marks the material to indicate that it needs to be re-calculated
  88709. */
  88710. markDirty(): void;
  88711. /** @hidden */
  88712. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88713. /**
  88714. * Binds the material to the mesh
  88715. * @param world defines the world transformation matrix
  88716. * @param mesh defines the mesh to bind the material to
  88717. */
  88718. bind(world: Matrix, mesh?: Mesh): void;
  88719. /**
  88720. * Binds the submesh to the material
  88721. * @param world defines the world transformation matrix
  88722. * @param mesh defines the mesh containing the submesh
  88723. * @param subMesh defines the submesh to bind the material to
  88724. */
  88725. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88726. /**
  88727. * Binds the world matrix to the material
  88728. * @param world defines the world transformation matrix
  88729. */
  88730. bindOnlyWorldMatrix(world: Matrix): void;
  88731. /**
  88732. * Binds the scene's uniform buffer to the effect.
  88733. * @param effect defines the effect to bind to the scene uniform buffer
  88734. * @param sceneUbo defines the uniform buffer storing scene data
  88735. */
  88736. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88737. /**
  88738. * Binds the view matrix to the effect
  88739. * @param effect defines the effect to bind the view matrix to
  88740. */
  88741. bindView(effect: Effect): void;
  88742. /**
  88743. * Binds the view projection matrix to the effect
  88744. * @param effect defines the effect to bind the view projection matrix to
  88745. */
  88746. bindViewProjection(effect: Effect): void;
  88747. /**
  88748. * Specifies if material alpha testing should be turned on for the mesh
  88749. * @param mesh defines the mesh to check
  88750. */
  88751. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88752. /**
  88753. * Processes to execute after binding the material to a mesh
  88754. * @param mesh defines the rendered mesh
  88755. */
  88756. protected _afterBind(mesh?: Mesh): void;
  88757. /**
  88758. * Unbinds the material from the mesh
  88759. */
  88760. unbind(): void;
  88761. /**
  88762. * Gets the active textures from the material
  88763. * @returns an array of textures
  88764. */
  88765. getActiveTextures(): BaseTexture[];
  88766. /**
  88767. * Specifies if the material uses a texture
  88768. * @param texture defines the texture to check against the material
  88769. * @returns a boolean specifying if the material uses the texture
  88770. */
  88771. hasTexture(texture: BaseTexture): boolean;
  88772. /**
  88773. * Makes a duplicate of the material, and gives it a new name
  88774. * @param name defines the new name for the duplicated material
  88775. * @returns the cloned material
  88776. */
  88777. clone(name: string): Nullable<Material>;
  88778. /**
  88779. * Gets the meshes bound to the material
  88780. * @returns an array of meshes bound to the material
  88781. */
  88782. getBindedMeshes(): AbstractMesh[];
  88783. /**
  88784. * Force shader compilation
  88785. * @param mesh defines the mesh associated with this material
  88786. * @param onCompiled defines a function to execute once the material is compiled
  88787. * @param options defines the options to configure the compilation
  88788. * @param onError defines a function to execute if the material fails compiling
  88789. */
  88790. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88791. /**
  88792. * Force shader compilation
  88793. * @param mesh defines the mesh that will use this material
  88794. * @param options defines additional options for compiling the shaders
  88795. * @returns a promise that resolves when the compilation completes
  88796. */
  88797. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88798. private static readonly _AllDirtyCallBack;
  88799. private static readonly _ImageProcessingDirtyCallBack;
  88800. private static readonly _TextureDirtyCallBack;
  88801. private static readonly _FresnelDirtyCallBack;
  88802. private static readonly _MiscDirtyCallBack;
  88803. private static readonly _LightsDirtyCallBack;
  88804. private static readonly _AttributeDirtyCallBack;
  88805. private static _FresnelAndMiscDirtyCallBack;
  88806. private static _TextureAndMiscDirtyCallBack;
  88807. private static readonly _DirtyCallbackArray;
  88808. private static readonly _RunDirtyCallBacks;
  88809. /**
  88810. * Marks a define in the material to indicate that it needs to be re-computed
  88811. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88812. */
  88813. markAsDirty(flag: number): void;
  88814. /**
  88815. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88816. * @param func defines a function which checks material defines against the submeshes
  88817. */
  88818. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88819. /**
  88820. * Indicates that we need to re-calculated for all submeshes
  88821. */
  88822. protected _markAllSubMeshesAsAllDirty(): void;
  88823. /**
  88824. * Indicates that image processing needs to be re-calculated for all submeshes
  88825. */
  88826. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88827. /**
  88828. * Indicates that textures need to be re-calculated for all submeshes
  88829. */
  88830. protected _markAllSubMeshesAsTexturesDirty(): void;
  88831. /**
  88832. * Indicates that fresnel needs to be re-calculated for all submeshes
  88833. */
  88834. protected _markAllSubMeshesAsFresnelDirty(): void;
  88835. /**
  88836. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88837. */
  88838. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88839. /**
  88840. * Indicates that lights need to be re-calculated for all submeshes
  88841. */
  88842. protected _markAllSubMeshesAsLightsDirty(): void;
  88843. /**
  88844. * Indicates that attributes need to be re-calculated for all submeshes
  88845. */
  88846. protected _markAllSubMeshesAsAttributesDirty(): void;
  88847. /**
  88848. * Indicates that misc needs to be re-calculated for all submeshes
  88849. */
  88850. protected _markAllSubMeshesAsMiscDirty(): void;
  88851. /**
  88852. * Indicates that textures and misc need to be re-calculated for all submeshes
  88853. */
  88854. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88855. /**
  88856. * Disposes the material
  88857. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88858. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88859. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88860. */
  88861. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88862. /** @hidden */
  88863. private releaseVertexArrayObject;
  88864. /**
  88865. * Serializes this material
  88866. * @returns the serialized material object
  88867. */
  88868. serialize(): any;
  88869. /**
  88870. * Creates a material from parsed material data
  88871. * @param parsedMaterial defines parsed material data
  88872. * @param scene defines the hosting scene
  88873. * @param rootUrl defines the root URL to use to load textures
  88874. * @returns a new material
  88875. */
  88876. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88877. }
  88878. }
  88879. declare module BABYLON {
  88880. /**
  88881. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88882. * separate meshes. This can be use to improve performances.
  88883. * @see http://doc.babylonjs.com/how_to/multi_materials
  88884. */
  88885. export class MultiMaterial extends Material {
  88886. private _subMaterials;
  88887. /**
  88888. * Gets or Sets the list of Materials used within the multi material.
  88889. * They need to be ordered according to the submeshes order in the associated mesh
  88890. */
  88891. subMaterials: Nullable<Material>[];
  88892. /**
  88893. * Function used to align with Node.getChildren()
  88894. * @returns the list of Materials used within the multi material
  88895. */
  88896. getChildren(): Nullable<Material>[];
  88897. /**
  88898. * Instantiates a new Multi Material
  88899. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88900. * separate meshes. This can be use to improve performances.
  88901. * @see http://doc.babylonjs.com/how_to/multi_materials
  88902. * @param name Define the name in the scene
  88903. * @param scene Define the scene the material belongs to
  88904. */
  88905. constructor(name: string, scene: Scene);
  88906. private _hookArray;
  88907. /**
  88908. * Get one of the submaterial by its index in the submaterials array
  88909. * @param index The index to look the sub material at
  88910. * @returns The Material if the index has been defined
  88911. */
  88912. getSubMaterial(index: number): Nullable<Material>;
  88913. /**
  88914. * Get the list of active textures for the whole sub materials list.
  88915. * @returns All the textures that will be used during the rendering
  88916. */
  88917. getActiveTextures(): BaseTexture[];
  88918. /**
  88919. * Gets the current class name of the material e.g. "MultiMaterial"
  88920. * Mainly use in serialization.
  88921. * @returns the class name
  88922. */
  88923. getClassName(): string;
  88924. /**
  88925. * Checks if the material is ready to render the requested sub mesh
  88926. * @param mesh Define the mesh the submesh belongs to
  88927. * @param subMesh Define the sub mesh to look readyness for
  88928. * @param useInstances Define whether or not the material is used with instances
  88929. * @returns true if ready, otherwise false
  88930. */
  88931. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88932. /**
  88933. * Clones the current material and its related sub materials
  88934. * @param name Define the name of the newly cloned material
  88935. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88936. * @returns the cloned material
  88937. */
  88938. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88939. /**
  88940. * Serializes the materials into a JSON representation.
  88941. * @returns the JSON representation
  88942. */
  88943. serialize(): any;
  88944. /**
  88945. * Dispose the material and release its associated resources
  88946. * @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)
  88947. * @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)
  88948. * @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)
  88949. */
  88950. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88951. /**
  88952. * Creates a MultiMaterial from parsed MultiMaterial data.
  88953. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88954. * @param scene defines the hosting scene
  88955. * @returns a new MultiMaterial
  88956. */
  88957. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88958. }
  88959. }
  88960. declare module BABYLON {
  88961. /**
  88962. * Base class for submeshes
  88963. */
  88964. export class BaseSubMesh {
  88965. /** @hidden */
  88966. _materialDefines: Nullable<MaterialDefines>;
  88967. /** @hidden */
  88968. _materialEffect: Nullable<Effect>;
  88969. /**
  88970. * Gets associated effect
  88971. */
  88972. readonly effect: Nullable<Effect>;
  88973. /**
  88974. * Sets associated effect (effect used to render this submesh)
  88975. * @param effect defines the effect to associate with
  88976. * @param defines defines the set of defines used to compile this effect
  88977. */
  88978. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88979. }
  88980. /**
  88981. * Defines a subdivision inside a mesh
  88982. */
  88983. export class SubMesh extends BaseSubMesh implements ICullable {
  88984. /** the material index to use */
  88985. materialIndex: number;
  88986. /** vertex index start */
  88987. verticesStart: number;
  88988. /** vertices count */
  88989. verticesCount: number;
  88990. /** index start */
  88991. indexStart: number;
  88992. /** indices count */
  88993. indexCount: number;
  88994. /** @hidden */
  88995. _linesIndexCount: number;
  88996. private _mesh;
  88997. private _renderingMesh;
  88998. private _boundingInfo;
  88999. private _linesIndexBuffer;
  89000. /** @hidden */
  89001. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89002. /** @hidden */
  89003. _trianglePlanes: Plane[];
  89004. /** @hidden */
  89005. _lastColliderTransformMatrix: Nullable<Matrix>;
  89006. /** @hidden */
  89007. _renderId: number;
  89008. /** @hidden */
  89009. _alphaIndex: number;
  89010. /** @hidden */
  89011. _distanceToCamera: number;
  89012. /** @hidden */
  89013. _id: number;
  89014. private _currentMaterial;
  89015. /**
  89016. * Add a new submesh to a mesh
  89017. * @param materialIndex defines the material index to use
  89018. * @param verticesStart defines vertex index start
  89019. * @param verticesCount defines vertices count
  89020. * @param indexStart defines index start
  89021. * @param indexCount defines indices count
  89022. * @param mesh defines the parent mesh
  89023. * @param renderingMesh defines an optional rendering mesh
  89024. * @param createBoundingBox defines if bounding box should be created for this submesh
  89025. * @returns the new submesh
  89026. */
  89027. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89028. /**
  89029. * Creates a new submesh
  89030. * @param materialIndex defines the material index to use
  89031. * @param verticesStart defines vertex index start
  89032. * @param verticesCount defines vertices count
  89033. * @param indexStart defines index start
  89034. * @param indexCount defines indices count
  89035. * @param mesh defines the parent mesh
  89036. * @param renderingMesh defines an optional rendering mesh
  89037. * @param createBoundingBox defines if bounding box should be created for this submesh
  89038. */
  89039. constructor(
  89040. /** the material index to use */
  89041. materialIndex: number,
  89042. /** vertex index start */
  89043. verticesStart: number,
  89044. /** vertices count */
  89045. verticesCount: number,
  89046. /** index start */
  89047. indexStart: number,
  89048. /** indices count */
  89049. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89050. /**
  89051. * Returns true if this submesh covers the entire parent mesh
  89052. * @ignorenaming
  89053. */
  89054. readonly IsGlobal: boolean;
  89055. /**
  89056. * Returns the submesh BoudingInfo object
  89057. * @returns current bounding info (or mesh's one if the submesh is global)
  89058. */
  89059. getBoundingInfo(): BoundingInfo;
  89060. /**
  89061. * Sets the submesh BoundingInfo
  89062. * @param boundingInfo defines the new bounding info to use
  89063. * @returns the SubMesh
  89064. */
  89065. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89066. /**
  89067. * Returns the mesh of the current submesh
  89068. * @return the parent mesh
  89069. */
  89070. getMesh(): AbstractMesh;
  89071. /**
  89072. * Returns the rendering mesh of the submesh
  89073. * @returns the rendering mesh (could be different from parent mesh)
  89074. */
  89075. getRenderingMesh(): Mesh;
  89076. /**
  89077. * Returns the submesh material
  89078. * @returns null or the current material
  89079. */
  89080. getMaterial(): Nullable<Material>;
  89081. /**
  89082. * Sets a new updated BoundingInfo object to the submesh
  89083. * @param data defines an optional position array to use to determine the bounding info
  89084. * @returns the SubMesh
  89085. */
  89086. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89087. /** @hidden */
  89088. _checkCollision(collider: Collider): boolean;
  89089. /**
  89090. * Updates the submesh BoundingInfo
  89091. * @param world defines the world matrix to use to update the bounding info
  89092. * @returns the submesh
  89093. */
  89094. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89095. /**
  89096. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89097. * @param frustumPlanes defines the frustum planes
  89098. * @returns true if the submesh is intersecting with the frustum
  89099. */
  89100. isInFrustum(frustumPlanes: Plane[]): boolean;
  89101. /**
  89102. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89103. * @param frustumPlanes defines the frustum planes
  89104. * @returns true if the submesh is inside the frustum
  89105. */
  89106. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89107. /**
  89108. * Renders the submesh
  89109. * @param enableAlphaMode defines if alpha needs to be used
  89110. * @returns the submesh
  89111. */
  89112. render(enableAlphaMode: boolean): SubMesh;
  89113. /**
  89114. * @hidden
  89115. */
  89116. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89117. /**
  89118. * Checks if the submesh intersects with a ray
  89119. * @param ray defines the ray to test
  89120. * @returns true is the passed ray intersects the submesh bounding box
  89121. */
  89122. canIntersects(ray: Ray): boolean;
  89123. /**
  89124. * Intersects current submesh with a ray
  89125. * @param ray defines the ray to test
  89126. * @param positions defines mesh's positions array
  89127. * @param indices defines mesh's indices array
  89128. * @param fastCheck defines if only bounding info should be used
  89129. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89130. * @returns intersection info or null if no intersection
  89131. */
  89132. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89133. /** @hidden */
  89134. private _intersectLines;
  89135. /** @hidden */
  89136. private _intersectUnIndexedLines;
  89137. /** @hidden */
  89138. private _intersectTriangles;
  89139. /** @hidden */
  89140. private _intersectUnIndexedTriangles;
  89141. /** @hidden */
  89142. _rebuild(): void;
  89143. /**
  89144. * Creates a new submesh from the passed mesh
  89145. * @param newMesh defines the new hosting mesh
  89146. * @param newRenderingMesh defines an optional rendering mesh
  89147. * @returns the new submesh
  89148. */
  89149. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89150. /**
  89151. * Release associated resources
  89152. */
  89153. dispose(): void;
  89154. /**
  89155. * Gets the class name
  89156. * @returns the string "SubMesh".
  89157. */
  89158. getClassName(): string;
  89159. /**
  89160. * Creates a new submesh from indices data
  89161. * @param materialIndex the index of the main mesh material
  89162. * @param startIndex the index where to start the copy in the mesh indices array
  89163. * @param indexCount the number of indices to copy then from the startIndex
  89164. * @param mesh the main mesh to create the submesh from
  89165. * @param renderingMesh the optional rendering mesh
  89166. * @returns a new submesh
  89167. */
  89168. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89169. }
  89170. }
  89171. declare module BABYLON {
  89172. /**
  89173. * Class used to represent data loading progression
  89174. */
  89175. export class SceneLoaderFlags {
  89176. private static _ForceFullSceneLoadingForIncremental;
  89177. private static _ShowLoadingScreen;
  89178. private static _CleanBoneMatrixWeights;
  89179. private static _loggingLevel;
  89180. /**
  89181. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89182. */
  89183. static ForceFullSceneLoadingForIncremental: boolean;
  89184. /**
  89185. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89186. */
  89187. static ShowLoadingScreen: boolean;
  89188. /**
  89189. * Defines the current logging level (while loading the scene)
  89190. * @ignorenaming
  89191. */
  89192. static loggingLevel: number;
  89193. /**
  89194. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89195. */
  89196. static CleanBoneMatrixWeights: boolean;
  89197. }
  89198. }
  89199. declare module BABYLON {
  89200. /**
  89201. * Class used to store geometry data (vertex buffers + index buffer)
  89202. */
  89203. export class Geometry implements IGetSetVerticesData {
  89204. /**
  89205. * Gets or sets the ID of the geometry
  89206. */
  89207. id: string;
  89208. /**
  89209. * Gets or sets the unique ID of the geometry
  89210. */
  89211. uniqueId: number;
  89212. /**
  89213. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89214. */
  89215. delayLoadState: number;
  89216. /**
  89217. * Gets the file containing the data to load when running in delay load state
  89218. */
  89219. delayLoadingFile: Nullable<string>;
  89220. /**
  89221. * Callback called when the geometry is updated
  89222. */
  89223. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89224. private _scene;
  89225. private _engine;
  89226. private _meshes;
  89227. private _totalVertices;
  89228. /** @hidden */
  89229. _indices: IndicesArray;
  89230. /** @hidden */
  89231. _vertexBuffers: {
  89232. [key: string]: VertexBuffer;
  89233. };
  89234. private _isDisposed;
  89235. private _extend;
  89236. private _boundingBias;
  89237. /** @hidden */
  89238. _delayInfo: Array<string>;
  89239. private _indexBuffer;
  89240. private _indexBufferIsUpdatable;
  89241. /** @hidden */
  89242. _boundingInfo: Nullable<BoundingInfo>;
  89243. /** @hidden */
  89244. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89245. /** @hidden */
  89246. _softwareSkinningFrameId: number;
  89247. private _vertexArrayObjects;
  89248. private _updatable;
  89249. /** @hidden */
  89250. _positions: Nullable<Vector3[]>;
  89251. /**
  89252. * 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
  89253. */
  89254. /**
  89255. * 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
  89256. */
  89257. boundingBias: Vector2;
  89258. /**
  89259. * Static function used to attach a new empty geometry to a mesh
  89260. * @param mesh defines the mesh to attach the geometry to
  89261. * @returns the new Geometry
  89262. */
  89263. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89264. /**
  89265. * Creates a new geometry
  89266. * @param id defines the unique ID
  89267. * @param scene defines the hosting scene
  89268. * @param vertexData defines the VertexData used to get geometry data
  89269. * @param updatable defines if geometry must be updatable (false by default)
  89270. * @param mesh defines the mesh that will be associated with the geometry
  89271. */
  89272. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89273. /**
  89274. * Gets the current extend of the geometry
  89275. */
  89276. readonly extend: {
  89277. minimum: Vector3;
  89278. maximum: Vector3;
  89279. };
  89280. /**
  89281. * Gets the hosting scene
  89282. * @returns the hosting Scene
  89283. */
  89284. getScene(): Scene;
  89285. /**
  89286. * Gets the hosting engine
  89287. * @returns the hosting Engine
  89288. */
  89289. getEngine(): Engine;
  89290. /**
  89291. * Defines if the geometry is ready to use
  89292. * @returns true if the geometry is ready to be used
  89293. */
  89294. isReady(): boolean;
  89295. /**
  89296. * Gets a value indicating that the geometry should not be serialized
  89297. */
  89298. readonly doNotSerialize: boolean;
  89299. /** @hidden */
  89300. _rebuild(): void;
  89301. /**
  89302. * Affects all geometry data in one call
  89303. * @param vertexData defines the geometry data
  89304. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89305. */
  89306. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89307. /**
  89308. * Set specific vertex data
  89309. * @param kind defines the data kind (Position, normal, etc...)
  89310. * @param data defines the vertex data to use
  89311. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89312. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89313. */
  89314. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89315. /**
  89316. * Removes a specific vertex data
  89317. * @param kind defines the data kind (Position, normal, etc...)
  89318. */
  89319. removeVerticesData(kind: string): void;
  89320. /**
  89321. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89322. * @param buffer defines the vertex buffer to use
  89323. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89324. */
  89325. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89326. /**
  89327. * Update a specific vertex buffer
  89328. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89329. * It will do nothing if the buffer is not updatable
  89330. * @param kind defines the data kind (Position, normal, etc...)
  89331. * @param data defines the data to use
  89332. * @param offset defines the offset in the target buffer where to store the data
  89333. * @param useBytes set to true if the offset is in bytes
  89334. */
  89335. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89336. /**
  89337. * Update a specific vertex buffer
  89338. * This function will create a new buffer if the current one is not updatable
  89339. * @param kind defines the data kind (Position, normal, etc...)
  89340. * @param data defines the data to use
  89341. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89342. */
  89343. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89344. private _updateBoundingInfo;
  89345. /** @hidden */
  89346. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89347. /**
  89348. * Gets total number of vertices
  89349. * @returns the total number of vertices
  89350. */
  89351. getTotalVertices(): number;
  89352. /**
  89353. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89354. * @param kind defines the data kind (Position, normal, etc...)
  89355. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89356. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89357. * @returns a float array containing vertex data
  89358. */
  89359. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89360. /**
  89361. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89362. * @param kind defines the data kind (Position, normal, etc...)
  89363. * @returns true if the vertex buffer with the specified kind is updatable
  89364. */
  89365. isVertexBufferUpdatable(kind: string): boolean;
  89366. /**
  89367. * Gets a specific vertex buffer
  89368. * @param kind defines the data kind (Position, normal, etc...)
  89369. * @returns a VertexBuffer
  89370. */
  89371. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89372. /**
  89373. * Returns all vertex buffers
  89374. * @return an object holding all vertex buffers indexed by kind
  89375. */
  89376. getVertexBuffers(): Nullable<{
  89377. [key: string]: VertexBuffer;
  89378. }>;
  89379. /**
  89380. * Gets a boolean indicating if specific vertex buffer is present
  89381. * @param kind defines the data kind (Position, normal, etc...)
  89382. * @returns true if data is present
  89383. */
  89384. isVerticesDataPresent(kind: string): boolean;
  89385. /**
  89386. * Gets a list of all attached data kinds (Position, normal, etc...)
  89387. * @returns a list of string containing all kinds
  89388. */
  89389. getVerticesDataKinds(): string[];
  89390. /**
  89391. * Update index buffer
  89392. * @param indices defines the indices to store in the index buffer
  89393. * @param offset defines the offset in the target buffer where to store the data
  89394. * @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)
  89395. */
  89396. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89397. /**
  89398. * Creates a new index buffer
  89399. * @param indices defines the indices to store in the index buffer
  89400. * @param totalVertices defines the total number of vertices (could be null)
  89401. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89402. */
  89403. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89404. /**
  89405. * Return the total number of indices
  89406. * @returns the total number of indices
  89407. */
  89408. getTotalIndices(): number;
  89409. /**
  89410. * Gets the index buffer array
  89411. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89412. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89413. * @returns the index buffer array
  89414. */
  89415. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89416. /**
  89417. * Gets the index buffer
  89418. * @return the index buffer
  89419. */
  89420. getIndexBuffer(): Nullable<DataBuffer>;
  89421. /** @hidden */
  89422. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89423. /**
  89424. * Release the associated resources for a specific mesh
  89425. * @param mesh defines the source mesh
  89426. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89427. */
  89428. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89429. /**
  89430. * Apply current geometry to a given mesh
  89431. * @param mesh defines the mesh to apply geometry to
  89432. */
  89433. applyToMesh(mesh: Mesh): void;
  89434. private _updateExtend;
  89435. private _applyToMesh;
  89436. private notifyUpdate;
  89437. /**
  89438. * Load the geometry if it was flagged as delay loaded
  89439. * @param scene defines the hosting scene
  89440. * @param onLoaded defines a callback called when the geometry is loaded
  89441. */
  89442. load(scene: Scene, onLoaded?: () => void): void;
  89443. private _queueLoad;
  89444. /**
  89445. * Invert the geometry to move from a right handed system to a left handed one.
  89446. */
  89447. toLeftHanded(): void;
  89448. /** @hidden */
  89449. _resetPointsArrayCache(): void;
  89450. /** @hidden */
  89451. _generatePointsArray(): boolean;
  89452. /**
  89453. * Gets a value indicating if the geometry is disposed
  89454. * @returns true if the geometry was disposed
  89455. */
  89456. isDisposed(): boolean;
  89457. private _disposeVertexArrayObjects;
  89458. /**
  89459. * Free all associated resources
  89460. */
  89461. dispose(): void;
  89462. /**
  89463. * Clone the current geometry into a new geometry
  89464. * @param id defines the unique ID of the new geometry
  89465. * @returns a new geometry object
  89466. */
  89467. copy(id: string): Geometry;
  89468. /**
  89469. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89470. * @return a JSON representation of the current geometry data (without the vertices data)
  89471. */
  89472. serialize(): any;
  89473. private toNumberArray;
  89474. /**
  89475. * Serialize all vertices data into a JSON oject
  89476. * @returns a JSON representation of the current geometry data
  89477. */
  89478. serializeVerticeData(): any;
  89479. /**
  89480. * Extracts a clone of a mesh geometry
  89481. * @param mesh defines the source mesh
  89482. * @param id defines the unique ID of the new geometry object
  89483. * @returns the new geometry object
  89484. */
  89485. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89486. /**
  89487. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89488. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89489. * Be aware Math.random() could cause collisions, but:
  89490. * "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"
  89491. * @returns a string containing a new GUID
  89492. */
  89493. static RandomId(): string;
  89494. /** @hidden */
  89495. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89496. private static _CleanMatricesWeights;
  89497. /**
  89498. * Create a new geometry from persisted data (Using .babylon file format)
  89499. * @param parsedVertexData defines the persisted data
  89500. * @param scene defines the hosting scene
  89501. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89502. * @returns the new geometry object
  89503. */
  89504. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89505. }
  89506. }
  89507. declare module BABYLON {
  89508. /**
  89509. * Define an interface for all classes that will get and set the data on vertices
  89510. */
  89511. export interface IGetSetVerticesData {
  89512. /**
  89513. * Gets a boolean indicating if specific vertex data is present
  89514. * @param kind defines the vertex data kind to use
  89515. * @returns true is data kind is present
  89516. */
  89517. isVerticesDataPresent(kind: string): boolean;
  89518. /**
  89519. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89520. * @param kind defines the data kind (Position, normal, etc...)
  89521. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89522. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89523. * @returns a float array containing vertex data
  89524. */
  89525. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89526. /**
  89527. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89528. * @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.
  89529. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89530. * @returns the indices array or an empty array if the mesh has no geometry
  89531. */
  89532. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89533. /**
  89534. * Set specific vertex data
  89535. * @param kind defines the data kind (Position, normal, etc...)
  89536. * @param data defines the vertex data to use
  89537. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89538. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89539. */
  89540. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89541. /**
  89542. * Update a specific associated vertex buffer
  89543. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89544. * - VertexBuffer.PositionKind
  89545. * - VertexBuffer.UVKind
  89546. * - VertexBuffer.UV2Kind
  89547. * - VertexBuffer.UV3Kind
  89548. * - VertexBuffer.UV4Kind
  89549. * - VertexBuffer.UV5Kind
  89550. * - VertexBuffer.UV6Kind
  89551. * - VertexBuffer.ColorKind
  89552. * - VertexBuffer.MatricesIndicesKind
  89553. * - VertexBuffer.MatricesIndicesExtraKind
  89554. * - VertexBuffer.MatricesWeightsKind
  89555. * - VertexBuffer.MatricesWeightsExtraKind
  89556. * @param data defines the data source
  89557. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89558. * @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)
  89559. */
  89560. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89561. /**
  89562. * Creates a new index buffer
  89563. * @param indices defines the indices to store in the index buffer
  89564. * @param totalVertices defines the total number of vertices (could be null)
  89565. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89566. */
  89567. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89568. }
  89569. /**
  89570. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89571. */
  89572. export class VertexData {
  89573. /**
  89574. * Mesh side orientation : usually the external or front surface
  89575. */
  89576. static readonly FRONTSIDE: number;
  89577. /**
  89578. * Mesh side orientation : usually the internal or back surface
  89579. */
  89580. static readonly BACKSIDE: number;
  89581. /**
  89582. * Mesh side orientation : both internal and external or front and back surfaces
  89583. */
  89584. static readonly DOUBLESIDE: number;
  89585. /**
  89586. * Mesh side orientation : by default, `FRONTSIDE`
  89587. */
  89588. static readonly DEFAULTSIDE: number;
  89589. /**
  89590. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89591. */
  89592. positions: Nullable<FloatArray>;
  89593. /**
  89594. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89595. */
  89596. normals: Nullable<FloatArray>;
  89597. /**
  89598. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89599. */
  89600. tangents: Nullable<FloatArray>;
  89601. /**
  89602. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89603. */
  89604. uvs: Nullable<FloatArray>;
  89605. /**
  89606. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89607. */
  89608. uvs2: Nullable<FloatArray>;
  89609. /**
  89610. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89611. */
  89612. uvs3: Nullable<FloatArray>;
  89613. /**
  89614. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89615. */
  89616. uvs4: Nullable<FloatArray>;
  89617. /**
  89618. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89619. */
  89620. uvs5: Nullable<FloatArray>;
  89621. /**
  89622. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89623. */
  89624. uvs6: Nullable<FloatArray>;
  89625. /**
  89626. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89627. */
  89628. colors: Nullable<FloatArray>;
  89629. /**
  89630. * 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).
  89631. */
  89632. matricesIndices: Nullable<FloatArray>;
  89633. /**
  89634. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89635. */
  89636. matricesWeights: Nullable<FloatArray>;
  89637. /**
  89638. * An array extending the number of possible indices
  89639. */
  89640. matricesIndicesExtra: Nullable<FloatArray>;
  89641. /**
  89642. * An array extending the number of possible weights when the number of indices is extended
  89643. */
  89644. matricesWeightsExtra: Nullable<FloatArray>;
  89645. /**
  89646. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89647. */
  89648. indices: Nullable<IndicesArray>;
  89649. /**
  89650. * Uses the passed data array to set the set the values for the specified kind of data
  89651. * @param data a linear array of floating numbers
  89652. * @param kind the type of data that is being set, eg positions, colors etc
  89653. */
  89654. set(data: FloatArray, kind: string): void;
  89655. /**
  89656. * Associates the vertexData to the passed Mesh.
  89657. * Sets it as updatable or not (default `false`)
  89658. * @param mesh the mesh the vertexData is applied to
  89659. * @param updatable when used and having the value true allows new data to update the vertexData
  89660. * @returns the VertexData
  89661. */
  89662. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89663. /**
  89664. * Associates the vertexData to the passed Geometry.
  89665. * Sets it as updatable or not (default `false`)
  89666. * @param geometry the geometry the vertexData is applied to
  89667. * @param updatable when used and having the value true allows new data to update the vertexData
  89668. * @returns VertexData
  89669. */
  89670. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89671. /**
  89672. * Updates the associated mesh
  89673. * @param mesh the mesh to be updated
  89674. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89675. * @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
  89676. * @returns VertexData
  89677. */
  89678. updateMesh(mesh: Mesh): VertexData;
  89679. /**
  89680. * Updates the associated geometry
  89681. * @param geometry the geometry to be updated
  89682. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89683. * @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
  89684. * @returns VertexData.
  89685. */
  89686. updateGeometry(geometry: Geometry): VertexData;
  89687. private _applyTo;
  89688. private _update;
  89689. /**
  89690. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89691. * @param matrix the transforming matrix
  89692. * @returns the VertexData
  89693. */
  89694. transform(matrix: Matrix): VertexData;
  89695. /**
  89696. * Merges the passed VertexData into the current one
  89697. * @param other the VertexData to be merged into the current one
  89698. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89699. * @returns the modified VertexData
  89700. */
  89701. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89702. private _mergeElement;
  89703. private _validate;
  89704. /**
  89705. * Serializes the VertexData
  89706. * @returns a serialized object
  89707. */
  89708. serialize(): any;
  89709. /**
  89710. * Extracts the vertexData from a mesh
  89711. * @param mesh the mesh from which to extract the VertexData
  89712. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89713. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89714. * @returns the object VertexData associated to the passed mesh
  89715. */
  89716. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89717. /**
  89718. * Extracts the vertexData from the geometry
  89719. * @param geometry the geometry from which to extract the VertexData
  89720. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89721. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89722. * @returns the object VertexData associated to the passed mesh
  89723. */
  89724. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89725. private static _ExtractFrom;
  89726. /**
  89727. * Creates the VertexData for a Ribbon
  89728. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89729. * * pathArray array of paths, each of which an array of successive Vector3
  89730. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89731. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89732. * * 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
  89733. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89734. * * 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)
  89735. * * 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)
  89736. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89737. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89738. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89739. * @returns the VertexData of the ribbon
  89740. */
  89741. static CreateRibbon(options: {
  89742. pathArray: Vector3[][];
  89743. closeArray?: boolean;
  89744. closePath?: boolean;
  89745. offset?: number;
  89746. sideOrientation?: number;
  89747. frontUVs?: Vector4;
  89748. backUVs?: Vector4;
  89749. invertUV?: boolean;
  89750. uvs?: Vector2[];
  89751. colors?: Color4[];
  89752. }): VertexData;
  89753. /**
  89754. * Creates the VertexData for a box
  89755. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89756. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89757. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89758. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89759. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89760. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89761. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89762. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89763. * * 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)
  89764. * * 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)
  89765. * @returns the VertexData of the box
  89766. */
  89767. static CreateBox(options: {
  89768. size?: number;
  89769. width?: number;
  89770. height?: number;
  89771. depth?: number;
  89772. faceUV?: Vector4[];
  89773. faceColors?: Color4[];
  89774. sideOrientation?: number;
  89775. frontUVs?: Vector4;
  89776. backUVs?: Vector4;
  89777. }): VertexData;
  89778. /**
  89779. * Creates the VertexData for a tiled box
  89780. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89781. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89782. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89783. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89784. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89785. * @returns the VertexData of the box
  89786. */
  89787. static CreateTiledBox(options: {
  89788. pattern?: number;
  89789. width?: number;
  89790. height?: number;
  89791. depth?: number;
  89792. tileSize?: number;
  89793. tileWidth?: number;
  89794. tileHeight?: number;
  89795. alignHorizontal?: number;
  89796. alignVertical?: number;
  89797. faceUV?: Vector4[];
  89798. faceColors?: Color4[];
  89799. sideOrientation?: number;
  89800. }): VertexData;
  89801. /**
  89802. * Creates the VertexData for a tiled plane
  89803. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89804. * * pattern a limited pattern arrangement depending on the number
  89805. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89806. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89807. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89808. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89809. * * 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)
  89810. * * 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)
  89811. * @returns the VertexData of the tiled plane
  89812. */
  89813. static CreateTiledPlane(options: {
  89814. pattern?: number;
  89815. tileSize?: number;
  89816. tileWidth?: number;
  89817. tileHeight?: number;
  89818. size?: number;
  89819. width?: number;
  89820. height?: number;
  89821. alignHorizontal?: number;
  89822. alignVertical?: number;
  89823. sideOrientation?: number;
  89824. frontUVs?: Vector4;
  89825. backUVs?: Vector4;
  89826. }): VertexData;
  89827. /**
  89828. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89829. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89830. * * segments sets the number of horizontal strips optional, default 32
  89831. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89832. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89833. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89834. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89835. * * 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
  89836. * * 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
  89837. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89838. * * 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)
  89839. * * 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)
  89840. * @returns the VertexData of the ellipsoid
  89841. */
  89842. static CreateSphere(options: {
  89843. segments?: number;
  89844. diameter?: number;
  89845. diameterX?: number;
  89846. diameterY?: number;
  89847. diameterZ?: number;
  89848. arc?: number;
  89849. slice?: number;
  89850. sideOrientation?: number;
  89851. frontUVs?: Vector4;
  89852. backUVs?: Vector4;
  89853. }): VertexData;
  89854. /**
  89855. * Creates the VertexData for a cylinder, cone or prism
  89856. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89857. * * height sets the height (y direction) of the cylinder, optional, default 2
  89858. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89859. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89860. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89861. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89862. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89863. * * 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
  89864. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89865. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89866. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89867. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89868. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89869. * * 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)
  89870. * * 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)
  89871. * @returns the VertexData of the cylinder, cone or prism
  89872. */
  89873. static CreateCylinder(options: {
  89874. height?: number;
  89875. diameterTop?: number;
  89876. diameterBottom?: number;
  89877. diameter?: number;
  89878. tessellation?: number;
  89879. subdivisions?: number;
  89880. arc?: number;
  89881. faceColors?: Color4[];
  89882. faceUV?: Vector4[];
  89883. hasRings?: boolean;
  89884. enclose?: boolean;
  89885. sideOrientation?: number;
  89886. frontUVs?: Vector4;
  89887. backUVs?: Vector4;
  89888. }): VertexData;
  89889. /**
  89890. * Creates the VertexData for a torus
  89891. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89892. * * diameter the diameter of the torus, optional default 1
  89893. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89894. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89895. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89896. * * 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)
  89897. * * 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)
  89898. * @returns the VertexData of the torus
  89899. */
  89900. static CreateTorus(options: {
  89901. diameter?: number;
  89902. thickness?: number;
  89903. tessellation?: number;
  89904. sideOrientation?: number;
  89905. frontUVs?: Vector4;
  89906. backUVs?: Vector4;
  89907. }): VertexData;
  89908. /**
  89909. * Creates the VertexData of the LineSystem
  89910. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89911. * - lines an array of lines, each line being an array of successive Vector3
  89912. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89913. * @returns the VertexData of the LineSystem
  89914. */
  89915. static CreateLineSystem(options: {
  89916. lines: Vector3[][];
  89917. colors?: Nullable<Color4[][]>;
  89918. }): VertexData;
  89919. /**
  89920. * Create the VertexData for a DashedLines
  89921. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89922. * - points an array successive Vector3
  89923. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89924. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89925. * - dashNb the intended total number of dashes, optional, default 200
  89926. * @returns the VertexData for the DashedLines
  89927. */
  89928. static CreateDashedLines(options: {
  89929. points: Vector3[];
  89930. dashSize?: number;
  89931. gapSize?: number;
  89932. dashNb?: number;
  89933. }): VertexData;
  89934. /**
  89935. * Creates the VertexData for a Ground
  89936. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89937. * - width the width (x direction) of the ground, optional, default 1
  89938. * - height the height (z direction) of the ground, optional, default 1
  89939. * - subdivisions the number of subdivisions per side, optional, default 1
  89940. * @returns the VertexData of the Ground
  89941. */
  89942. static CreateGround(options: {
  89943. width?: number;
  89944. height?: number;
  89945. subdivisions?: number;
  89946. subdivisionsX?: number;
  89947. subdivisionsY?: number;
  89948. }): VertexData;
  89949. /**
  89950. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89951. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89952. * * xmin the ground minimum X coordinate, optional, default -1
  89953. * * zmin the ground minimum Z coordinate, optional, default -1
  89954. * * xmax the ground maximum X coordinate, optional, default 1
  89955. * * zmax the ground maximum Z coordinate, optional, default 1
  89956. * * 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}
  89957. * * 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}
  89958. * @returns the VertexData of the TiledGround
  89959. */
  89960. static CreateTiledGround(options: {
  89961. xmin: number;
  89962. zmin: number;
  89963. xmax: number;
  89964. zmax: number;
  89965. subdivisions?: {
  89966. w: number;
  89967. h: number;
  89968. };
  89969. precision?: {
  89970. w: number;
  89971. h: number;
  89972. };
  89973. }): VertexData;
  89974. /**
  89975. * Creates the VertexData of the Ground designed from a heightmap
  89976. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89977. * * width the width (x direction) of the ground
  89978. * * height the height (z direction) of the ground
  89979. * * subdivisions the number of subdivisions per side
  89980. * * minHeight the minimum altitude on the ground, optional, default 0
  89981. * * maxHeight the maximum altitude on the ground, optional default 1
  89982. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89983. * * buffer the array holding the image color data
  89984. * * bufferWidth the width of image
  89985. * * bufferHeight the height of image
  89986. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89987. * @returns the VertexData of the Ground designed from a heightmap
  89988. */
  89989. static CreateGroundFromHeightMap(options: {
  89990. width: number;
  89991. height: number;
  89992. subdivisions: number;
  89993. minHeight: number;
  89994. maxHeight: number;
  89995. colorFilter: Color3;
  89996. buffer: Uint8Array;
  89997. bufferWidth: number;
  89998. bufferHeight: number;
  89999. alphaFilter: number;
  90000. }): VertexData;
  90001. /**
  90002. * Creates the VertexData for a Plane
  90003. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90004. * * size sets the width and height of the plane to the value of size, optional default 1
  90005. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90006. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90007. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90008. * * 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)
  90009. * * 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)
  90010. * @returns the VertexData of the box
  90011. */
  90012. static CreatePlane(options: {
  90013. size?: number;
  90014. width?: number;
  90015. height?: number;
  90016. sideOrientation?: number;
  90017. frontUVs?: Vector4;
  90018. backUVs?: Vector4;
  90019. }): VertexData;
  90020. /**
  90021. * Creates the VertexData of the Disc or regular Polygon
  90022. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90023. * * radius the radius of the disc, optional default 0.5
  90024. * * tessellation the number of polygon sides, optional, default 64
  90025. * * 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
  90026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90027. * * 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)
  90028. * * 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)
  90029. * @returns the VertexData of the box
  90030. */
  90031. static CreateDisc(options: {
  90032. radius?: number;
  90033. tessellation?: number;
  90034. arc?: number;
  90035. sideOrientation?: number;
  90036. frontUVs?: Vector4;
  90037. backUVs?: Vector4;
  90038. }): VertexData;
  90039. /**
  90040. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90041. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90042. * @param polygon a mesh built from polygonTriangulation.build()
  90043. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90044. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90045. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90046. * @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)
  90047. * @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)
  90048. * @returns the VertexData of the Polygon
  90049. */
  90050. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90051. /**
  90052. * Creates the VertexData of the IcoSphere
  90053. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90054. * * radius the radius of the IcoSphere, optional default 1
  90055. * * radiusX allows stretching in the x direction, optional, default radius
  90056. * * radiusY allows stretching in the y direction, optional, default radius
  90057. * * radiusZ allows stretching in the z direction, optional, default radius
  90058. * * flat when true creates a flat shaded mesh, optional, default true
  90059. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90061. * * 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)
  90062. * * 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)
  90063. * @returns the VertexData of the IcoSphere
  90064. */
  90065. static CreateIcoSphere(options: {
  90066. radius?: number;
  90067. radiusX?: number;
  90068. radiusY?: number;
  90069. radiusZ?: number;
  90070. flat?: boolean;
  90071. subdivisions?: number;
  90072. sideOrientation?: number;
  90073. frontUVs?: Vector4;
  90074. backUVs?: Vector4;
  90075. }): VertexData;
  90076. /**
  90077. * Creates the VertexData for a Polyhedron
  90078. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90079. * * type provided types are:
  90080. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90081. * * 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)
  90082. * * size the size of the IcoSphere, optional default 1
  90083. * * sizeX allows stretching in the x direction, optional, default size
  90084. * * sizeY allows stretching in the y direction, optional, default size
  90085. * * sizeZ allows stretching in the z direction, optional, default size
  90086. * * 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
  90087. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90088. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90089. * * flat when true creates a flat shaded mesh, optional, default true
  90090. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90091. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90092. * * 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)
  90093. * * 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)
  90094. * @returns the VertexData of the Polyhedron
  90095. */
  90096. static CreatePolyhedron(options: {
  90097. type?: number;
  90098. size?: number;
  90099. sizeX?: number;
  90100. sizeY?: number;
  90101. sizeZ?: number;
  90102. custom?: any;
  90103. faceUV?: Vector4[];
  90104. faceColors?: Color4[];
  90105. flat?: boolean;
  90106. sideOrientation?: number;
  90107. frontUVs?: Vector4;
  90108. backUVs?: Vector4;
  90109. }): VertexData;
  90110. /**
  90111. * Creates the VertexData for a TorusKnot
  90112. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90113. * * radius the radius of the torus knot, optional, default 2
  90114. * * tube the thickness of the tube, optional, default 0.5
  90115. * * radialSegments the number of sides on each tube segments, optional, default 32
  90116. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90117. * * p the number of windings around the z axis, optional, default 2
  90118. * * q the number of windings around the x axis, optional, default 3
  90119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90120. * * 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)
  90121. * * 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)
  90122. * @returns the VertexData of the Torus Knot
  90123. */
  90124. static CreateTorusKnot(options: {
  90125. radius?: number;
  90126. tube?: number;
  90127. radialSegments?: number;
  90128. tubularSegments?: number;
  90129. p?: number;
  90130. q?: number;
  90131. sideOrientation?: number;
  90132. frontUVs?: Vector4;
  90133. backUVs?: Vector4;
  90134. }): VertexData;
  90135. /**
  90136. * Compute normals for given positions and indices
  90137. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90138. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90139. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90140. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90141. * * facetNormals : optional array of facet normals (vector3)
  90142. * * facetPositions : optional array of facet positions (vector3)
  90143. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90144. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90145. * * bInfo : optional bounding info, required for facetPartitioning computation
  90146. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90147. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90148. * * useRightHandedSystem: optional boolean to for right handed system computation
  90149. * * depthSort : optional boolean to enable the facet depth sort computation
  90150. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90151. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90152. */
  90153. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90154. facetNormals?: any;
  90155. facetPositions?: any;
  90156. facetPartitioning?: any;
  90157. ratio?: number;
  90158. bInfo?: any;
  90159. bbSize?: Vector3;
  90160. subDiv?: any;
  90161. useRightHandedSystem?: boolean;
  90162. depthSort?: boolean;
  90163. distanceTo?: Vector3;
  90164. depthSortedFacets?: any;
  90165. }): void;
  90166. /** @hidden */
  90167. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90168. /**
  90169. * Applies VertexData created from the imported parameters to the geometry
  90170. * @param parsedVertexData the parsed data from an imported file
  90171. * @param geometry the geometry to apply the VertexData to
  90172. */
  90173. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90174. }
  90175. }
  90176. declare module BABYLON {
  90177. /**
  90178. * Defines a target to use with MorphTargetManager
  90179. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90180. */
  90181. export class MorphTarget implements IAnimatable {
  90182. /** defines the name of the target */
  90183. name: string;
  90184. /**
  90185. * Gets or sets the list of animations
  90186. */
  90187. animations: Animation[];
  90188. private _scene;
  90189. private _positions;
  90190. private _normals;
  90191. private _tangents;
  90192. private _uvs;
  90193. private _influence;
  90194. private _uniqueId;
  90195. /**
  90196. * Observable raised when the influence changes
  90197. */
  90198. onInfluenceChanged: Observable<boolean>;
  90199. /** @hidden */
  90200. _onDataLayoutChanged: Observable<void>;
  90201. /**
  90202. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90203. */
  90204. influence: number;
  90205. /**
  90206. * Gets or sets the id of the morph Target
  90207. */
  90208. id: string;
  90209. private _animationPropertiesOverride;
  90210. /**
  90211. * Gets or sets the animation properties override
  90212. */
  90213. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90214. /**
  90215. * Creates a new MorphTarget
  90216. * @param name defines the name of the target
  90217. * @param influence defines the influence to use
  90218. * @param scene defines the scene the morphtarget belongs to
  90219. */
  90220. constructor(
  90221. /** defines the name of the target */
  90222. name: string, influence?: number, scene?: Nullable<Scene>);
  90223. /**
  90224. * Gets the unique ID of this manager
  90225. */
  90226. readonly uniqueId: number;
  90227. /**
  90228. * Gets a boolean defining if the target contains position data
  90229. */
  90230. readonly hasPositions: boolean;
  90231. /**
  90232. * Gets a boolean defining if the target contains normal data
  90233. */
  90234. readonly hasNormals: boolean;
  90235. /**
  90236. * Gets a boolean defining if the target contains tangent data
  90237. */
  90238. readonly hasTangents: boolean;
  90239. /**
  90240. * Gets a boolean defining if the target contains texture coordinates data
  90241. */
  90242. readonly hasUVs: boolean;
  90243. /**
  90244. * Affects position data to this target
  90245. * @param data defines the position data to use
  90246. */
  90247. setPositions(data: Nullable<FloatArray>): void;
  90248. /**
  90249. * Gets the position data stored in this target
  90250. * @returns a FloatArray containing the position data (or null if not present)
  90251. */
  90252. getPositions(): Nullable<FloatArray>;
  90253. /**
  90254. * Affects normal data to this target
  90255. * @param data defines the normal data to use
  90256. */
  90257. setNormals(data: Nullable<FloatArray>): void;
  90258. /**
  90259. * Gets the normal data stored in this target
  90260. * @returns a FloatArray containing the normal data (or null if not present)
  90261. */
  90262. getNormals(): Nullable<FloatArray>;
  90263. /**
  90264. * Affects tangent data to this target
  90265. * @param data defines the tangent data to use
  90266. */
  90267. setTangents(data: Nullable<FloatArray>): void;
  90268. /**
  90269. * Gets the tangent data stored in this target
  90270. * @returns a FloatArray containing the tangent data (or null if not present)
  90271. */
  90272. getTangents(): Nullable<FloatArray>;
  90273. /**
  90274. * Affects texture coordinates data to this target
  90275. * @param data defines the texture coordinates data to use
  90276. */
  90277. setUVs(data: Nullable<FloatArray>): void;
  90278. /**
  90279. * Gets the texture coordinates data stored in this target
  90280. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90281. */
  90282. getUVs(): Nullable<FloatArray>;
  90283. /**
  90284. * Clone the current target
  90285. * @returns a new MorphTarget
  90286. */
  90287. clone(): MorphTarget;
  90288. /**
  90289. * Serializes the current target into a Serialization object
  90290. * @returns the serialized object
  90291. */
  90292. serialize(): any;
  90293. /**
  90294. * Returns the string "MorphTarget"
  90295. * @returns "MorphTarget"
  90296. */
  90297. getClassName(): string;
  90298. /**
  90299. * Creates a new target from serialized data
  90300. * @param serializationObject defines the serialized data to use
  90301. * @returns a new MorphTarget
  90302. */
  90303. static Parse(serializationObject: any): MorphTarget;
  90304. /**
  90305. * Creates a MorphTarget from mesh data
  90306. * @param mesh defines the source mesh
  90307. * @param name defines the name to use for the new target
  90308. * @param influence defines the influence to attach to the target
  90309. * @returns a new MorphTarget
  90310. */
  90311. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90312. }
  90313. }
  90314. declare module BABYLON {
  90315. /**
  90316. * This class is used to deform meshes using morphing between different targets
  90317. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90318. */
  90319. export class MorphTargetManager {
  90320. private _targets;
  90321. private _targetInfluenceChangedObservers;
  90322. private _targetDataLayoutChangedObservers;
  90323. private _activeTargets;
  90324. private _scene;
  90325. private _influences;
  90326. private _supportsNormals;
  90327. private _supportsTangents;
  90328. private _supportsUVs;
  90329. private _vertexCount;
  90330. private _uniqueId;
  90331. private _tempInfluences;
  90332. /**
  90333. * Gets or sets a boolean indicating if normals must be morphed
  90334. */
  90335. enableNormalMorphing: boolean;
  90336. /**
  90337. * Gets or sets a boolean indicating if tangents must be morphed
  90338. */
  90339. enableTangentMorphing: boolean;
  90340. /**
  90341. * Gets or sets a boolean indicating if UV must be morphed
  90342. */
  90343. enableUVMorphing: boolean;
  90344. /**
  90345. * Creates a new MorphTargetManager
  90346. * @param scene defines the current scene
  90347. */
  90348. constructor(scene?: Nullable<Scene>);
  90349. /**
  90350. * Gets the unique ID of this manager
  90351. */
  90352. readonly uniqueId: number;
  90353. /**
  90354. * Gets the number of vertices handled by this manager
  90355. */
  90356. readonly vertexCount: number;
  90357. /**
  90358. * Gets a boolean indicating if this manager supports morphing of normals
  90359. */
  90360. readonly supportsNormals: boolean;
  90361. /**
  90362. * Gets a boolean indicating if this manager supports morphing of tangents
  90363. */
  90364. readonly supportsTangents: boolean;
  90365. /**
  90366. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90367. */
  90368. readonly supportsUVs: boolean;
  90369. /**
  90370. * Gets the number of targets stored in this manager
  90371. */
  90372. readonly numTargets: number;
  90373. /**
  90374. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90375. */
  90376. readonly numInfluencers: number;
  90377. /**
  90378. * Gets the list of influences (one per target)
  90379. */
  90380. readonly influences: Float32Array;
  90381. /**
  90382. * Gets the active target at specified index. An active target is a target with an influence > 0
  90383. * @param index defines the index to check
  90384. * @returns the requested target
  90385. */
  90386. getActiveTarget(index: number): MorphTarget;
  90387. /**
  90388. * Gets the target at specified index
  90389. * @param index defines the index to check
  90390. * @returns the requested target
  90391. */
  90392. getTarget(index: number): MorphTarget;
  90393. /**
  90394. * Add a new target to this manager
  90395. * @param target defines the target to add
  90396. */
  90397. addTarget(target: MorphTarget): void;
  90398. /**
  90399. * Removes a target from the manager
  90400. * @param target defines the target to remove
  90401. */
  90402. removeTarget(target: MorphTarget): void;
  90403. /**
  90404. * Clone the current manager
  90405. * @returns a new MorphTargetManager
  90406. */
  90407. clone(): MorphTargetManager;
  90408. /**
  90409. * Serializes the current manager into a Serialization object
  90410. * @returns the serialized object
  90411. */
  90412. serialize(): any;
  90413. private _syncActiveTargets;
  90414. /**
  90415. * Syncrhonize the targets with all the meshes using this morph target manager
  90416. */
  90417. synchronize(): void;
  90418. /**
  90419. * Creates a new MorphTargetManager from serialized data
  90420. * @param serializationObject defines the serialized data
  90421. * @param scene defines the hosting scene
  90422. * @returns the new MorphTargetManager
  90423. */
  90424. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90425. }
  90426. }
  90427. declare module BABYLON {
  90428. /**
  90429. * Class used to represent a specific level of detail of a mesh
  90430. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90431. */
  90432. export class MeshLODLevel {
  90433. /** Defines the distance where this level should start being displayed */
  90434. distance: number;
  90435. /** Defines the mesh to use to render this level */
  90436. mesh: Nullable<Mesh>;
  90437. /**
  90438. * Creates a new LOD level
  90439. * @param distance defines the distance where this level should star being displayed
  90440. * @param mesh defines the mesh to use to render this level
  90441. */
  90442. constructor(
  90443. /** Defines the distance where this level should start being displayed */
  90444. distance: number,
  90445. /** Defines the mesh to use to render this level */
  90446. mesh: Nullable<Mesh>);
  90447. }
  90448. }
  90449. declare module BABYLON {
  90450. /**
  90451. * Mesh representing the gorund
  90452. */
  90453. export class GroundMesh extends Mesh {
  90454. /** If octree should be generated */
  90455. generateOctree: boolean;
  90456. private _heightQuads;
  90457. /** @hidden */
  90458. _subdivisionsX: number;
  90459. /** @hidden */
  90460. _subdivisionsY: number;
  90461. /** @hidden */
  90462. _width: number;
  90463. /** @hidden */
  90464. _height: number;
  90465. /** @hidden */
  90466. _minX: number;
  90467. /** @hidden */
  90468. _maxX: number;
  90469. /** @hidden */
  90470. _minZ: number;
  90471. /** @hidden */
  90472. _maxZ: number;
  90473. constructor(name: string, scene: Scene);
  90474. /**
  90475. * "GroundMesh"
  90476. * @returns "GroundMesh"
  90477. */
  90478. getClassName(): string;
  90479. /**
  90480. * The minimum of x and y subdivisions
  90481. */
  90482. readonly subdivisions: number;
  90483. /**
  90484. * X subdivisions
  90485. */
  90486. readonly subdivisionsX: number;
  90487. /**
  90488. * Y subdivisions
  90489. */
  90490. readonly subdivisionsY: number;
  90491. /**
  90492. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90493. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90494. * @param chunksCount the number of subdivisions for x and y
  90495. * @param octreeBlocksSize (Default: 32)
  90496. */
  90497. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90498. /**
  90499. * Returns a height (y) value in the Worl system :
  90500. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90501. * @param x x coordinate
  90502. * @param z z coordinate
  90503. * @returns the ground y position if (x, z) are outside the ground surface.
  90504. */
  90505. getHeightAtCoordinates(x: number, z: number): number;
  90506. /**
  90507. * Returns a normalized vector (Vector3) orthogonal to the ground
  90508. * at the ground coordinates (x, z) expressed in the World system.
  90509. * @param x x coordinate
  90510. * @param z z coordinate
  90511. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90512. */
  90513. getNormalAtCoordinates(x: number, z: number): Vector3;
  90514. /**
  90515. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90516. * at the ground coordinates (x, z) expressed in the World system.
  90517. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90518. * @param x x coordinate
  90519. * @param z z coordinate
  90520. * @param ref vector to store the result
  90521. * @returns the GroundMesh.
  90522. */
  90523. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90524. /**
  90525. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90526. * if the ground has been updated.
  90527. * This can be used in the render loop.
  90528. * @returns the GroundMesh.
  90529. */
  90530. updateCoordinateHeights(): GroundMesh;
  90531. private _getFacetAt;
  90532. private _initHeightQuads;
  90533. private _computeHeightQuads;
  90534. /**
  90535. * Serializes this ground mesh
  90536. * @param serializationObject object to write serialization to
  90537. */
  90538. serialize(serializationObject: any): void;
  90539. /**
  90540. * Parses a serialized ground mesh
  90541. * @param parsedMesh the serialized mesh
  90542. * @param scene the scene to create the ground mesh in
  90543. * @returns the created ground mesh
  90544. */
  90545. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90546. }
  90547. }
  90548. declare module BABYLON {
  90549. /**
  90550. * Interface for Physics-Joint data
  90551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90552. */
  90553. export interface PhysicsJointData {
  90554. /**
  90555. * The main pivot of the joint
  90556. */
  90557. mainPivot?: Vector3;
  90558. /**
  90559. * The connected pivot of the joint
  90560. */
  90561. connectedPivot?: Vector3;
  90562. /**
  90563. * The main axis of the joint
  90564. */
  90565. mainAxis?: Vector3;
  90566. /**
  90567. * The connected axis of the joint
  90568. */
  90569. connectedAxis?: Vector3;
  90570. /**
  90571. * The collision of the joint
  90572. */
  90573. collision?: boolean;
  90574. /**
  90575. * Native Oimo/Cannon/Energy data
  90576. */
  90577. nativeParams?: any;
  90578. }
  90579. /**
  90580. * This is a holder class for the physics joint created by the physics plugin
  90581. * It holds a set of functions to control the underlying joint
  90582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90583. */
  90584. export class PhysicsJoint {
  90585. /**
  90586. * The type of the physics joint
  90587. */
  90588. type: number;
  90589. /**
  90590. * The data for the physics joint
  90591. */
  90592. jointData: PhysicsJointData;
  90593. private _physicsJoint;
  90594. protected _physicsPlugin: IPhysicsEnginePlugin;
  90595. /**
  90596. * Initializes the physics joint
  90597. * @param type The type of the physics joint
  90598. * @param jointData The data for the physics joint
  90599. */
  90600. constructor(
  90601. /**
  90602. * The type of the physics joint
  90603. */
  90604. type: number,
  90605. /**
  90606. * The data for the physics joint
  90607. */
  90608. jointData: PhysicsJointData);
  90609. /**
  90610. * Gets the physics joint
  90611. */
  90612. /**
  90613. * Sets the physics joint
  90614. */
  90615. physicsJoint: any;
  90616. /**
  90617. * Sets the physics plugin
  90618. */
  90619. physicsPlugin: IPhysicsEnginePlugin;
  90620. /**
  90621. * Execute a function that is physics-plugin specific.
  90622. * @param {Function} func the function that will be executed.
  90623. * It accepts two parameters: the physics world and the physics joint
  90624. */
  90625. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90626. /**
  90627. * Distance-Joint type
  90628. */
  90629. static DistanceJoint: number;
  90630. /**
  90631. * Hinge-Joint type
  90632. */
  90633. static HingeJoint: number;
  90634. /**
  90635. * Ball-and-Socket joint type
  90636. */
  90637. static BallAndSocketJoint: number;
  90638. /**
  90639. * Wheel-Joint type
  90640. */
  90641. static WheelJoint: number;
  90642. /**
  90643. * Slider-Joint type
  90644. */
  90645. static SliderJoint: number;
  90646. /**
  90647. * Prismatic-Joint type
  90648. */
  90649. static PrismaticJoint: number;
  90650. /**
  90651. * Universal-Joint type
  90652. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90653. */
  90654. static UniversalJoint: number;
  90655. /**
  90656. * Hinge-Joint 2 type
  90657. */
  90658. static Hinge2Joint: number;
  90659. /**
  90660. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90661. */
  90662. static PointToPointJoint: number;
  90663. /**
  90664. * Spring-Joint type
  90665. */
  90666. static SpringJoint: number;
  90667. /**
  90668. * Lock-Joint type
  90669. */
  90670. static LockJoint: number;
  90671. }
  90672. /**
  90673. * A class representing a physics distance joint
  90674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90675. */
  90676. export class DistanceJoint extends PhysicsJoint {
  90677. /**
  90678. *
  90679. * @param jointData The data for the Distance-Joint
  90680. */
  90681. constructor(jointData: DistanceJointData);
  90682. /**
  90683. * Update the predefined distance.
  90684. * @param maxDistance The maximum preferred distance
  90685. * @param minDistance The minimum preferred distance
  90686. */
  90687. updateDistance(maxDistance: number, minDistance?: number): void;
  90688. }
  90689. /**
  90690. * Represents a Motor-Enabled Joint
  90691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90692. */
  90693. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90694. /**
  90695. * Initializes the Motor-Enabled Joint
  90696. * @param type The type of the joint
  90697. * @param jointData The physica joint data for the joint
  90698. */
  90699. constructor(type: number, jointData: PhysicsJointData);
  90700. /**
  90701. * Set the motor values.
  90702. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90703. * @param force the force to apply
  90704. * @param maxForce max force for this motor.
  90705. */
  90706. setMotor(force?: number, maxForce?: number): void;
  90707. /**
  90708. * Set the motor's limits.
  90709. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90710. * @param upperLimit The upper limit of the motor
  90711. * @param lowerLimit The lower limit of the motor
  90712. */
  90713. setLimit(upperLimit: number, lowerLimit?: number): void;
  90714. }
  90715. /**
  90716. * This class represents a single physics Hinge-Joint
  90717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90718. */
  90719. export class HingeJoint extends MotorEnabledJoint {
  90720. /**
  90721. * Initializes the Hinge-Joint
  90722. * @param jointData The joint data for the Hinge-Joint
  90723. */
  90724. constructor(jointData: PhysicsJointData);
  90725. /**
  90726. * Set the motor values.
  90727. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90728. * @param {number} force the force to apply
  90729. * @param {number} maxForce max force for this motor.
  90730. */
  90731. setMotor(force?: number, maxForce?: number): void;
  90732. /**
  90733. * Set the motor's limits.
  90734. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90735. * @param upperLimit The upper limit of the motor
  90736. * @param lowerLimit The lower limit of the motor
  90737. */
  90738. setLimit(upperLimit: number, lowerLimit?: number): void;
  90739. }
  90740. /**
  90741. * This class represents a dual hinge physics joint (same as wheel joint)
  90742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90743. */
  90744. export class Hinge2Joint extends MotorEnabledJoint {
  90745. /**
  90746. * Initializes the Hinge2-Joint
  90747. * @param jointData The joint data for the Hinge2-Joint
  90748. */
  90749. constructor(jointData: PhysicsJointData);
  90750. /**
  90751. * Set the motor values.
  90752. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90753. * @param {number} targetSpeed the speed the motor is to reach
  90754. * @param {number} maxForce max force for this motor.
  90755. * @param {motorIndex} the motor's index, 0 or 1.
  90756. */
  90757. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90758. /**
  90759. * Set the motor limits.
  90760. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90761. * @param {number} upperLimit the upper limit
  90762. * @param {number} lowerLimit lower limit
  90763. * @param {motorIndex} the motor's index, 0 or 1.
  90764. */
  90765. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90766. }
  90767. /**
  90768. * Interface for a motor enabled joint
  90769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90770. */
  90771. export interface IMotorEnabledJoint {
  90772. /**
  90773. * Physics joint
  90774. */
  90775. physicsJoint: any;
  90776. /**
  90777. * Sets the motor of the motor-enabled joint
  90778. * @param force The force of the motor
  90779. * @param maxForce The maximum force of the motor
  90780. * @param motorIndex The index of the motor
  90781. */
  90782. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90783. /**
  90784. * Sets the limit of the motor
  90785. * @param upperLimit The upper limit of the motor
  90786. * @param lowerLimit The lower limit of the motor
  90787. * @param motorIndex The index of the motor
  90788. */
  90789. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90790. }
  90791. /**
  90792. * Joint data for a Distance-Joint
  90793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90794. */
  90795. export interface DistanceJointData extends PhysicsJointData {
  90796. /**
  90797. * Max distance the 2 joint objects can be apart
  90798. */
  90799. maxDistance: number;
  90800. }
  90801. /**
  90802. * Joint data from a spring joint
  90803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90804. */
  90805. export interface SpringJointData extends PhysicsJointData {
  90806. /**
  90807. * Length of the spring
  90808. */
  90809. length: number;
  90810. /**
  90811. * Stiffness of the spring
  90812. */
  90813. stiffness: number;
  90814. /**
  90815. * Damping of the spring
  90816. */
  90817. damping: number;
  90818. /** this callback will be called when applying the force to the impostors. */
  90819. forceApplicationCallback: () => void;
  90820. }
  90821. }
  90822. declare module BABYLON {
  90823. /**
  90824. * Holds the data for the raycast result
  90825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90826. */
  90827. export class PhysicsRaycastResult {
  90828. private _hasHit;
  90829. private _hitDistance;
  90830. private _hitNormalWorld;
  90831. private _hitPointWorld;
  90832. private _rayFromWorld;
  90833. private _rayToWorld;
  90834. /**
  90835. * Gets if there was a hit
  90836. */
  90837. readonly hasHit: boolean;
  90838. /**
  90839. * Gets the distance from the hit
  90840. */
  90841. readonly hitDistance: number;
  90842. /**
  90843. * Gets the hit normal/direction in the world
  90844. */
  90845. readonly hitNormalWorld: Vector3;
  90846. /**
  90847. * Gets the hit point in the world
  90848. */
  90849. readonly hitPointWorld: Vector3;
  90850. /**
  90851. * Gets the ray "start point" of the ray in the world
  90852. */
  90853. readonly rayFromWorld: Vector3;
  90854. /**
  90855. * Gets the ray "end point" of the ray in the world
  90856. */
  90857. readonly rayToWorld: Vector3;
  90858. /**
  90859. * Sets the hit data (normal & point in world space)
  90860. * @param hitNormalWorld defines the normal in world space
  90861. * @param hitPointWorld defines the point in world space
  90862. */
  90863. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90864. /**
  90865. * Sets the distance from the start point to the hit point
  90866. * @param distance
  90867. */
  90868. setHitDistance(distance: number): void;
  90869. /**
  90870. * Calculates the distance manually
  90871. */
  90872. calculateHitDistance(): void;
  90873. /**
  90874. * Resets all the values to default
  90875. * @param from The from point on world space
  90876. * @param to The to point on world space
  90877. */
  90878. reset(from?: Vector3, to?: Vector3): void;
  90879. }
  90880. /**
  90881. * Interface for the size containing width and height
  90882. */
  90883. interface IXYZ {
  90884. /**
  90885. * X
  90886. */
  90887. x: number;
  90888. /**
  90889. * Y
  90890. */
  90891. y: number;
  90892. /**
  90893. * Z
  90894. */
  90895. z: number;
  90896. }
  90897. }
  90898. declare module BABYLON {
  90899. /**
  90900. * Interface used to describe a physics joint
  90901. */
  90902. export interface PhysicsImpostorJoint {
  90903. /** Defines the main impostor to which the joint is linked */
  90904. mainImpostor: PhysicsImpostor;
  90905. /** Defines the impostor that is connected to the main impostor using this joint */
  90906. connectedImpostor: PhysicsImpostor;
  90907. /** Defines the joint itself */
  90908. joint: PhysicsJoint;
  90909. }
  90910. /** @hidden */
  90911. export interface IPhysicsEnginePlugin {
  90912. world: any;
  90913. name: string;
  90914. setGravity(gravity: Vector3): void;
  90915. setTimeStep(timeStep: number): void;
  90916. getTimeStep(): number;
  90917. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90918. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90920. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90921. removePhysicsBody(impostor: PhysicsImpostor): void;
  90922. generateJoint(joint: PhysicsImpostorJoint): void;
  90923. removeJoint(joint: PhysicsImpostorJoint): void;
  90924. isSupported(): boolean;
  90925. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90926. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90927. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90928. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90930. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90931. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90932. getBodyMass(impostor: PhysicsImpostor): number;
  90933. getBodyFriction(impostor: PhysicsImpostor): number;
  90934. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90935. getBodyRestitution(impostor: PhysicsImpostor): number;
  90936. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90937. getBodyPressure?(impostor: PhysicsImpostor): number;
  90938. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90939. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90940. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90941. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90942. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90943. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90944. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90945. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90946. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90947. sleepBody(impostor: PhysicsImpostor): void;
  90948. wakeUpBody(impostor: PhysicsImpostor): void;
  90949. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90950. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90951. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90952. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90953. getRadius(impostor: PhysicsImpostor): number;
  90954. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90955. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90956. dispose(): void;
  90957. }
  90958. /**
  90959. * Interface used to define a physics engine
  90960. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90961. */
  90962. export interface IPhysicsEngine {
  90963. /**
  90964. * Gets the gravity vector used by the simulation
  90965. */
  90966. gravity: Vector3;
  90967. /**
  90968. * Sets the gravity vector used by the simulation
  90969. * @param gravity defines the gravity vector to use
  90970. */
  90971. setGravity(gravity: Vector3): void;
  90972. /**
  90973. * Set the time step of the physics engine.
  90974. * Default is 1/60.
  90975. * To slow it down, enter 1/600 for example.
  90976. * To speed it up, 1/30
  90977. * @param newTimeStep the new timestep to apply to this world.
  90978. */
  90979. setTimeStep(newTimeStep: number): void;
  90980. /**
  90981. * Get the time step of the physics engine.
  90982. * @returns the current time step
  90983. */
  90984. getTimeStep(): number;
  90985. /**
  90986. * Release all resources
  90987. */
  90988. dispose(): void;
  90989. /**
  90990. * Gets the name of the current physics plugin
  90991. * @returns the name of the plugin
  90992. */
  90993. getPhysicsPluginName(): string;
  90994. /**
  90995. * Adding a new impostor for the impostor tracking.
  90996. * This will be done by the impostor itself.
  90997. * @param impostor the impostor to add
  90998. */
  90999. addImpostor(impostor: PhysicsImpostor): void;
  91000. /**
  91001. * Remove an impostor from the engine.
  91002. * This impostor and its mesh will not longer be updated by the physics engine.
  91003. * @param impostor the impostor to remove
  91004. */
  91005. removeImpostor(impostor: PhysicsImpostor): void;
  91006. /**
  91007. * Add a joint to the physics engine
  91008. * @param mainImpostor defines the main impostor to which the joint is added.
  91009. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91010. * @param joint defines the joint that will connect both impostors.
  91011. */
  91012. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91013. /**
  91014. * Removes a joint from the simulation
  91015. * @param mainImpostor defines the impostor used with the joint
  91016. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91017. * @param joint defines the joint to remove
  91018. */
  91019. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91020. /**
  91021. * Gets the current plugin used to run the simulation
  91022. * @returns current plugin
  91023. */
  91024. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91025. /**
  91026. * Gets the list of physic impostors
  91027. * @returns an array of PhysicsImpostor
  91028. */
  91029. getImpostors(): Array<PhysicsImpostor>;
  91030. /**
  91031. * Gets the impostor for a physics enabled object
  91032. * @param object defines the object impersonated by the impostor
  91033. * @returns the PhysicsImpostor or null if not found
  91034. */
  91035. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91036. /**
  91037. * Gets the impostor for a physics body object
  91038. * @param body defines physics body used by the impostor
  91039. * @returns the PhysicsImpostor or null if not found
  91040. */
  91041. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91042. /**
  91043. * Does a raycast in the physics world
  91044. * @param from when should the ray start?
  91045. * @param to when should the ray end?
  91046. * @returns PhysicsRaycastResult
  91047. */
  91048. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91049. /**
  91050. * Called by the scene. No need to call it.
  91051. * @param delta defines the timespam between frames
  91052. */
  91053. _step(delta: number): void;
  91054. }
  91055. }
  91056. declare module BABYLON {
  91057. /**
  91058. * The interface for the physics imposter parameters
  91059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91060. */
  91061. export interface PhysicsImpostorParameters {
  91062. /**
  91063. * The mass of the physics imposter
  91064. */
  91065. mass: number;
  91066. /**
  91067. * The friction of the physics imposter
  91068. */
  91069. friction?: number;
  91070. /**
  91071. * The coefficient of restitution of the physics imposter
  91072. */
  91073. restitution?: number;
  91074. /**
  91075. * The native options of the physics imposter
  91076. */
  91077. nativeOptions?: any;
  91078. /**
  91079. * Specifies if the parent should be ignored
  91080. */
  91081. ignoreParent?: boolean;
  91082. /**
  91083. * Specifies if bi-directional transformations should be disabled
  91084. */
  91085. disableBidirectionalTransformation?: boolean;
  91086. /**
  91087. * The pressure inside the physics imposter, soft object only
  91088. */
  91089. pressure?: number;
  91090. /**
  91091. * The stiffness the physics imposter, soft object only
  91092. */
  91093. stiffness?: number;
  91094. /**
  91095. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91096. */
  91097. velocityIterations?: number;
  91098. /**
  91099. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91100. */
  91101. positionIterations?: number;
  91102. /**
  91103. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91104. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91105. * Add to fix multiple points
  91106. */
  91107. fixedPoints?: number;
  91108. /**
  91109. * The collision margin around a soft object
  91110. */
  91111. margin?: number;
  91112. /**
  91113. * The collision margin around a soft object
  91114. */
  91115. damping?: number;
  91116. /**
  91117. * The path for a rope based on an extrusion
  91118. */
  91119. path?: any;
  91120. /**
  91121. * The shape of an extrusion used for a rope based on an extrusion
  91122. */
  91123. shape?: any;
  91124. }
  91125. /**
  91126. * Interface for a physics-enabled object
  91127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91128. */
  91129. export interface IPhysicsEnabledObject {
  91130. /**
  91131. * The position of the physics-enabled object
  91132. */
  91133. position: Vector3;
  91134. /**
  91135. * The rotation of the physics-enabled object
  91136. */
  91137. rotationQuaternion: Nullable<Quaternion>;
  91138. /**
  91139. * The scale of the physics-enabled object
  91140. */
  91141. scaling: Vector3;
  91142. /**
  91143. * The rotation of the physics-enabled object
  91144. */
  91145. rotation?: Vector3;
  91146. /**
  91147. * The parent of the physics-enabled object
  91148. */
  91149. parent?: any;
  91150. /**
  91151. * The bounding info of the physics-enabled object
  91152. * @returns The bounding info of the physics-enabled object
  91153. */
  91154. getBoundingInfo(): BoundingInfo;
  91155. /**
  91156. * Computes the world matrix
  91157. * @param force Specifies if the world matrix should be computed by force
  91158. * @returns A world matrix
  91159. */
  91160. computeWorldMatrix(force: boolean): Matrix;
  91161. /**
  91162. * Gets the world matrix
  91163. * @returns A world matrix
  91164. */
  91165. getWorldMatrix?(): Matrix;
  91166. /**
  91167. * Gets the child meshes
  91168. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91169. * @returns An array of abstract meshes
  91170. */
  91171. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91172. /**
  91173. * Gets the vertex data
  91174. * @param kind The type of vertex data
  91175. * @returns A nullable array of numbers, or a float32 array
  91176. */
  91177. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91178. /**
  91179. * Gets the indices from the mesh
  91180. * @returns A nullable array of index arrays
  91181. */
  91182. getIndices?(): Nullable<IndicesArray>;
  91183. /**
  91184. * Gets the scene from the mesh
  91185. * @returns the indices array or null
  91186. */
  91187. getScene?(): Scene;
  91188. /**
  91189. * Gets the absolute position from the mesh
  91190. * @returns the absolute position
  91191. */
  91192. getAbsolutePosition(): Vector3;
  91193. /**
  91194. * Gets the absolute pivot point from the mesh
  91195. * @returns the absolute pivot point
  91196. */
  91197. getAbsolutePivotPoint(): Vector3;
  91198. /**
  91199. * Rotates the mesh
  91200. * @param axis The axis of rotation
  91201. * @param amount The amount of rotation
  91202. * @param space The space of the rotation
  91203. * @returns The rotation transform node
  91204. */
  91205. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91206. /**
  91207. * Translates the mesh
  91208. * @param axis The axis of translation
  91209. * @param distance The distance of translation
  91210. * @param space The space of the translation
  91211. * @returns The transform node
  91212. */
  91213. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91214. /**
  91215. * Sets the absolute position of the mesh
  91216. * @param absolutePosition The absolute position of the mesh
  91217. * @returns The transform node
  91218. */
  91219. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91220. /**
  91221. * Gets the class name of the mesh
  91222. * @returns The class name
  91223. */
  91224. getClassName(): string;
  91225. }
  91226. /**
  91227. * Represents a physics imposter
  91228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91229. */
  91230. export class PhysicsImpostor {
  91231. /**
  91232. * The physics-enabled object used as the physics imposter
  91233. */
  91234. object: IPhysicsEnabledObject;
  91235. /**
  91236. * The type of the physics imposter
  91237. */
  91238. type: number;
  91239. private _options;
  91240. private _scene?;
  91241. /**
  91242. * The default object size of the imposter
  91243. */
  91244. static DEFAULT_OBJECT_SIZE: Vector3;
  91245. /**
  91246. * The identity quaternion of the imposter
  91247. */
  91248. static IDENTITY_QUATERNION: Quaternion;
  91249. /** @hidden */
  91250. _pluginData: any;
  91251. private _physicsEngine;
  91252. private _physicsBody;
  91253. private _bodyUpdateRequired;
  91254. private _onBeforePhysicsStepCallbacks;
  91255. private _onAfterPhysicsStepCallbacks;
  91256. /** @hidden */
  91257. _onPhysicsCollideCallbacks: Array<{
  91258. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91259. otherImpostors: Array<PhysicsImpostor>;
  91260. }>;
  91261. private _deltaPosition;
  91262. private _deltaRotation;
  91263. private _deltaRotationConjugated;
  91264. /** @hidden */
  91265. _isFromLine: boolean;
  91266. private _parent;
  91267. private _isDisposed;
  91268. private static _tmpVecs;
  91269. private static _tmpQuat;
  91270. /**
  91271. * Specifies if the physics imposter is disposed
  91272. */
  91273. readonly isDisposed: boolean;
  91274. /**
  91275. * Gets the mass of the physics imposter
  91276. */
  91277. mass: number;
  91278. /**
  91279. * Gets the coefficient of friction
  91280. */
  91281. /**
  91282. * Sets the coefficient of friction
  91283. */
  91284. friction: number;
  91285. /**
  91286. * Gets the coefficient of restitution
  91287. */
  91288. /**
  91289. * Sets the coefficient of restitution
  91290. */
  91291. restitution: number;
  91292. /**
  91293. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91294. */
  91295. /**
  91296. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91297. */
  91298. pressure: number;
  91299. /**
  91300. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91301. */
  91302. /**
  91303. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91304. */
  91305. stiffness: number;
  91306. /**
  91307. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91308. */
  91309. /**
  91310. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91311. */
  91312. velocityIterations: number;
  91313. /**
  91314. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91315. */
  91316. /**
  91317. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91318. */
  91319. positionIterations: number;
  91320. /**
  91321. * The unique id of the physics imposter
  91322. * set by the physics engine when adding this impostor to the array
  91323. */
  91324. uniqueId: number;
  91325. /**
  91326. * @hidden
  91327. */
  91328. soft: boolean;
  91329. /**
  91330. * @hidden
  91331. */
  91332. segments: number;
  91333. private _joints;
  91334. /**
  91335. * Initializes the physics imposter
  91336. * @param object The physics-enabled object used as the physics imposter
  91337. * @param type The type of the physics imposter
  91338. * @param _options The options for the physics imposter
  91339. * @param _scene The Babylon scene
  91340. */
  91341. constructor(
  91342. /**
  91343. * The physics-enabled object used as the physics imposter
  91344. */
  91345. object: IPhysicsEnabledObject,
  91346. /**
  91347. * The type of the physics imposter
  91348. */
  91349. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91350. /**
  91351. * This function will completly initialize this impostor.
  91352. * It will create a new body - but only if this mesh has no parent.
  91353. * If it has, this impostor will not be used other than to define the impostor
  91354. * of the child mesh.
  91355. * @hidden
  91356. */
  91357. _init(): void;
  91358. private _getPhysicsParent;
  91359. /**
  91360. * Should a new body be generated.
  91361. * @returns boolean specifying if body initialization is required
  91362. */
  91363. isBodyInitRequired(): boolean;
  91364. /**
  91365. * Sets the updated scaling
  91366. * @param updated Specifies if the scaling is updated
  91367. */
  91368. setScalingUpdated(): void;
  91369. /**
  91370. * Force a regeneration of this or the parent's impostor's body.
  91371. * Use under cautious - This will remove all joints already implemented.
  91372. */
  91373. forceUpdate(): void;
  91374. /**
  91375. * Gets the body that holds this impostor. Either its own, or its parent.
  91376. */
  91377. /**
  91378. * Set the physics body. Used mainly by the physics engine/plugin
  91379. */
  91380. physicsBody: any;
  91381. /**
  91382. * Get the parent of the physics imposter
  91383. * @returns Physics imposter or null
  91384. */
  91385. /**
  91386. * Sets the parent of the physics imposter
  91387. */
  91388. parent: Nullable<PhysicsImpostor>;
  91389. /**
  91390. * Resets the update flags
  91391. */
  91392. resetUpdateFlags(): void;
  91393. /**
  91394. * Gets the object extend size
  91395. * @returns the object extend size
  91396. */
  91397. getObjectExtendSize(): Vector3;
  91398. /**
  91399. * Gets the object center
  91400. * @returns The object center
  91401. */
  91402. getObjectCenter(): Vector3;
  91403. /**
  91404. * Get a specific parametes from the options parameter
  91405. * @param paramName The object parameter name
  91406. * @returns The object parameter
  91407. */
  91408. getParam(paramName: string): any;
  91409. /**
  91410. * Sets a specific parameter in the options given to the physics plugin
  91411. * @param paramName The parameter name
  91412. * @param value The value of the parameter
  91413. */
  91414. setParam(paramName: string, value: number): void;
  91415. /**
  91416. * Specifically change the body's mass option. Won't recreate the physics body object
  91417. * @param mass The mass of the physics imposter
  91418. */
  91419. setMass(mass: number): void;
  91420. /**
  91421. * Gets the linear velocity
  91422. * @returns linear velocity or null
  91423. */
  91424. getLinearVelocity(): Nullable<Vector3>;
  91425. /**
  91426. * Sets the linear velocity
  91427. * @param velocity linear velocity or null
  91428. */
  91429. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91430. /**
  91431. * Gets the angular velocity
  91432. * @returns angular velocity or null
  91433. */
  91434. getAngularVelocity(): Nullable<Vector3>;
  91435. /**
  91436. * Sets the angular velocity
  91437. * @param velocity The velocity or null
  91438. */
  91439. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91440. /**
  91441. * Execute a function with the physics plugin native code
  91442. * Provide a function the will have two variables - the world object and the physics body object
  91443. * @param func The function to execute with the physics plugin native code
  91444. */
  91445. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91446. /**
  91447. * Register a function that will be executed before the physics world is stepping forward
  91448. * @param func The function to execute before the physics world is stepped forward
  91449. */
  91450. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91451. /**
  91452. * Unregister a function that will be executed before the physics world is stepping forward
  91453. * @param func The function to execute before the physics world is stepped forward
  91454. */
  91455. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91456. /**
  91457. * Register a function that will be executed after the physics step
  91458. * @param func The function to execute after physics step
  91459. */
  91460. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91461. /**
  91462. * Unregisters a function that will be executed after the physics step
  91463. * @param func The function to execute after physics step
  91464. */
  91465. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91466. /**
  91467. * register a function that will be executed when this impostor collides against a different body
  91468. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91469. * @param func Callback that is executed on collision
  91470. */
  91471. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91472. /**
  91473. * Unregisters the physics imposter on contact
  91474. * @param collideAgainst The physics object to collide against
  91475. * @param func Callback to execute on collision
  91476. */
  91477. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91478. private _tmpQuat;
  91479. private _tmpQuat2;
  91480. /**
  91481. * Get the parent rotation
  91482. * @returns The parent rotation
  91483. */
  91484. getParentsRotation(): Quaternion;
  91485. /**
  91486. * this function is executed by the physics engine.
  91487. */
  91488. beforeStep: () => void;
  91489. /**
  91490. * this function is executed by the physics engine
  91491. */
  91492. afterStep: () => void;
  91493. /**
  91494. * Legacy collision detection event support
  91495. */
  91496. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91497. /**
  91498. * event and body object due to cannon's event-based architecture.
  91499. */
  91500. onCollide: (e: {
  91501. body: any;
  91502. }) => void;
  91503. /**
  91504. * Apply a force
  91505. * @param force The force to apply
  91506. * @param contactPoint The contact point for the force
  91507. * @returns The physics imposter
  91508. */
  91509. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91510. /**
  91511. * Apply an impulse
  91512. * @param force The impulse force
  91513. * @param contactPoint The contact point for the impulse force
  91514. * @returns The physics imposter
  91515. */
  91516. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91517. /**
  91518. * A help function to create a joint
  91519. * @param otherImpostor A physics imposter used to create a joint
  91520. * @param jointType The type of joint
  91521. * @param jointData The data for the joint
  91522. * @returns The physics imposter
  91523. */
  91524. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91525. /**
  91526. * Add a joint to this impostor with a different impostor
  91527. * @param otherImpostor A physics imposter used to add a joint
  91528. * @param joint The joint to add
  91529. * @returns The physics imposter
  91530. */
  91531. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91532. /**
  91533. * Add an anchor to a cloth impostor
  91534. * @param otherImpostor rigid impostor to anchor to
  91535. * @param width ratio across width from 0 to 1
  91536. * @param height ratio up height from 0 to 1
  91537. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91538. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91539. * @returns impostor the soft imposter
  91540. */
  91541. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91542. /**
  91543. * Add a hook to a rope impostor
  91544. * @param otherImpostor rigid impostor to anchor to
  91545. * @param length ratio across rope from 0 to 1
  91546. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91547. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91548. * @returns impostor the rope imposter
  91549. */
  91550. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91551. /**
  91552. * Will keep this body still, in a sleep mode.
  91553. * @returns the physics imposter
  91554. */
  91555. sleep(): PhysicsImpostor;
  91556. /**
  91557. * Wake the body up.
  91558. * @returns The physics imposter
  91559. */
  91560. wakeUp(): PhysicsImpostor;
  91561. /**
  91562. * Clones the physics imposter
  91563. * @param newObject The physics imposter clones to this physics-enabled object
  91564. * @returns A nullable physics imposter
  91565. */
  91566. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91567. /**
  91568. * Disposes the physics imposter
  91569. */
  91570. dispose(): void;
  91571. /**
  91572. * Sets the delta position
  91573. * @param position The delta position amount
  91574. */
  91575. setDeltaPosition(position: Vector3): void;
  91576. /**
  91577. * Sets the delta rotation
  91578. * @param rotation The delta rotation amount
  91579. */
  91580. setDeltaRotation(rotation: Quaternion): void;
  91581. /**
  91582. * Gets the box size of the physics imposter and stores the result in the input parameter
  91583. * @param result Stores the box size
  91584. * @returns The physics imposter
  91585. */
  91586. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91587. /**
  91588. * Gets the radius of the physics imposter
  91589. * @returns Radius of the physics imposter
  91590. */
  91591. getRadius(): number;
  91592. /**
  91593. * Sync a bone with this impostor
  91594. * @param bone The bone to sync to the impostor.
  91595. * @param boneMesh The mesh that the bone is influencing.
  91596. * @param jointPivot The pivot of the joint / bone in local space.
  91597. * @param distToJoint Optional distance from the impostor to the joint.
  91598. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91599. */
  91600. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91601. /**
  91602. * Sync impostor to a bone
  91603. * @param bone The bone that the impostor will be synced to.
  91604. * @param boneMesh The mesh that the bone is influencing.
  91605. * @param jointPivot The pivot of the joint / bone in local space.
  91606. * @param distToJoint Optional distance from the impostor to the joint.
  91607. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91608. * @param boneAxis Optional vector3 axis the bone is aligned with
  91609. */
  91610. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91611. /**
  91612. * No-Imposter type
  91613. */
  91614. static NoImpostor: number;
  91615. /**
  91616. * Sphere-Imposter type
  91617. */
  91618. static SphereImpostor: number;
  91619. /**
  91620. * Box-Imposter type
  91621. */
  91622. static BoxImpostor: number;
  91623. /**
  91624. * Plane-Imposter type
  91625. */
  91626. static PlaneImpostor: number;
  91627. /**
  91628. * Mesh-imposter type
  91629. */
  91630. static MeshImpostor: number;
  91631. /**
  91632. * Capsule-Impostor type (Ammo.js plugin only)
  91633. */
  91634. static CapsuleImpostor: number;
  91635. /**
  91636. * Cylinder-Imposter type
  91637. */
  91638. static CylinderImpostor: number;
  91639. /**
  91640. * Particle-Imposter type
  91641. */
  91642. static ParticleImpostor: number;
  91643. /**
  91644. * Heightmap-Imposter type
  91645. */
  91646. static HeightmapImpostor: number;
  91647. /**
  91648. * ConvexHull-Impostor type (Ammo.js plugin only)
  91649. */
  91650. static ConvexHullImpostor: number;
  91651. /**
  91652. * Rope-Imposter type
  91653. */
  91654. static RopeImpostor: number;
  91655. /**
  91656. * Cloth-Imposter type
  91657. */
  91658. static ClothImpostor: number;
  91659. /**
  91660. * Softbody-Imposter type
  91661. */
  91662. static SoftbodyImpostor: number;
  91663. }
  91664. }
  91665. declare module BABYLON {
  91666. /**
  91667. * @hidden
  91668. **/
  91669. export class _CreationDataStorage {
  91670. closePath?: boolean;
  91671. closeArray?: boolean;
  91672. idx: number[];
  91673. dashSize: number;
  91674. gapSize: number;
  91675. path3D: Path3D;
  91676. pathArray: Vector3[][];
  91677. arc: number;
  91678. radius: number;
  91679. cap: number;
  91680. tessellation: number;
  91681. }
  91682. /**
  91683. * @hidden
  91684. **/
  91685. class _InstanceDataStorage {
  91686. visibleInstances: any;
  91687. batchCache: _InstancesBatch;
  91688. instancesBufferSize: number;
  91689. instancesBuffer: Nullable<Buffer>;
  91690. instancesData: Float32Array;
  91691. overridenInstanceCount: number;
  91692. isFrozen: boolean;
  91693. previousBatch: Nullable<_InstancesBatch>;
  91694. hardwareInstancedRendering: boolean;
  91695. sideOrientation: number;
  91696. }
  91697. /**
  91698. * @hidden
  91699. **/
  91700. export class _InstancesBatch {
  91701. mustReturn: boolean;
  91702. visibleInstances: Nullable<InstancedMesh[]>[];
  91703. renderSelf: boolean[];
  91704. hardwareInstancedRendering: boolean[];
  91705. }
  91706. /**
  91707. * Class used to represent renderable models
  91708. */
  91709. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91710. /**
  91711. * Mesh side orientation : usually the external or front surface
  91712. */
  91713. static readonly FRONTSIDE: number;
  91714. /**
  91715. * Mesh side orientation : usually the internal or back surface
  91716. */
  91717. static readonly BACKSIDE: number;
  91718. /**
  91719. * Mesh side orientation : both internal and external or front and back surfaces
  91720. */
  91721. static readonly DOUBLESIDE: number;
  91722. /**
  91723. * Mesh side orientation : by default, `FRONTSIDE`
  91724. */
  91725. static readonly DEFAULTSIDE: number;
  91726. /**
  91727. * Mesh cap setting : no cap
  91728. */
  91729. static readonly NO_CAP: number;
  91730. /**
  91731. * Mesh cap setting : one cap at the beginning of the mesh
  91732. */
  91733. static readonly CAP_START: number;
  91734. /**
  91735. * Mesh cap setting : one cap at the end of the mesh
  91736. */
  91737. static readonly CAP_END: number;
  91738. /**
  91739. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91740. */
  91741. static readonly CAP_ALL: number;
  91742. /**
  91743. * Mesh pattern setting : no flip or rotate
  91744. */
  91745. static readonly NO_FLIP: number;
  91746. /**
  91747. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91748. */
  91749. static readonly FLIP_TILE: number;
  91750. /**
  91751. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91752. */
  91753. static readonly ROTATE_TILE: number;
  91754. /**
  91755. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91756. */
  91757. static readonly FLIP_ROW: number;
  91758. /**
  91759. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91760. */
  91761. static readonly ROTATE_ROW: number;
  91762. /**
  91763. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91764. */
  91765. static readonly FLIP_N_ROTATE_TILE: number;
  91766. /**
  91767. * Mesh pattern setting : rotate pattern and rotate
  91768. */
  91769. static readonly FLIP_N_ROTATE_ROW: number;
  91770. /**
  91771. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91772. */
  91773. static readonly CENTER: number;
  91774. /**
  91775. * Mesh tile positioning : part tiles on left
  91776. */
  91777. static readonly LEFT: number;
  91778. /**
  91779. * Mesh tile positioning : part tiles on right
  91780. */
  91781. static readonly RIGHT: number;
  91782. /**
  91783. * Mesh tile positioning : part tiles on top
  91784. */
  91785. static readonly TOP: number;
  91786. /**
  91787. * Mesh tile positioning : part tiles on bottom
  91788. */
  91789. static readonly BOTTOM: number;
  91790. /**
  91791. * Gets the default side orientation.
  91792. * @param orientation the orientation to value to attempt to get
  91793. * @returns the default orientation
  91794. * @hidden
  91795. */
  91796. static _GetDefaultSideOrientation(orientation?: number): number;
  91797. private _internalMeshDataInfo;
  91798. /**
  91799. * An event triggered before rendering the mesh
  91800. */
  91801. readonly onBeforeRenderObservable: Observable<Mesh>;
  91802. /**
  91803. * An event triggered before binding the mesh
  91804. */
  91805. readonly onBeforeBindObservable: Observable<Mesh>;
  91806. /**
  91807. * An event triggered after rendering the mesh
  91808. */
  91809. readonly onAfterRenderObservable: Observable<Mesh>;
  91810. /**
  91811. * An event triggered before drawing the mesh
  91812. */
  91813. readonly onBeforeDrawObservable: Observable<Mesh>;
  91814. private _onBeforeDrawObserver;
  91815. /**
  91816. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91817. */
  91818. onBeforeDraw: () => void;
  91819. readonly hasInstances: boolean;
  91820. /**
  91821. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91822. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91823. */
  91824. delayLoadState: number;
  91825. /**
  91826. * Gets the list of instances created from this mesh
  91827. * it is not supposed to be modified manually.
  91828. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91829. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91830. */
  91831. instances: InstancedMesh[];
  91832. /**
  91833. * Gets the file containing delay loading data for this mesh
  91834. */
  91835. delayLoadingFile: string;
  91836. /** @hidden */
  91837. _binaryInfo: any;
  91838. /**
  91839. * User defined function used to change how LOD level selection is done
  91840. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91841. */
  91842. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91843. /**
  91844. * Gets or sets the morph target manager
  91845. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91846. */
  91847. morphTargetManager: Nullable<MorphTargetManager>;
  91848. /** @hidden */
  91849. _creationDataStorage: Nullable<_CreationDataStorage>;
  91850. /** @hidden */
  91851. _geometry: Nullable<Geometry>;
  91852. /** @hidden */
  91853. _delayInfo: Array<string>;
  91854. /** @hidden */
  91855. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91856. /** @hidden */
  91857. _instanceDataStorage: _InstanceDataStorage;
  91858. private _effectiveMaterial;
  91859. /** @hidden */
  91860. _shouldGenerateFlatShading: boolean;
  91861. /** @hidden */
  91862. _originalBuilderSideOrientation: number;
  91863. /**
  91864. * Use this property to change the original side orientation defined at construction time
  91865. */
  91866. overrideMaterialSideOrientation: Nullable<number>;
  91867. /**
  91868. * Gets the source mesh (the one used to clone this one from)
  91869. */
  91870. readonly source: Nullable<Mesh>;
  91871. /**
  91872. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91873. */
  91874. isUnIndexed: boolean;
  91875. /**
  91876. * @constructor
  91877. * @param name The value used by scene.getMeshByName() to do a lookup.
  91878. * @param scene The scene to add this mesh to.
  91879. * @param parent The parent of this mesh, if it has one
  91880. * @param source An optional Mesh from which geometry is shared, cloned.
  91881. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91882. * When false, achieved by calling a clone(), also passing False.
  91883. * This will make creation of children, recursive.
  91884. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91885. */
  91886. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91887. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91888. doNotInstantiate: boolean;
  91889. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91890. /**
  91891. * Gets the class name
  91892. * @returns the string "Mesh".
  91893. */
  91894. getClassName(): string;
  91895. /** @hidden */
  91896. readonly _isMesh: boolean;
  91897. /**
  91898. * Returns a description of this mesh
  91899. * @param fullDetails define if full details about this mesh must be used
  91900. * @returns a descriptive string representing this mesh
  91901. */
  91902. toString(fullDetails?: boolean): string;
  91903. /** @hidden */
  91904. _unBindEffect(): void;
  91905. /**
  91906. * Gets a boolean indicating if this mesh has LOD
  91907. */
  91908. readonly hasLODLevels: boolean;
  91909. /**
  91910. * Gets the list of MeshLODLevel associated with the current mesh
  91911. * @returns an array of MeshLODLevel
  91912. */
  91913. getLODLevels(): MeshLODLevel[];
  91914. private _sortLODLevels;
  91915. /**
  91916. * Add a mesh as LOD level triggered at the given distance.
  91917. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91918. * @param distance The distance from the center of the object to show this level
  91919. * @param mesh The mesh to be added as LOD level (can be null)
  91920. * @return This mesh (for chaining)
  91921. */
  91922. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91923. /**
  91924. * Returns the LOD level mesh at the passed distance or null if not found.
  91925. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91926. * @param distance The distance from the center of the object to show this level
  91927. * @returns a Mesh or `null`
  91928. */
  91929. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91930. /**
  91931. * Remove a mesh from the LOD array
  91932. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91933. * @param mesh defines the mesh to be removed
  91934. * @return This mesh (for chaining)
  91935. */
  91936. removeLODLevel(mesh: Mesh): Mesh;
  91937. /**
  91938. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91939. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91940. * @param camera defines the camera to use to compute distance
  91941. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91942. * @return This mesh (for chaining)
  91943. */
  91944. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91945. /**
  91946. * Gets the mesh internal Geometry object
  91947. */
  91948. readonly geometry: Nullable<Geometry>;
  91949. /**
  91950. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91951. * @returns the total number of vertices
  91952. */
  91953. getTotalVertices(): number;
  91954. /**
  91955. * Returns the content of an associated vertex buffer
  91956. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91957. * - VertexBuffer.PositionKind
  91958. * - VertexBuffer.UVKind
  91959. * - VertexBuffer.UV2Kind
  91960. * - VertexBuffer.UV3Kind
  91961. * - VertexBuffer.UV4Kind
  91962. * - VertexBuffer.UV5Kind
  91963. * - VertexBuffer.UV6Kind
  91964. * - VertexBuffer.ColorKind
  91965. * - VertexBuffer.MatricesIndicesKind
  91966. * - VertexBuffer.MatricesIndicesExtraKind
  91967. * - VertexBuffer.MatricesWeightsKind
  91968. * - VertexBuffer.MatricesWeightsExtraKind
  91969. * @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
  91970. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91971. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91972. */
  91973. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91974. /**
  91975. * Returns the mesh VertexBuffer object from the requested `kind`
  91976. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91977. * - VertexBuffer.PositionKind
  91978. * - VertexBuffer.NormalKind
  91979. * - VertexBuffer.UVKind
  91980. * - VertexBuffer.UV2Kind
  91981. * - VertexBuffer.UV3Kind
  91982. * - VertexBuffer.UV4Kind
  91983. * - VertexBuffer.UV5Kind
  91984. * - VertexBuffer.UV6Kind
  91985. * - VertexBuffer.ColorKind
  91986. * - VertexBuffer.MatricesIndicesKind
  91987. * - VertexBuffer.MatricesIndicesExtraKind
  91988. * - VertexBuffer.MatricesWeightsKind
  91989. * - VertexBuffer.MatricesWeightsExtraKind
  91990. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91991. */
  91992. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91993. /**
  91994. * Tests if a specific vertex buffer is associated with this mesh
  91995. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91996. * - VertexBuffer.PositionKind
  91997. * - VertexBuffer.NormalKind
  91998. * - VertexBuffer.UVKind
  91999. * - VertexBuffer.UV2Kind
  92000. * - VertexBuffer.UV3Kind
  92001. * - VertexBuffer.UV4Kind
  92002. * - VertexBuffer.UV5Kind
  92003. * - VertexBuffer.UV6Kind
  92004. * - VertexBuffer.ColorKind
  92005. * - VertexBuffer.MatricesIndicesKind
  92006. * - VertexBuffer.MatricesIndicesExtraKind
  92007. * - VertexBuffer.MatricesWeightsKind
  92008. * - VertexBuffer.MatricesWeightsExtraKind
  92009. * @returns a boolean
  92010. */
  92011. isVerticesDataPresent(kind: string): boolean;
  92012. /**
  92013. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92014. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92015. * - VertexBuffer.PositionKind
  92016. * - VertexBuffer.UVKind
  92017. * - VertexBuffer.UV2Kind
  92018. * - VertexBuffer.UV3Kind
  92019. * - VertexBuffer.UV4Kind
  92020. * - VertexBuffer.UV5Kind
  92021. * - VertexBuffer.UV6Kind
  92022. * - VertexBuffer.ColorKind
  92023. * - VertexBuffer.MatricesIndicesKind
  92024. * - VertexBuffer.MatricesIndicesExtraKind
  92025. * - VertexBuffer.MatricesWeightsKind
  92026. * - VertexBuffer.MatricesWeightsExtraKind
  92027. * @returns a boolean
  92028. */
  92029. isVertexBufferUpdatable(kind: string): boolean;
  92030. /**
  92031. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92032. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92033. * - VertexBuffer.PositionKind
  92034. * - VertexBuffer.NormalKind
  92035. * - VertexBuffer.UVKind
  92036. * - VertexBuffer.UV2Kind
  92037. * - VertexBuffer.UV3Kind
  92038. * - VertexBuffer.UV4Kind
  92039. * - VertexBuffer.UV5Kind
  92040. * - VertexBuffer.UV6Kind
  92041. * - VertexBuffer.ColorKind
  92042. * - VertexBuffer.MatricesIndicesKind
  92043. * - VertexBuffer.MatricesIndicesExtraKind
  92044. * - VertexBuffer.MatricesWeightsKind
  92045. * - VertexBuffer.MatricesWeightsExtraKind
  92046. * @returns an array of strings
  92047. */
  92048. getVerticesDataKinds(): string[];
  92049. /**
  92050. * Returns a positive integer : the total number of indices in this mesh geometry.
  92051. * @returns the numner of indices or zero if the mesh has no geometry.
  92052. */
  92053. getTotalIndices(): number;
  92054. /**
  92055. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92056. * @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.
  92057. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92058. * @returns the indices array or an empty array if the mesh has no geometry
  92059. */
  92060. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92061. readonly isBlocked: boolean;
  92062. /**
  92063. * Determine if the current mesh is ready to be rendered
  92064. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92065. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92066. * @returns true if all associated assets are ready (material, textures, shaders)
  92067. */
  92068. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92069. /**
  92070. * 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.
  92071. */
  92072. readonly areNormalsFrozen: boolean;
  92073. /**
  92074. * 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.
  92075. * @returns the current mesh
  92076. */
  92077. freezeNormals(): Mesh;
  92078. /**
  92079. * 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
  92080. * @returns the current mesh
  92081. */
  92082. unfreezeNormals(): Mesh;
  92083. /**
  92084. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92085. */
  92086. overridenInstanceCount: number;
  92087. /** @hidden */
  92088. _preActivate(): Mesh;
  92089. /** @hidden */
  92090. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92091. /** @hidden */
  92092. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92093. /**
  92094. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92095. * This means the mesh underlying bounding box and sphere are recomputed.
  92096. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92097. * @returns the current mesh
  92098. */
  92099. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92100. /** @hidden */
  92101. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92102. /**
  92103. * This function will subdivide the mesh into multiple submeshes
  92104. * @param count defines the expected number of submeshes
  92105. */
  92106. subdivide(count: number): void;
  92107. /**
  92108. * Copy a FloatArray into a specific associated vertex buffer
  92109. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92110. * - VertexBuffer.PositionKind
  92111. * - VertexBuffer.UVKind
  92112. * - VertexBuffer.UV2Kind
  92113. * - VertexBuffer.UV3Kind
  92114. * - VertexBuffer.UV4Kind
  92115. * - VertexBuffer.UV5Kind
  92116. * - VertexBuffer.UV6Kind
  92117. * - VertexBuffer.ColorKind
  92118. * - VertexBuffer.MatricesIndicesKind
  92119. * - VertexBuffer.MatricesIndicesExtraKind
  92120. * - VertexBuffer.MatricesWeightsKind
  92121. * - VertexBuffer.MatricesWeightsExtraKind
  92122. * @param data defines the data source
  92123. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92124. * @param stride defines the data stride size (can be null)
  92125. * @returns the current mesh
  92126. */
  92127. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92128. /**
  92129. * Delete a vertex buffer associated with this mesh
  92130. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92131. * - VertexBuffer.PositionKind
  92132. * - VertexBuffer.UVKind
  92133. * - VertexBuffer.UV2Kind
  92134. * - VertexBuffer.UV3Kind
  92135. * - VertexBuffer.UV4Kind
  92136. * - VertexBuffer.UV5Kind
  92137. * - VertexBuffer.UV6Kind
  92138. * - VertexBuffer.ColorKind
  92139. * - VertexBuffer.MatricesIndicesKind
  92140. * - VertexBuffer.MatricesIndicesExtraKind
  92141. * - VertexBuffer.MatricesWeightsKind
  92142. * - VertexBuffer.MatricesWeightsExtraKind
  92143. */
  92144. removeVerticesData(kind: string): void;
  92145. /**
  92146. * Flags an associated vertex buffer as updatable
  92147. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92148. * - VertexBuffer.PositionKind
  92149. * - VertexBuffer.UVKind
  92150. * - VertexBuffer.UV2Kind
  92151. * - VertexBuffer.UV3Kind
  92152. * - VertexBuffer.UV4Kind
  92153. * - VertexBuffer.UV5Kind
  92154. * - VertexBuffer.UV6Kind
  92155. * - VertexBuffer.ColorKind
  92156. * - VertexBuffer.MatricesIndicesKind
  92157. * - VertexBuffer.MatricesIndicesExtraKind
  92158. * - VertexBuffer.MatricesWeightsKind
  92159. * - VertexBuffer.MatricesWeightsExtraKind
  92160. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92161. */
  92162. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92163. /**
  92164. * Sets the mesh global Vertex Buffer
  92165. * @param buffer defines the buffer to use
  92166. * @returns the current mesh
  92167. */
  92168. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92169. /**
  92170. * Update a specific associated vertex buffer
  92171. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92172. * - VertexBuffer.PositionKind
  92173. * - VertexBuffer.UVKind
  92174. * - VertexBuffer.UV2Kind
  92175. * - VertexBuffer.UV3Kind
  92176. * - VertexBuffer.UV4Kind
  92177. * - VertexBuffer.UV5Kind
  92178. * - VertexBuffer.UV6Kind
  92179. * - VertexBuffer.ColorKind
  92180. * - VertexBuffer.MatricesIndicesKind
  92181. * - VertexBuffer.MatricesIndicesExtraKind
  92182. * - VertexBuffer.MatricesWeightsKind
  92183. * - VertexBuffer.MatricesWeightsExtraKind
  92184. * @param data defines the data source
  92185. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92186. * @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)
  92187. * @returns the current mesh
  92188. */
  92189. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92190. /**
  92191. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92192. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92193. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92194. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92195. * @returns the current mesh
  92196. */
  92197. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92198. /**
  92199. * Creates a un-shared specific occurence of the geometry for the mesh.
  92200. * @returns the current mesh
  92201. */
  92202. makeGeometryUnique(): Mesh;
  92203. /**
  92204. * Set the index buffer of this mesh
  92205. * @param indices defines the source data
  92206. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92207. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92208. * @returns the current mesh
  92209. */
  92210. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92211. /**
  92212. * Update the current index buffer
  92213. * @param indices defines the source data
  92214. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92215. * @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)
  92216. * @returns the current mesh
  92217. */
  92218. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92219. /**
  92220. * Invert the geometry to move from a right handed system to a left handed one.
  92221. * @returns the current mesh
  92222. */
  92223. toLeftHanded(): Mesh;
  92224. /** @hidden */
  92225. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92226. /** @hidden */
  92227. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92228. /**
  92229. * Registers for this mesh a javascript function called just before the rendering process
  92230. * @param func defines the function to call before rendering this mesh
  92231. * @returns the current mesh
  92232. */
  92233. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92234. /**
  92235. * Disposes a previously registered javascript function called before the rendering
  92236. * @param func defines the function to remove
  92237. * @returns the current mesh
  92238. */
  92239. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92240. /**
  92241. * Registers for this mesh a javascript function called just after the rendering is complete
  92242. * @param func defines the function to call after rendering this mesh
  92243. * @returns the current mesh
  92244. */
  92245. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92246. /**
  92247. * Disposes a previously registered javascript function called after the rendering.
  92248. * @param func defines the function to remove
  92249. * @returns the current mesh
  92250. */
  92251. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92252. /** @hidden */
  92253. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  92254. /** @hidden */
  92255. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92256. /** @hidden */
  92257. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92258. /** @hidden */
  92259. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92260. /** @hidden */
  92261. _rebuild(): void;
  92262. /** @hidden */
  92263. _freeze(): void;
  92264. /** @hidden */
  92265. _unFreeze(): void;
  92266. /**
  92267. * 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
  92268. * @param subMesh defines the subMesh to render
  92269. * @param enableAlphaMode defines if alpha mode can be changed
  92270. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92271. * @returns the current mesh
  92272. */
  92273. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92274. private _onBeforeDraw;
  92275. /**
  92276. * Renormalize the mesh and patch it up if there are no weights
  92277. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92278. * However in the case of zero weights then we set just a single influence to 1.
  92279. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92280. */
  92281. cleanMatrixWeights(): void;
  92282. private normalizeSkinFourWeights;
  92283. private normalizeSkinWeightsAndExtra;
  92284. /**
  92285. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92286. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92287. * the user know there was an issue with importing the mesh
  92288. * @returns a validation object with skinned, valid and report string
  92289. */
  92290. validateSkinning(): {
  92291. skinned: boolean;
  92292. valid: boolean;
  92293. report: string;
  92294. };
  92295. /** @hidden */
  92296. _checkDelayState(): Mesh;
  92297. private _queueLoad;
  92298. /**
  92299. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92300. * A mesh is in the frustum if its bounding box intersects the frustum
  92301. * @param frustumPlanes defines the frustum to test
  92302. * @returns true if the mesh is in the frustum planes
  92303. */
  92304. isInFrustum(frustumPlanes: Plane[]): boolean;
  92305. /**
  92306. * Sets the mesh material by the material or multiMaterial `id` property
  92307. * @param id is a string identifying the material or the multiMaterial
  92308. * @returns the current mesh
  92309. */
  92310. setMaterialByID(id: string): Mesh;
  92311. /**
  92312. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92313. * @returns an array of IAnimatable
  92314. */
  92315. getAnimatables(): IAnimatable[];
  92316. /**
  92317. * Modifies the mesh geometry according to the passed transformation matrix.
  92318. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92319. * The mesh normals are modified using the same transformation.
  92320. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92321. * @param transform defines the transform matrix to use
  92322. * @see http://doc.babylonjs.com/resources/baking_transformations
  92323. * @returns the current mesh
  92324. */
  92325. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92326. /**
  92327. * Modifies the mesh geometry according to its own current World Matrix.
  92328. * The mesh World Matrix is then reset.
  92329. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92330. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92331. * @see http://doc.babylonjs.com/resources/baking_transformations
  92332. * @returns the current mesh
  92333. */
  92334. bakeCurrentTransformIntoVertices(): Mesh;
  92335. /** @hidden */
  92336. readonly _positions: Nullable<Vector3[]>;
  92337. /** @hidden */
  92338. _resetPointsArrayCache(): Mesh;
  92339. /** @hidden */
  92340. _generatePointsArray(): boolean;
  92341. /**
  92342. * Returns a new Mesh object generated from the current mesh properties.
  92343. * This method must not get confused with createInstance()
  92344. * @param name is a string, the name given to the new mesh
  92345. * @param newParent can be any Node object (default `null`)
  92346. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92347. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92348. * @returns a new mesh
  92349. */
  92350. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92351. /**
  92352. * Releases resources associated with this mesh.
  92353. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92354. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92355. */
  92356. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92357. /** @hidden */
  92358. _disposeInstanceSpecificData(): void;
  92359. /**
  92360. * Modifies the mesh geometry according to a displacement map.
  92361. * 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.
  92362. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92363. * @param url is a string, the URL from the image file is to be downloaded.
  92364. * @param minHeight is the lower limit of the displacement.
  92365. * @param maxHeight is the upper limit of the displacement.
  92366. * @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.
  92367. * @param uvOffset is an optional vector2 used to offset UV.
  92368. * @param uvScale is an optional vector2 used to scale UV.
  92369. * @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.
  92370. * @returns the Mesh.
  92371. */
  92372. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92373. /**
  92374. * Modifies the mesh geometry according to a displacementMap buffer.
  92375. * 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.
  92376. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92377. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92378. * @param heightMapWidth is the width of the buffer image.
  92379. * @param heightMapHeight is the height of the buffer image.
  92380. * @param minHeight is the lower limit of the displacement.
  92381. * @param maxHeight is the upper limit of the displacement.
  92382. * @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.
  92383. * @param uvOffset is an optional vector2 used to offset UV.
  92384. * @param uvScale is an optional vector2 used to scale UV.
  92385. * @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.
  92386. * @returns the Mesh.
  92387. */
  92388. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92389. /**
  92390. * Modify the mesh to get a flat shading rendering.
  92391. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92392. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92393. * @returns current mesh
  92394. */
  92395. convertToFlatShadedMesh(): Mesh;
  92396. /**
  92397. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92398. * In other words, more vertices, no more indices and a single bigger VBO.
  92399. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92400. * @returns current mesh
  92401. */
  92402. convertToUnIndexedMesh(): Mesh;
  92403. /**
  92404. * Inverses facet orientations.
  92405. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92406. * @param flipNormals will also inverts the normals
  92407. * @returns current mesh
  92408. */
  92409. flipFaces(flipNormals?: boolean): Mesh;
  92410. /**
  92411. * Increase the number of facets and hence vertices in a mesh
  92412. * Vertex normals are interpolated from existing vertex normals
  92413. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92414. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92415. */
  92416. increaseVertices(numberPerEdge: number): void;
  92417. /**
  92418. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92419. * This will undo any application of covertToFlatShadedMesh
  92420. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92421. */
  92422. forceSharedVertices(): void;
  92423. /** @hidden */
  92424. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92425. /** @hidden */
  92426. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92427. /**
  92428. * Creates a new InstancedMesh object from the mesh model.
  92429. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92430. * @param name defines the name of the new instance
  92431. * @returns a new InstancedMesh
  92432. */
  92433. createInstance(name: string): InstancedMesh;
  92434. /**
  92435. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92436. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92437. * @returns the current mesh
  92438. */
  92439. synchronizeInstances(): Mesh;
  92440. /**
  92441. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92442. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92443. * This should be used together with the simplification to avoid disappearing triangles.
  92444. * @param successCallback an optional success callback to be called after the optimization finished.
  92445. * @returns the current mesh
  92446. */
  92447. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92448. /**
  92449. * Serialize current mesh
  92450. * @param serializationObject defines the object which will receive the serialization data
  92451. */
  92452. serialize(serializationObject: any): void;
  92453. /** @hidden */
  92454. _syncGeometryWithMorphTargetManager(): void;
  92455. /** @hidden */
  92456. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92457. /**
  92458. * Returns a new Mesh object parsed from the source provided.
  92459. * @param parsedMesh is the source
  92460. * @param scene defines the hosting scene
  92461. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92462. * @returns a new Mesh
  92463. */
  92464. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92465. /**
  92466. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92467. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92468. * @param name defines the name of the mesh to create
  92469. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92470. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92471. * @param closePath creates a seam between the first and the last points of each path of the path array
  92472. * @param offset is taken in account only if the `pathArray` is containing a single path
  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. * @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)
  92477. * @returns a new Mesh
  92478. */
  92479. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92480. /**
  92481. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92482. * @param name defines the name of the mesh to create
  92483. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92484. * @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
  92485. * @param scene defines the hosting scene
  92486. * @param updatable defines if the mesh must be flagged as updatable
  92487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92488. * @returns a new Mesh
  92489. */
  92490. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92491. /**
  92492. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92493. * @param name defines the name of the mesh to create
  92494. * @param size sets the size (float) of each box side (default 1)
  92495. * @param scene defines the hosting scene
  92496. * @param updatable defines if the mesh must be flagged as updatable
  92497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92498. * @returns a new Mesh
  92499. */
  92500. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92501. /**
  92502. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92503. * @param name defines the name of the mesh to create
  92504. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92505. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92506. * @param scene defines the hosting scene
  92507. * @param updatable defines if the mesh must be flagged as updatable
  92508. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92509. * @returns a new Mesh
  92510. */
  92511. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92512. /**
  92513. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92514. * @param name defines the name of the mesh to create
  92515. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92516. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92517. * @param scene defines the hosting scene
  92518. * @returns a new Mesh
  92519. */
  92520. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92521. /**
  92522. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92523. * @param name defines the name of the mesh to create
  92524. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92525. * @param diameterTop set the top cap diameter (floats, default 1)
  92526. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92527. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92528. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92529. * @param scene defines the hosting scene
  92530. * @param updatable defines if the mesh must be flagged as updatable
  92531. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92532. * @returns a new Mesh
  92533. */
  92534. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92535. /**
  92536. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92537. * @param name defines the name of the mesh to create
  92538. * @param diameter sets the diameter size (float) of the torus (default 1)
  92539. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92540. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92541. * @param scene defines the hosting scene
  92542. * @param updatable defines if the mesh must be flagged as updatable
  92543. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92544. * @returns a new Mesh
  92545. */
  92546. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92547. /**
  92548. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92549. * @param name defines the name of the mesh to create
  92550. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92551. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92552. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92553. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92554. * @param p the number of windings on X axis (positive integers, default 2)
  92555. * @param q the number of windings on Y axis (positive integers, default 3)
  92556. * @param scene defines the hosting scene
  92557. * @param updatable defines if the mesh must be flagged as updatable
  92558. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92559. * @returns a new Mesh
  92560. */
  92561. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92562. /**
  92563. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92564. * @param name defines the name of the mesh to create
  92565. * @param points is an array successive Vector3
  92566. * @param scene defines the hosting scene
  92567. * @param updatable defines if the mesh must be flagged as updatable
  92568. * @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).
  92569. * @returns a new Mesh
  92570. */
  92571. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92572. /**
  92573. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92574. * @param name defines the name of the mesh to create
  92575. * @param points is an array successive Vector3
  92576. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92577. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92578. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92579. * @param scene defines the hosting scene
  92580. * @param updatable defines if the mesh must be flagged as updatable
  92581. * @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)
  92582. * @returns a new Mesh
  92583. */
  92584. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92585. /**
  92586. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92587. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92588. * 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.
  92589. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92590. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92591. * Remember you can only change the shape positions, not their number when updating a polygon.
  92592. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92593. * @param name defines the name of the mesh to create
  92594. * @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
  92595. * @param scene defines the hosting scene
  92596. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92597. * @param updatable defines if the mesh must be flagged as updatable
  92598. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92599. * @param earcutInjection can be used to inject your own earcut reference
  92600. * @returns a new Mesh
  92601. */
  92602. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92603. /**
  92604. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92605. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92606. * @param name defines the name of the mesh to create
  92607. * @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
  92608. * @param depth defines the height of extrusion
  92609. * @param scene defines the hosting scene
  92610. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92611. * @param updatable defines if the mesh must be flagged as updatable
  92612. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92613. * @param earcutInjection can be used to inject your own earcut reference
  92614. * @returns a new Mesh
  92615. */
  92616. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92617. /**
  92618. * Creates an extruded shape mesh.
  92619. * 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
  92620. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92621. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92622. * @param name defines the name of the mesh to create
  92623. * @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
  92624. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92625. * @param scale is the value to scale the shape
  92626. * @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
  92627. * @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
  92628. * @param scene defines the hosting scene
  92629. * @param updatable defines if the mesh must be flagged as updatable
  92630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92631. * @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)
  92632. * @returns a new Mesh
  92633. */
  92634. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92635. /**
  92636. * Creates an custom extruded shape mesh.
  92637. * The custom extrusion is a parametric shape.
  92638. * It has no predefined shape. Its final shape will depend on the input parameters.
  92639. * Please consider using the same method from the MeshBuilder class instead
  92640. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92641. * @param name defines the name of the mesh to create
  92642. * @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
  92643. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92644. * @param scaleFunction is a custom Javascript function called on each path point
  92645. * @param rotationFunction is a custom Javascript function called on each path point
  92646. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92647. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92648. * @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
  92649. * @param scene defines the hosting scene
  92650. * @param updatable defines if the mesh must be flagged as updatable
  92651. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92652. * @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)
  92653. * @returns a new Mesh
  92654. */
  92655. 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;
  92656. /**
  92657. * Creates lathe mesh.
  92658. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92659. * Please consider using the same method from the MeshBuilder class instead
  92660. * @param name defines the name of the mesh to create
  92661. * @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
  92662. * @param radius is the radius value of the lathe
  92663. * @param tessellation is the side number of the lathe.
  92664. * @param scene defines the hosting scene
  92665. * @param updatable defines if the mesh must be flagged as updatable
  92666. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92667. * @returns a new Mesh
  92668. */
  92669. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92670. /**
  92671. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92672. * @param name defines the name of the mesh to create
  92673. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92674. * @param scene defines the hosting scene
  92675. * @param updatable defines if the mesh must be flagged as updatable
  92676. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92677. * @returns a new Mesh
  92678. */
  92679. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92680. /**
  92681. * Creates a ground mesh.
  92682. * Please consider using the same method from the MeshBuilder class instead
  92683. * @param name defines the name of the mesh to create
  92684. * @param width set the width of the ground
  92685. * @param height set the height of the ground
  92686. * @param subdivisions sets the number of subdivisions per side
  92687. * @param scene defines the hosting scene
  92688. * @param updatable defines if the mesh must be flagged as updatable
  92689. * @returns a new Mesh
  92690. */
  92691. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92692. /**
  92693. * Creates a tiled ground mesh.
  92694. * Please consider using the same method from the MeshBuilder class instead
  92695. * @param name defines the name of the mesh to create
  92696. * @param xmin set the ground minimum X coordinate
  92697. * @param zmin set the ground minimum Y coordinate
  92698. * @param xmax set the ground maximum X coordinate
  92699. * @param zmax set the ground maximum Z coordinate
  92700. * @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
  92701. * @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
  92702. * @param scene defines the hosting scene
  92703. * @param updatable defines if the mesh must be flagged as updatable
  92704. * @returns a new Mesh
  92705. */
  92706. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92707. w: number;
  92708. h: number;
  92709. }, precision: {
  92710. w: number;
  92711. h: number;
  92712. }, scene: Scene, updatable?: boolean): Mesh;
  92713. /**
  92714. * Creates a ground mesh from a height map.
  92715. * Please consider using the same method from the MeshBuilder class instead
  92716. * @see http://doc.babylonjs.com/babylon101/height_map
  92717. * @param name defines the name of the mesh to create
  92718. * @param url sets the URL of the height map image resource
  92719. * @param width set the ground width size
  92720. * @param height set the ground height size
  92721. * @param subdivisions sets the number of subdivision per side
  92722. * @param minHeight is the minimum altitude on the ground
  92723. * @param maxHeight is the maximum altitude on the ground
  92724. * @param scene defines the hosting scene
  92725. * @param updatable defines if the mesh must be flagged as updatable
  92726. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92727. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92728. * @returns a new Mesh
  92729. */
  92730. 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;
  92731. /**
  92732. * Creates a tube mesh.
  92733. * The tube is a parametric shape.
  92734. * It has no predefined shape. Its final shape will depend on the input parameters.
  92735. * Please consider using the same method from the MeshBuilder class instead
  92736. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92737. * @param name defines the name of the mesh to create
  92738. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92739. * @param radius sets the tube radius size
  92740. * @param tessellation is the number of sides on the tubular surface
  92741. * @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
  92742. * @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
  92743. * @param scene defines the hosting scene
  92744. * @param updatable defines if the mesh must be flagged as updatable
  92745. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92746. * @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)
  92747. * @returns a new Mesh
  92748. */
  92749. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92750. (i: number, distance: number): number;
  92751. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92752. /**
  92753. * Creates a polyhedron mesh.
  92754. * Please consider using the same method from the MeshBuilder class instead.
  92755. * * 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
  92756. * * The parameter `size` (positive float, default 1) sets the polygon size
  92757. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92758. * * 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`
  92759. * * 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
  92760. * * 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)`)
  92761. * * 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
  92762. * * 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
  92763. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92764. * * If you create a double-sided mesh, you can choose what parts of 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
  92765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92766. * @param name defines the name of the mesh to create
  92767. * @param options defines the options used to create the mesh
  92768. * @param scene defines the hosting scene
  92769. * @returns a new Mesh
  92770. */
  92771. static CreatePolyhedron(name: string, options: {
  92772. type?: number;
  92773. size?: number;
  92774. sizeX?: number;
  92775. sizeY?: number;
  92776. sizeZ?: number;
  92777. custom?: any;
  92778. faceUV?: Vector4[];
  92779. faceColors?: Color4[];
  92780. updatable?: boolean;
  92781. sideOrientation?: number;
  92782. }, scene: Scene): Mesh;
  92783. /**
  92784. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92785. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92786. * * 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`)
  92787. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92788. * * 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
  92789. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92790. * * If you create a double-sided mesh, you can choose what parts of 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
  92791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92792. * @param name defines the name of the mesh
  92793. * @param options defines the options used to create the mesh
  92794. * @param scene defines the hosting scene
  92795. * @returns a new Mesh
  92796. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92797. */
  92798. static CreateIcoSphere(name: string, options: {
  92799. radius?: number;
  92800. flat?: boolean;
  92801. subdivisions?: number;
  92802. sideOrientation?: number;
  92803. updatable?: boolean;
  92804. }, scene: Scene): Mesh;
  92805. /**
  92806. * Creates a decal mesh.
  92807. * Please consider using the same method from the MeshBuilder class instead.
  92808. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92809. * @param name defines the name of the mesh
  92810. * @param sourceMesh defines the mesh receiving the decal
  92811. * @param position sets the position of the decal in world coordinates
  92812. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92813. * @param size sets the decal scaling
  92814. * @param angle sets the angle to rotate the decal
  92815. * @returns a new Mesh
  92816. */
  92817. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92818. /**
  92819. * Prepare internal position array for software CPU skinning
  92820. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92821. */
  92822. setPositionsForCPUSkinning(): Float32Array;
  92823. /**
  92824. * Prepare internal normal array for software CPU skinning
  92825. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92826. */
  92827. setNormalsForCPUSkinning(): Float32Array;
  92828. /**
  92829. * Updates the vertex buffer by applying transformation from the bones
  92830. * @param skeleton defines the skeleton to apply to current mesh
  92831. * @returns the current mesh
  92832. */
  92833. applySkeleton(skeleton: Skeleton): Mesh;
  92834. /**
  92835. * 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
  92836. * @param meshes defines the list of meshes to scan
  92837. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92838. */
  92839. static MinMax(meshes: AbstractMesh[]): {
  92840. min: Vector3;
  92841. max: Vector3;
  92842. };
  92843. /**
  92844. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92845. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92846. * @returns a vector3
  92847. */
  92848. static Center(meshesOrMinMaxVector: {
  92849. min: Vector3;
  92850. max: Vector3;
  92851. } | AbstractMesh[]): Vector3;
  92852. /**
  92853. * Merge the array of meshes into a single mesh for performance reasons.
  92854. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92855. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92856. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92857. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92858. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92859. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92860. * @returns a new mesh
  92861. */
  92862. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92863. /** @hidden */
  92864. addInstance(instance: InstancedMesh): void;
  92865. /** @hidden */
  92866. removeInstance(instance: InstancedMesh): void;
  92867. }
  92868. }
  92869. declare module BABYLON {
  92870. /**
  92871. * This is the base class of all the camera used in the application.
  92872. * @see http://doc.babylonjs.com/features/cameras
  92873. */
  92874. export class Camera extends Node {
  92875. /** @hidden */
  92876. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92877. /**
  92878. * This is the default projection mode used by the cameras.
  92879. * It helps recreating a feeling of perspective and better appreciate depth.
  92880. * This is the best way to simulate real life cameras.
  92881. */
  92882. static readonly PERSPECTIVE_CAMERA: number;
  92883. /**
  92884. * This helps creating camera with an orthographic mode.
  92885. * 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.
  92886. */
  92887. static readonly ORTHOGRAPHIC_CAMERA: number;
  92888. /**
  92889. * This is the default FOV mode for perspective cameras.
  92890. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92891. */
  92892. static readonly FOVMODE_VERTICAL_FIXED: number;
  92893. /**
  92894. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92895. */
  92896. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92897. /**
  92898. * This specifies ther is no need for a camera rig.
  92899. * Basically only one eye is rendered corresponding to the camera.
  92900. */
  92901. static readonly RIG_MODE_NONE: number;
  92902. /**
  92903. * Simulates a camera Rig with one blue eye and one red eye.
  92904. * This can be use with 3d blue and red glasses.
  92905. */
  92906. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92907. /**
  92908. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92909. */
  92910. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92911. /**
  92912. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92913. */
  92914. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92915. /**
  92916. * Defines that both eyes of the camera will be rendered over under each other.
  92917. */
  92918. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92919. /**
  92920. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92921. */
  92922. static readonly RIG_MODE_VR: number;
  92923. /**
  92924. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92925. */
  92926. static readonly RIG_MODE_WEBVR: number;
  92927. /**
  92928. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92929. */
  92930. static readonly RIG_MODE_CUSTOM: number;
  92931. /**
  92932. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92933. */
  92934. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92935. /**
  92936. * Define the input manager associated with the camera.
  92937. */
  92938. inputs: CameraInputsManager<Camera>;
  92939. /** @hidden */
  92940. _position: Vector3;
  92941. /**
  92942. * Define the current local position of the camera in the scene
  92943. */
  92944. position: Vector3;
  92945. /**
  92946. * The vector the camera should consider as up.
  92947. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92948. */
  92949. upVector: Vector3;
  92950. /**
  92951. * Define the current limit on the left side for an orthographic camera
  92952. * In scene unit
  92953. */
  92954. orthoLeft: Nullable<number>;
  92955. /**
  92956. * Define the current limit on the right side for an orthographic camera
  92957. * In scene unit
  92958. */
  92959. orthoRight: Nullable<number>;
  92960. /**
  92961. * Define the current limit on the bottom side for an orthographic camera
  92962. * In scene unit
  92963. */
  92964. orthoBottom: Nullable<number>;
  92965. /**
  92966. * Define the current limit on the top side for an orthographic camera
  92967. * In scene unit
  92968. */
  92969. orthoTop: Nullable<number>;
  92970. /**
  92971. * Field Of View is set in Radians. (default is 0.8)
  92972. */
  92973. fov: number;
  92974. /**
  92975. * Define the minimum distance the camera can see from.
  92976. * This is important to note that the depth buffer are not infinite and the closer it starts
  92977. * the more your scene might encounter depth fighting issue.
  92978. */
  92979. minZ: number;
  92980. /**
  92981. * Define the maximum distance the camera can see to.
  92982. * This is important to note that the depth buffer are not infinite and the further it end
  92983. * the more your scene might encounter depth fighting issue.
  92984. */
  92985. maxZ: number;
  92986. /**
  92987. * Define the default inertia of the camera.
  92988. * This helps giving a smooth feeling to the camera movement.
  92989. */
  92990. inertia: number;
  92991. /**
  92992. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92993. */
  92994. mode: number;
  92995. /**
  92996. * Define wether the camera is intermediate.
  92997. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92998. */
  92999. isIntermediate: boolean;
  93000. /**
  93001. * Define the viewport of the camera.
  93002. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93003. */
  93004. viewport: Viewport;
  93005. /**
  93006. * Restricts the camera to viewing objects with the same layerMask.
  93007. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93008. */
  93009. layerMask: number;
  93010. /**
  93011. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93012. */
  93013. fovMode: number;
  93014. /**
  93015. * Rig mode of the camera.
  93016. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93017. * This is normally controlled byt the camera themselves as internal use.
  93018. */
  93019. cameraRigMode: number;
  93020. /**
  93021. * Defines the distance between both "eyes" in case of a RIG
  93022. */
  93023. interaxialDistance: number;
  93024. /**
  93025. * Defines if stereoscopic rendering is done side by side or over under.
  93026. */
  93027. isStereoscopicSideBySide: boolean;
  93028. /**
  93029. * 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
  93030. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93031. * else in the scene. (Eg. security camera)
  93032. *
  93033. * 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)
  93034. */
  93035. customRenderTargets: RenderTargetTexture[];
  93036. /**
  93037. * When set, the camera will render to this render target instead of the default canvas
  93038. *
  93039. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93040. */
  93041. outputRenderTarget: Nullable<RenderTargetTexture>;
  93042. /**
  93043. * Observable triggered when the camera view matrix has changed.
  93044. */
  93045. onViewMatrixChangedObservable: Observable<Camera>;
  93046. /**
  93047. * Observable triggered when the camera Projection matrix has changed.
  93048. */
  93049. onProjectionMatrixChangedObservable: Observable<Camera>;
  93050. /**
  93051. * Observable triggered when the inputs have been processed.
  93052. */
  93053. onAfterCheckInputsObservable: Observable<Camera>;
  93054. /**
  93055. * Observable triggered when reset has been called and applied to the camera.
  93056. */
  93057. onRestoreStateObservable: Observable<Camera>;
  93058. /** @hidden */
  93059. _cameraRigParams: any;
  93060. /** @hidden */
  93061. _rigCameras: Camera[];
  93062. /** @hidden */
  93063. _rigPostProcess: Nullable<PostProcess>;
  93064. protected _webvrViewMatrix: Matrix;
  93065. /** @hidden */
  93066. _skipRendering: boolean;
  93067. /** @hidden */
  93068. _projectionMatrix: Matrix;
  93069. /** @hidden */
  93070. _postProcesses: Nullable<PostProcess>[];
  93071. /** @hidden */
  93072. _activeMeshes: SmartArray<AbstractMesh>;
  93073. protected _globalPosition: Vector3;
  93074. /** @hidden */
  93075. _computedViewMatrix: Matrix;
  93076. private _doNotComputeProjectionMatrix;
  93077. private _transformMatrix;
  93078. private _frustumPlanes;
  93079. private _refreshFrustumPlanes;
  93080. private _storedFov;
  93081. private _stateStored;
  93082. /**
  93083. * Instantiates a new camera object.
  93084. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93085. * @see http://doc.babylonjs.com/features/cameras
  93086. * @param name Defines the name of the camera in the scene
  93087. * @param position Defines the position of the camera
  93088. * @param scene Defines the scene the camera belongs too
  93089. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93090. */
  93091. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93092. /**
  93093. * Store current camera state (fov, position, etc..)
  93094. * @returns the camera
  93095. */
  93096. storeState(): Camera;
  93097. /**
  93098. * Restores the camera state values if it has been stored. You must call storeState() first
  93099. */
  93100. protected _restoreStateValues(): boolean;
  93101. /**
  93102. * Restored camera state. You must call storeState() first.
  93103. * @returns true if restored and false otherwise
  93104. */
  93105. restoreState(): boolean;
  93106. /**
  93107. * Gets the class name of the camera.
  93108. * @returns the class name
  93109. */
  93110. getClassName(): string;
  93111. /** @hidden */
  93112. readonly _isCamera: boolean;
  93113. /**
  93114. * Gets a string representation of the camera useful for debug purpose.
  93115. * @param fullDetails Defines that a more verboe level of logging is required
  93116. * @returns the string representation
  93117. */
  93118. toString(fullDetails?: boolean): string;
  93119. /**
  93120. * Gets the current world space position of the camera.
  93121. */
  93122. readonly globalPosition: Vector3;
  93123. /**
  93124. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93125. * @returns the active meshe list
  93126. */
  93127. getActiveMeshes(): SmartArray<AbstractMesh>;
  93128. /**
  93129. * Check wether a mesh is part of the current active mesh list of the camera
  93130. * @param mesh Defines the mesh to check
  93131. * @returns true if active, false otherwise
  93132. */
  93133. isActiveMesh(mesh: Mesh): boolean;
  93134. /**
  93135. * Is this camera ready to be used/rendered
  93136. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93137. * @return true if the camera is ready
  93138. */
  93139. isReady(completeCheck?: boolean): boolean;
  93140. /** @hidden */
  93141. _initCache(): void;
  93142. /** @hidden */
  93143. _updateCache(ignoreParentClass?: boolean): void;
  93144. /** @hidden */
  93145. _isSynchronized(): boolean;
  93146. /** @hidden */
  93147. _isSynchronizedViewMatrix(): boolean;
  93148. /** @hidden */
  93149. _isSynchronizedProjectionMatrix(): boolean;
  93150. /**
  93151. * Attach the input controls to a specific dom element to get the input from.
  93152. * @param element Defines the element the controls should be listened from
  93153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93154. */
  93155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93156. /**
  93157. * Detach the current controls from the specified dom element.
  93158. * @param element Defines the element to stop listening the inputs from
  93159. */
  93160. detachControl(element: HTMLElement): void;
  93161. /**
  93162. * Update the camera state according to the different inputs gathered during the frame.
  93163. */
  93164. update(): void;
  93165. /** @hidden */
  93166. _checkInputs(): void;
  93167. /** @hidden */
  93168. readonly rigCameras: Camera[];
  93169. /**
  93170. * Gets the post process used by the rig cameras
  93171. */
  93172. readonly rigPostProcess: Nullable<PostProcess>;
  93173. /**
  93174. * Internal, gets the first post proces.
  93175. * @returns the first post process to be run on this camera.
  93176. */
  93177. _getFirstPostProcess(): Nullable<PostProcess>;
  93178. private _cascadePostProcessesToRigCams;
  93179. /**
  93180. * Attach a post process to the camera.
  93181. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93182. * @param postProcess The post process to attach to the camera
  93183. * @param insertAt The position of the post process in case several of them are in use in the scene
  93184. * @returns the position the post process has been inserted at
  93185. */
  93186. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93187. /**
  93188. * Detach a post process to the camera.
  93189. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93190. * @param postProcess The post process to detach from the camera
  93191. */
  93192. detachPostProcess(postProcess: PostProcess): void;
  93193. /**
  93194. * Gets the current world matrix of the camera
  93195. */
  93196. getWorldMatrix(): Matrix;
  93197. /** @hidden */
  93198. _getViewMatrix(): Matrix;
  93199. /**
  93200. * Gets the current view matrix of the camera.
  93201. * @param force forces the camera to recompute the matrix without looking at the cached state
  93202. * @returns the view matrix
  93203. */
  93204. getViewMatrix(force?: boolean): Matrix;
  93205. /**
  93206. * Freeze the projection matrix.
  93207. * It will prevent the cache check of the camera projection compute and can speed up perf
  93208. * if no parameter of the camera are meant to change
  93209. * @param projection Defines manually a projection if necessary
  93210. */
  93211. freezeProjectionMatrix(projection?: Matrix): void;
  93212. /**
  93213. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93214. */
  93215. unfreezeProjectionMatrix(): void;
  93216. /**
  93217. * Gets the current projection matrix of the camera.
  93218. * @param force forces the camera to recompute the matrix without looking at the cached state
  93219. * @returns the projection matrix
  93220. */
  93221. getProjectionMatrix(force?: boolean): Matrix;
  93222. /**
  93223. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93224. * @returns a Matrix
  93225. */
  93226. getTransformationMatrix(): Matrix;
  93227. private _updateFrustumPlanes;
  93228. /**
  93229. * Checks if a cullable object (mesh...) is in the camera frustum
  93230. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93231. * @param target The object to check
  93232. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93233. * @returns true if the object is in frustum otherwise false
  93234. */
  93235. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93236. /**
  93237. * Checks if a cullable object (mesh...) is in the camera frustum
  93238. * Unlike isInFrustum this cheks the full bounding box
  93239. * @param target The object to check
  93240. * @returns true if the object is in frustum otherwise false
  93241. */
  93242. isCompletelyInFrustum(target: ICullable): boolean;
  93243. /**
  93244. * Gets a ray in the forward direction from the camera.
  93245. * @param length Defines the length of the ray to create
  93246. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93247. * @param origin Defines the start point of the ray which defaults to the camera position
  93248. * @returns the forward ray
  93249. */
  93250. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93251. /**
  93252. * Releases resources associated with this node.
  93253. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93254. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93255. */
  93256. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93257. /** @hidden */
  93258. _isLeftCamera: boolean;
  93259. /**
  93260. * Gets the left camera of a rig setup in case of Rigged Camera
  93261. */
  93262. readonly isLeftCamera: boolean;
  93263. /** @hidden */
  93264. _isRightCamera: boolean;
  93265. /**
  93266. * Gets the right camera of a rig setup in case of Rigged Camera
  93267. */
  93268. readonly isRightCamera: boolean;
  93269. /**
  93270. * Gets the left camera of a rig setup in case of Rigged Camera
  93271. */
  93272. readonly leftCamera: Nullable<FreeCamera>;
  93273. /**
  93274. * Gets the right camera of a rig setup in case of Rigged Camera
  93275. */
  93276. readonly rightCamera: Nullable<FreeCamera>;
  93277. /**
  93278. * Gets the left camera target of a rig setup in case of Rigged Camera
  93279. * @returns the target position
  93280. */
  93281. getLeftTarget(): Nullable<Vector3>;
  93282. /**
  93283. * Gets the right camera target of a rig setup in case of Rigged Camera
  93284. * @returns the target position
  93285. */
  93286. getRightTarget(): Nullable<Vector3>;
  93287. /**
  93288. * @hidden
  93289. */
  93290. setCameraRigMode(mode: number, rigParams: any): void;
  93291. /** @hidden */
  93292. static _setStereoscopicRigMode(camera: Camera): void;
  93293. /** @hidden */
  93294. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93295. /** @hidden */
  93296. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93297. /** @hidden */
  93298. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93299. /** @hidden */
  93300. _getVRProjectionMatrix(): Matrix;
  93301. protected _updateCameraRotationMatrix(): void;
  93302. protected _updateWebVRCameraRotationMatrix(): void;
  93303. /**
  93304. * This function MUST be overwritten by the different WebVR cameras available.
  93305. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93306. * @hidden
  93307. */
  93308. _getWebVRProjectionMatrix(): Matrix;
  93309. /**
  93310. * This function MUST be overwritten by the different WebVR cameras available.
  93311. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93312. * @hidden
  93313. */
  93314. _getWebVRViewMatrix(): Matrix;
  93315. /** @hidden */
  93316. setCameraRigParameter(name: string, value: any): void;
  93317. /**
  93318. * needs to be overridden by children so sub has required properties to be copied
  93319. * @hidden
  93320. */
  93321. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93322. /**
  93323. * May need to be overridden by children
  93324. * @hidden
  93325. */
  93326. _updateRigCameras(): void;
  93327. /** @hidden */
  93328. _setupInputs(): void;
  93329. /**
  93330. * Serialiaze the camera setup to a json represention
  93331. * @returns the JSON representation
  93332. */
  93333. serialize(): any;
  93334. /**
  93335. * Clones the current camera.
  93336. * @param name The cloned camera name
  93337. * @returns the cloned camera
  93338. */
  93339. clone(name: string): Camera;
  93340. /**
  93341. * Gets the direction of the camera relative to a given local axis.
  93342. * @param localAxis Defines the reference axis to provide a relative direction.
  93343. * @return the direction
  93344. */
  93345. getDirection(localAxis: Vector3): Vector3;
  93346. /**
  93347. * Returns the current camera absolute rotation
  93348. */
  93349. readonly absoluteRotation: Quaternion;
  93350. /**
  93351. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93352. * @param localAxis Defines the reference axis to provide a relative direction.
  93353. * @param result Defines the vector to store the result in
  93354. */
  93355. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93356. /**
  93357. * Gets a camera constructor for a given camera type
  93358. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93359. * @param name The name of the camera the result will be able to instantiate
  93360. * @param scene The scene the result will construct the camera in
  93361. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93362. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93363. * @returns a factory method to construc the camera
  93364. */
  93365. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93366. /**
  93367. * Compute the world matrix of the camera.
  93368. * @returns the camera world matrix
  93369. */
  93370. computeWorldMatrix(): Matrix;
  93371. /**
  93372. * Parse a JSON and creates the camera from the parsed information
  93373. * @param parsedCamera The JSON to parse
  93374. * @param scene The scene to instantiate the camera in
  93375. * @returns the newly constructed camera
  93376. */
  93377. static Parse(parsedCamera: any, scene: Scene): Camera;
  93378. }
  93379. }
  93380. declare module BABYLON {
  93381. /**
  93382. * Class containing static functions to help procedurally build meshes
  93383. */
  93384. export class DiscBuilder {
  93385. /**
  93386. * Creates a plane polygonal mesh. By default, this is a disc
  93387. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93388. * * 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
  93389. * * 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
  93390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93393. * @param name defines the name of the mesh
  93394. * @param options defines the options used to create the mesh
  93395. * @param scene defines the hosting scene
  93396. * @returns the plane polygonal mesh
  93397. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93398. */
  93399. static CreateDisc(name: string, options: {
  93400. radius?: number;
  93401. tessellation?: number;
  93402. arc?: number;
  93403. updatable?: boolean;
  93404. sideOrientation?: number;
  93405. frontUVs?: Vector4;
  93406. backUVs?: Vector4;
  93407. }, scene?: Nullable<Scene>): Mesh;
  93408. }
  93409. }
  93410. declare module BABYLON {
  93411. /**
  93412. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93413. *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.
  93414. * The SPS is also a particle system. It provides some methods to manage the particles.
  93415. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93416. *
  93417. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93418. */
  93419. export class SolidParticleSystem implements IDisposable {
  93420. /**
  93421. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93422. * Example : var p = SPS.particles[i];
  93423. */
  93424. particles: SolidParticle[];
  93425. /**
  93426. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93427. */
  93428. nbParticles: number;
  93429. /**
  93430. * If the particles must ever face the camera (default false). Useful for planar particles.
  93431. */
  93432. billboard: boolean;
  93433. /**
  93434. * Recompute normals when adding a shape
  93435. */
  93436. recomputeNormals: boolean;
  93437. /**
  93438. * This a counter ofr your own usage. It's not set by any SPS functions.
  93439. */
  93440. counter: number;
  93441. /**
  93442. * The SPS name. This name is also given to the underlying mesh.
  93443. */
  93444. name: string;
  93445. /**
  93446. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93447. */
  93448. mesh: Mesh;
  93449. /**
  93450. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93451. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93452. */
  93453. vars: any;
  93454. /**
  93455. * This array is populated when the SPS is set as 'pickable'.
  93456. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93457. * Each element of this array is an object `{idx: int, faceId: int}`.
  93458. * `idx` is the picked particle index in the `SPS.particles` array
  93459. * `faceId` is the picked face index counted within this particle.
  93460. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93461. */
  93462. pickedParticles: {
  93463. idx: number;
  93464. faceId: number;
  93465. }[];
  93466. /**
  93467. * This array is populated when `enableDepthSort` is set to true.
  93468. * Each element of this array is an instance of the class DepthSortedParticle.
  93469. */
  93470. depthSortedParticles: DepthSortedParticle[];
  93471. /**
  93472. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93473. * @hidden
  93474. */
  93475. _bSphereOnly: boolean;
  93476. /**
  93477. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93478. * @hidden
  93479. */
  93480. _bSphereRadiusFactor: number;
  93481. private _scene;
  93482. private _positions;
  93483. private _indices;
  93484. private _normals;
  93485. private _colors;
  93486. private _uvs;
  93487. private _indices32;
  93488. private _positions32;
  93489. private _normals32;
  93490. private _fixedNormal32;
  93491. private _colors32;
  93492. private _uvs32;
  93493. private _index;
  93494. private _updatable;
  93495. private _pickable;
  93496. private _isVisibilityBoxLocked;
  93497. private _alwaysVisible;
  93498. private _depthSort;
  93499. private _expandable;
  93500. private _shapeCounter;
  93501. private _copy;
  93502. private _color;
  93503. private _computeParticleColor;
  93504. private _computeParticleTexture;
  93505. private _computeParticleRotation;
  93506. private _computeParticleVertex;
  93507. private _computeBoundingBox;
  93508. private _depthSortParticles;
  93509. private _camera;
  93510. private _mustUnrotateFixedNormals;
  93511. private _particlesIntersect;
  93512. private _needs32Bits;
  93513. private _isNotBuilt;
  93514. private _lastParticleId;
  93515. private _idxOfId;
  93516. /**
  93517. * Creates a SPS (Solid Particle System) object.
  93518. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93519. * @param scene (Scene) is the scene in which the SPS is added.
  93520. * @param options defines the options of the sps e.g.
  93521. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93522. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93523. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93524. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93525. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93526. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93527. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93528. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93529. */
  93530. constructor(name: string, scene: Scene, options?: {
  93531. updatable?: boolean;
  93532. isPickable?: boolean;
  93533. enableDepthSort?: boolean;
  93534. particleIntersection?: boolean;
  93535. boundingSphereOnly?: boolean;
  93536. bSphereRadiusFactor?: number;
  93537. expandable?: boolean;
  93538. });
  93539. /**
  93540. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93541. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93542. * @returns the created mesh
  93543. */
  93544. buildMesh(): Mesh;
  93545. /**
  93546. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93547. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93548. * Thus the particles generated from `digest()` have their property `position` set yet.
  93549. * @param mesh ( Mesh ) is the mesh to be digested
  93550. * @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
  93551. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93552. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93553. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93554. * @returns the current SPS
  93555. */
  93556. digest(mesh: Mesh, options?: {
  93557. facetNb?: number;
  93558. number?: number;
  93559. delta?: number;
  93560. storage?: [];
  93561. }): SolidParticleSystem;
  93562. /**
  93563. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  93564. * @hidden
  93565. */
  93566. private _unrotateFixedNormals;
  93567. /**
  93568. * Resets the temporary working copy particle
  93569. * @hidden
  93570. */
  93571. private _resetCopy;
  93572. /**
  93573. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  93574. * @param p the current index in the positions array to be updated
  93575. * @param shape a Vector3 array, the shape geometry
  93576. * @param positions the positions array to be updated
  93577. * @param meshInd the shape indices array
  93578. * @param indices the indices array to be updated
  93579. * @param meshUV the shape uv array
  93580. * @param uvs the uv array to be updated
  93581. * @param meshCol the shape color array
  93582. * @param colors the color array to be updated
  93583. * @param meshNor the shape normals array
  93584. * @param normals the normals array to be updated
  93585. * @param idx the particle index
  93586. * @param idxInShape the particle index in its shape
  93587. * @param options the addShape() method passed options
  93588. * @hidden
  93589. */
  93590. private _meshBuilder;
  93591. /**
  93592. * Returns a shape Vector3 array from positions float array
  93593. * @param positions float array
  93594. * @returns a vector3 array
  93595. * @hidden
  93596. */
  93597. private _posToShape;
  93598. /**
  93599. * Returns a shapeUV array from a float uvs (array deep copy)
  93600. * @param uvs as a float array
  93601. * @returns a shapeUV array
  93602. * @hidden
  93603. */
  93604. private _uvsToShapeUV;
  93605. /**
  93606. * Adds a new particle object in the particles array
  93607. * @param idx particle index in particles array
  93608. * @param id particle id
  93609. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  93610. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  93611. * @param model particle ModelShape object
  93612. * @param shapeId model shape identifier
  93613. * @param idxInShape index of the particle in the current model
  93614. * @param bInfo model bounding info object
  93615. * @param storage target storage array, if any
  93616. * @hidden
  93617. */
  93618. private _addParticle;
  93619. /**
  93620. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93621. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93622. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93623. * @param nb (positive integer) the number of particles to be created from this model
  93624. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93625. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93626. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93627. * @returns the number of shapes in the system
  93628. */
  93629. addShape(mesh: Mesh, nb: number, options?: {
  93630. positionFunction?: any;
  93631. vertexFunction?: any;
  93632. storage?: [];
  93633. }): number;
  93634. /**
  93635. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  93636. * @hidden
  93637. */
  93638. private _rebuildParticle;
  93639. /**
  93640. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93641. * @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.
  93642. * @returns the SPS.
  93643. */
  93644. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93645. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93646. * Returns an array with the removed particles.
  93647. * 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.
  93648. * The SPS can't be empty so at least one particle needs to remain in place.
  93649. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93650. * @param start index of the first particle to remove
  93651. * @param end index of the last particle to remove (included)
  93652. * @returns an array populated with the removed particles
  93653. */
  93654. removeParticles(start: number, end: number): SolidParticle[];
  93655. /**
  93656. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  93657. * @param solidParticleArray an array populated with Solid Particles objects
  93658. * @returns the SPS
  93659. */
  93660. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  93661. /**
  93662. * Creates a new particle and modifies the SPS mesh geometry :
  93663. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  93664. * - calls _addParticle() to populate the particle array
  93665. * factorized code from addShape() and insertParticlesFromArray()
  93666. * @param idx particle index in the particles array
  93667. * @param i particle index in its shape
  93668. * @param modelShape particle ModelShape object
  93669. * @param shape shape vertex array
  93670. * @param meshInd shape indices array
  93671. * @param meshUV shape uv array
  93672. * @param meshCol shape color array
  93673. * @param meshNor shape normals array
  93674. * @param bbInfo shape bounding info
  93675. * @param storage target particle storage
  93676. * @options addShape() passed options
  93677. * @hidden
  93678. */
  93679. private _insertNewParticle;
  93680. /**
  93681. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93682. * This method calls `updateParticle()` for each particle of the SPS.
  93683. * For an animated SPS, it is usually called within the render loop.
  93684. * 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.
  93685. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93686. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93687. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93688. * @returns the SPS.
  93689. */
  93690. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93691. /**
  93692. * Disposes the SPS.
  93693. */
  93694. dispose(): void;
  93695. /**
  93696. * Returns a SolidParticle object from its identifier : particle.id
  93697. * @param id (integer) the particle Id
  93698. * @returns the searched particle or null if not found in the SPS.
  93699. */
  93700. getParticleById(id: number): Nullable<SolidParticle>;
  93701. /**
  93702. * Returns a new array populated with the particles having the passed shapeId.
  93703. * @param shapeId (integer) the shape identifier
  93704. * @returns a new solid particle array
  93705. */
  93706. getParticlesByShapeId(shapeId: number): SolidParticle[];
  93707. /**
  93708. * Populates the passed array "ref" with the particles having the passed shapeId.
  93709. * @param shapeId the shape identifier
  93710. * @returns the SPS
  93711. * @param ref
  93712. */
  93713. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  93714. /**
  93715. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93716. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93717. * @returns the SPS.
  93718. */
  93719. refreshVisibleSize(): SolidParticleSystem;
  93720. /**
  93721. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93722. * @param size the size (float) of the visibility box
  93723. * note : this doesn't lock the SPS mesh bounding box.
  93724. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93725. */
  93726. setVisibilityBox(size: number): void;
  93727. /**
  93728. * Gets whether the SPS as always visible or not
  93729. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93730. */
  93731. /**
  93732. * Sets the SPS as always visible or not
  93733. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93734. */
  93735. isAlwaysVisible: boolean;
  93736. /**
  93737. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93738. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93739. */
  93740. /**
  93741. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93742. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93743. */
  93744. isVisibilityBoxLocked: boolean;
  93745. /**
  93746. * Tells to `setParticles()` to compute the particle rotations or not.
  93747. * Default value : true. The SPS is faster when it's set to false.
  93748. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93749. */
  93750. /**
  93751. * Gets if `setParticles()` computes the particle rotations or not.
  93752. * Default value : true. The SPS is faster when it's set to false.
  93753. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93754. */
  93755. computeParticleRotation: boolean;
  93756. /**
  93757. * Tells to `setParticles()` to compute the particle colors or not.
  93758. * Default value : true. The SPS is faster when it's set to false.
  93759. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93760. */
  93761. /**
  93762. * Gets if `setParticles()` computes the particle colors or not.
  93763. * Default value : true. The SPS is faster when it's set to false.
  93764. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93765. */
  93766. computeParticleColor: boolean;
  93767. /**
  93768. * Gets if `setParticles()` computes the particle textures or not.
  93769. * Default value : true. The SPS is faster when it's set to false.
  93770. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  93771. */
  93772. computeParticleTexture: boolean;
  93773. /**
  93774. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  93775. * Default value : false. The SPS is faster when it's set to false.
  93776. * Note : the particle custom vertex positions aren't stored values.
  93777. */
  93778. /**
  93779. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93780. * Default value : false. The SPS is faster when it's set to false.
  93781. * Note : the particle custom vertex positions aren't stored values.
  93782. */
  93783. computeParticleVertex: boolean;
  93784. /**
  93785. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93786. */
  93787. /**
  93788. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  93789. */
  93790. computeBoundingBox: boolean;
  93791. /**
  93792. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  93793. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93794. * Default : `true`
  93795. */
  93796. /**
  93797. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  93798. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93799. * Default : `true`
  93800. */
  93801. depthSortParticles: boolean;
  93802. /**
  93803. * Gets if the SPS is created as expandable at construction time.
  93804. * Default : `false`
  93805. */
  93806. readonly expandable: boolean;
  93807. /**
  93808. * This function does nothing. It may be overwritten to set all the particle first values.
  93809. * The SPS doesn't call this function, you may have to call it by your own.
  93810. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93811. */
  93812. initParticles(): void;
  93813. /**
  93814. * This function does nothing. It may be overwritten to recycle a particle.
  93815. * The SPS doesn't call this function, you may have to call it by your own.
  93816. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93817. * @param particle The particle to recycle
  93818. * @returns the recycled particle
  93819. */
  93820. recycleParticle(particle: SolidParticle): SolidParticle;
  93821. /**
  93822. * Updates a particle : this function should be overwritten by the user.
  93823. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  93824. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93825. * @example : just set a particle position or velocity and recycle conditions
  93826. * @param particle The particle to update
  93827. * @returns the updated particle
  93828. */
  93829. updateParticle(particle: SolidParticle): SolidParticle;
  93830. /**
  93831. * Updates a vertex of a particle : it can be overwritten by the user.
  93832. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  93833. * @param particle the current particle
  93834. * @param vertex the current index of the current particle
  93835. * @param pt the index of the current vertex in the particle shape
  93836. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93837. * @example : just set a vertex particle position
  93838. * @returns the updated vertex
  93839. */
  93840. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93841. /**
  93842. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93843. * This does nothing and may be overwritten by the user.
  93844. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93845. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93846. * @param update the boolean update value actually passed to setParticles()
  93847. */
  93848. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93849. /**
  93850. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93851. * This will be passed three parameters.
  93852. * This does nothing and may be overwritten by the user.
  93853. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93854. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93855. * @param update the boolean update value actually passed to setParticles()
  93856. */
  93857. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93858. }
  93859. }
  93860. declare module BABYLON {
  93861. /**
  93862. * Represents one particle of a solid particle system.
  93863. */
  93864. export class SolidParticle {
  93865. /**
  93866. * particle global index
  93867. */
  93868. idx: number;
  93869. /**
  93870. * particle identifier
  93871. */
  93872. id: number;
  93873. /**
  93874. * The color of the particle
  93875. */
  93876. color: Nullable<Color4>;
  93877. /**
  93878. * The world space position of the particle.
  93879. */
  93880. position: Vector3;
  93881. /**
  93882. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93883. */
  93884. rotation: Vector3;
  93885. /**
  93886. * The world space rotation quaternion of the particle.
  93887. */
  93888. rotationQuaternion: Nullable<Quaternion>;
  93889. /**
  93890. * The scaling of the particle.
  93891. */
  93892. scaling: Vector3;
  93893. /**
  93894. * The uvs of the particle.
  93895. */
  93896. uvs: Vector4;
  93897. /**
  93898. * The current speed of the particle.
  93899. */
  93900. velocity: Vector3;
  93901. /**
  93902. * The pivot point in the particle local space.
  93903. */
  93904. pivot: Vector3;
  93905. /**
  93906. * Must the particle be translated from its pivot point in its local space ?
  93907. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93908. * Default : false
  93909. */
  93910. translateFromPivot: boolean;
  93911. /**
  93912. * Is the particle active or not ?
  93913. */
  93914. alive: boolean;
  93915. /**
  93916. * Is the particle visible or not ?
  93917. */
  93918. isVisible: boolean;
  93919. /**
  93920. * Index of this particle in the global "positions" array (Internal use)
  93921. * @hidden
  93922. */
  93923. _pos: number;
  93924. /**
  93925. * @hidden Index of this particle in the global "indices" array (Internal use)
  93926. */
  93927. _ind: number;
  93928. /**
  93929. * @hidden ModelShape of this particle (Internal use)
  93930. */
  93931. _model: ModelShape;
  93932. /**
  93933. * ModelShape id of this particle
  93934. */
  93935. shapeId: number;
  93936. /**
  93937. * Index of the particle in its shape id
  93938. */
  93939. idxInShape: number;
  93940. /**
  93941. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93942. */
  93943. _modelBoundingInfo: BoundingInfo;
  93944. /**
  93945. * @hidden Particle BoundingInfo object (Internal use)
  93946. */
  93947. _boundingInfo: BoundingInfo;
  93948. /**
  93949. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93950. */
  93951. _sps: SolidParticleSystem;
  93952. /**
  93953. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93954. */
  93955. _stillInvisible: boolean;
  93956. /**
  93957. * @hidden Last computed particle rotation matrix
  93958. */
  93959. _rotationMatrix: number[];
  93960. /**
  93961. * Parent particle Id, if any.
  93962. * Default null.
  93963. */
  93964. parentId: Nullable<number>;
  93965. /**
  93966. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93967. * The possible values are :
  93968. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93969. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93970. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93971. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93972. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93973. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93974. * */
  93975. cullingStrategy: number;
  93976. /**
  93977. * @hidden Internal global position in the SPS.
  93978. */
  93979. _globalPosition: Vector3;
  93980. /**
  93981. * Creates a Solid Particle object.
  93982. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93983. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  93984. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  93985. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93986. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93987. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93988. * @param shapeId (integer) is the model shape identifier in the SPS.
  93989. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93990. * @param sps defines the sps it is associated to
  93991. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93992. */
  93993. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93994. /**
  93995. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  93996. * @param target the particle target
  93997. * @returns the current particle
  93998. */
  93999. copyToRef(target: SolidParticle): SolidParticle;
  94000. /**
  94001. * Legacy support, changed scale to scaling
  94002. */
  94003. /**
  94004. * Legacy support, changed scale to scaling
  94005. */
  94006. scale: Vector3;
  94007. /**
  94008. * Legacy support, changed quaternion to rotationQuaternion
  94009. */
  94010. /**
  94011. * Legacy support, changed quaternion to rotationQuaternion
  94012. */
  94013. quaternion: Nullable<Quaternion>;
  94014. /**
  94015. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94016. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94017. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94018. * @returns true if it intersects
  94019. */
  94020. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94021. /**
  94022. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94023. * A particle is in the frustum if its bounding box intersects the frustum
  94024. * @param frustumPlanes defines the frustum to test
  94025. * @returns true if the particle is in the frustum planes
  94026. */
  94027. isInFrustum(frustumPlanes: Plane[]): boolean;
  94028. /**
  94029. * get the rotation matrix of the particle
  94030. * @hidden
  94031. */
  94032. getRotationMatrix(m: Matrix): void;
  94033. }
  94034. /**
  94035. * Represents the shape of the model used by one particle of a solid particle system.
  94036. * SPS internal tool, don't use it manually.
  94037. */
  94038. export class ModelShape {
  94039. /**
  94040. * The shape id
  94041. * @hidden
  94042. */
  94043. shapeID: number;
  94044. /**
  94045. * flat array of model positions (internal use)
  94046. * @hidden
  94047. */
  94048. _shape: Vector3[];
  94049. /**
  94050. * flat array of model UVs (internal use)
  94051. * @hidden
  94052. */
  94053. _shapeUV: number[];
  94054. /**
  94055. * color array of the model
  94056. * @hidden
  94057. */
  94058. _shapeColors: number[];
  94059. /**
  94060. * indices array of the model
  94061. * @hidden
  94062. */
  94063. _indices: number[];
  94064. /**
  94065. * normals array of the model
  94066. * @hidden
  94067. */
  94068. _normals: number[];
  94069. /**
  94070. * length of the shape in the model indices array (internal use)
  94071. * @hidden
  94072. */
  94073. _indicesLength: number;
  94074. /**
  94075. * Custom position function (internal use)
  94076. * @hidden
  94077. */
  94078. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94079. /**
  94080. * Custom vertex function (internal use)
  94081. * @hidden
  94082. */
  94083. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94084. /**
  94085. * 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.
  94086. * SPS internal tool, don't use it manually.
  94087. * @hidden
  94088. */
  94089. 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>);
  94090. }
  94091. /**
  94092. * Represents a Depth Sorted Particle in the solid particle system.
  94093. */
  94094. export class DepthSortedParticle {
  94095. /**
  94096. * Index of the particle in the "indices" array
  94097. */
  94098. ind: number;
  94099. /**
  94100. * Length of the particle shape in the "indices" array
  94101. */
  94102. indicesLength: number;
  94103. /**
  94104. * Squared distance from the particle to the camera
  94105. */
  94106. sqDistance: number;
  94107. }
  94108. }
  94109. declare module BABYLON {
  94110. /**
  94111. * @hidden
  94112. */
  94113. export class _MeshCollisionData {
  94114. _checkCollisions: boolean;
  94115. _collisionMask: number;
  94116. _collisionGroup: number;
  94117. _collider: Nullable<Collider>;
  94118. _oldPositionForCollisions: Vector3;
  94119. _diffPositionForCollisions: Vector3;
  94120. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94121. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94122. }
  94123. }
  94124. declare module BABYLON {
  94125. /** @hidden */
  94126. class _FacetDataStorage {
  94127. facetPositions: Vector3[];
  94128. facetNormals: Vector3[];
  94129. facetPartitioning: number[][];
  94130. facetNb: number;
  94131. partitioningSubdivisions: number;
  94132. partitioningBBoxRatio: number;
  94133. facetDataEnabled: boolean;
  94134. facetParameters: any;
  94135. bbSize: Vector3;
  94136. subDiv: {
  94137. max: number;
  94138. X: number;
  94139. Y: number;
  94140. Z: number;
  94141. };
  94142. facetDepthSort: boolean;
  94143. facetDepthSortEnabled: boolean;
  94144. depthSortedIndices: IndicesArray;
  94145. depthSortedFacets: {
  94146. ind: number;
  94147. sqDistance: number;
  94148. }[];
  94149. facetDepthSortFunction: (f1: {
  94150. ind: number;
  94151. sqDistance: number;
  94152. }, f2: {
  94153. ind: number;
  94154. sqDistance: number;
  94155. }) => number;
  94156. facetDepthSortFrom: Vector3;
  94157. facetDepthSortOrigin: Vector3;
  94158. invertedMatrix: Matrix;
  94159. }
  94160. /**
  94161. * @hidden
  94162. **/
  94163. class _InternalAbstractMeshDataInfo {
  94164. _hasVertexAlpha: boolean;
  94165. _useVertexColors: boolean;
  94166. _numBoneInfluencers: number;
  94167. _applyFog: boolean;
  94168. _receiveShadows: boolean;
  94169. _facetData: _FacetDataStorage;
  94170. _visibility: number;
  94171. _skeleton: Nullable<Skeleton>;
  94172. _layerMask: number;
  94173. _computeBonesUsingShaders: boolean;
  94174. _isActive: boolean;
  94175. _onlyForInstances: boolean;
  94176. _isActiveIntermediate: boolean;
  94177. _onlyForInstancesIntermediate: boolean;
  94178. _actAsRegularMesh: boolean;
  94179. }
  94180. /**
  94181. * Class used to store all common mesh properties
  94182. */
  94183. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94184. /** No occlusion */
  94185. static OCCLUSION_TYPE_NONE: number;
  94186. /** Occlusion set to optimisitic */
  94187. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94188. /** Occlusion set to strict */
  94189. static OCCLUSION_TYPE_STRICT: number;
  94190. /** Use an accurante occlusion algorithm */
  94191. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94192. /** Use a conservative occlusion algorithm */
  94193. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94194. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94195. * Test order :
  94196. * Is the bounding sphere outside the frustum ?
  94197. * If not, are the bounding box vertices outside the frustum ?
  94198. * It not, then the cullable object is in the frustum.
  94199. */
  94200. static readonly CULLINGSTRATEGY_STANDARD: number;
  94201. /** Culling strategy : Bounding Sphere Only.
  94202. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94203. * It's also less accurate than the standard because some not visible objects can still be selected.
  94204. * Test : is the bounding sphere outside the frustum ?
  94205. * If not, then the cullable object is in the frustum.
  94206. */
  94207. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94208. /** Culling strategy : Optimistic Inclusion.
  94209. * This in an inclusion test first, then the standard exclusion test.
  94210. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94211. * 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.
  94212. * Anyway, it's as accurate as the standard strategy.
  94213. * Test :
  94214. * Is the cullable object bounding sphere center in the frustum ?
  94215. * If not, apply the default culling strategy.
  94216. */
  94217. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94218. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94219. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94220. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94221. * 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.
  94222. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94223. * Test :
  94224. * Is the cullable object bounding sphere center in the frustum ?
  94225. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94226. */
  94227. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94228. /**
  94229. * No billboard
  94230. */
  94231. static readonly BILLBOARDMODE_NONE: number;
  94232. /** Billboard on X axis */
  94233. static readonly BILLBOARDMODE_X: number;
  94234. /** Billboard on Y axis */
  94235. static readonly BILLBOARDMODE_Y: number;
  94236. /** Billboard on Z axis */
  94237. static readonly BILLBOARDMODE_Z: number;
  94238. /** Billboard on all axes */
  94239. static readonly BILLBOARDMODE_ALL: number;
  94240. /** Billboard on using position instead of orientation */
  94241. static readonly BILLBOARDMODE_USE_POSITION: number;
  94242. /** @hidden */
  94243. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94244. /**
  94245. * The culling strategy to use to check whether the mesh must be rendered or not.
  94246. * This value can be changed at any time and will be used on the next render mesh selection.
  94247. * The possible values are :
  94248. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94249. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94250. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94251. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94252. * Please read each static variable documentation to get details about the culling process.
  94253. * */
  94254. cullingStrategy: number;
  94255. /**
  94256. * Gets the number of facets in the mesh
  94257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94258. */
  94259. readonly facetNb: number;
  94260. /**
  94261. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94263. */
  94264. partitioningSubdivisions: number;
  94265. /**
  94266. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94267. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94269. */
  94270. partitioningBBoxRatio: number;
  94271. /**
  94272. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94273. * Works only for updatable meshes.
  94274. * Doesn't work with multi-materials
  94275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94276. */
  94277. mustDepthSortFacets: boolean;
  94278. /**
  94279. * The location (Vector3) where the facet depth sort must be computed from.
  94280. * By default, the active camera position.
  94281. * Used only when facet depth sort is enabled
  94282. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94283. */
  94284. facetDepthSortFrom: Vector3;
  94285. /**
  94286. * gets a boolean indicating if facetData is enabled
  94287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94288. */
  94289. readonly isFacetDataEnabled: boolean;
  94290. /** @hidden */
  94291. _updateNonUniformScalingState(value: boolean): boolean;
  94292. /**
  94293. * An event triggered when this mesh collides with another one
  94294. */
  94295. onCollideObservable: Observable<AbstractMesh>;
  94296. /** Set a function to call when this mesh collides with another one */
  94297. onCollide: () => void;
  94298. /**
  94299. * An event triggered when the collision's position changes
  94300. */
  94301. onCollisionPositionChangeObservable: Observable<Vector3>;
  94302. /** Set a function to call when the collision's position changes */
  94303. onCollisionPositionChange: () => void;
  94304. /**
  94305. * An event triggered when material is changed
  94306. */
  94307. onMaterialChangedObservable: Observable<AbstractMesh>;
  94308. /**
  94309. * Gets or sets the orientation for POV movement & rotation
  94310. */
  94311. definedFacingForward: boolean;
  94312. /** @hidden */
  94313. _occlusionQuery: Nullable<WebGLQuery>;
  94314. /** @hidden */
  94315. _renderingGroup: Nullable<RenderingGroup>;
  94316. /**
  94317. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94318. */
  94319. /**
  94320. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94321. */
  94322. visibility: number;
  94323. /** Gets or sets the alpha index used to sort transparent meshes
  94324. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94325. */
  94326. alphaIndex: number;
  94327. /**
  94328. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94329. */
  94330. isVisible: boolean;
  94331. /**
  94332. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94333. */
  94334. isPickable: boolean;
  94335. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94336. showSubMeshesBoundingBox: boolean;
  94337. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94338. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94339. */
  94340. isBlocker: boolean;
  94341. /**
  94342. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94343. */
  94344. enablePointerMoveEvents: boolean;
  94345. /**
  94346. * Specifies the rendering group id for this mesh (0 by default)
  94347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94348. */
  94349. renderingGroupId: number;
  94350. private _material;
  94351. /** Gets or sets current material */
  94352. material: Nullable<Material>;
  94353. /**
  94354. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94355. * @see http://doc.babylonjs.com/babylon101/shadows
  94356. */
  94357. receiveShadows: boolean;
  94358. /** Defines color to use when rendering outline */
  94359. outlineColor: Color3;
  94360. /** Define width to use when rendering outline */
  94361. outlineWidth: number;
  94362. /** Defines color to use when rendering overlay */
  94363. overlayColor: Color3;
  94364. /** Defines alpha to use when rendering overlay */
  94365. overlayAlpha: number;
  94366. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94367. hasVertexAlpha: boolean;
  94368. /** 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) */
  94369. useVertexColors: boolean;
  94370. /**
  94371. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94372. */
  94373. computeBonesUsingShaders: boolean;
  94374. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94375. numBoneInfluencers: number;
  94376. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94377. applyFog: boolean;
  94378. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94379. useOctreeForRenderingSelection: boolean;
  94380. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94381. useOctreeForPicking: boolean;
  94382. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94383. useOctreeForCollisions: boolean;
  94384. /**
  94385. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94386. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94387. */
  94388. layerMask: number;
  94389. /**
  94390. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94391. */
  94392. alwaysSelectAsActiveMesh: boolean;
  94393. /**
  94394. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94395. */
  94396. doNotSyncBoundingInfo: boolean;
  94397. /**
  94398. * Gets or sets the current action manager
  94399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94400. */
  94401. actionManager: Nullable<AbstractActionManager>;
  94402. private _meshCollisionData;
  94403. /**
  94404. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94405. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94406. */
  94407. ellipsoid: Vector3;
  94408. /**
  94409. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94411. */
  94412. ellipsoidOffset: Vector3;
  94413. /**
  94414. * Gets or sets a collision mask used to mask collisions (default is -1).
  94415. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94416. */
  94417. collisionMask: number;
  94418. /**
  94419. * Gets or sets the current collision group mask (-1 by default).
  94420. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94421. */
  94422. collisionGroup: number;
  94423. /**
  94424. * Defines edge width used when edgesRenderer is enabled
  94425. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94426. */
  94427. edgesWidth: number;
  94428. /**
  94429. * Defines edge color used when edgesRenderer is enabled
  94430. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94431. */
  94432. edgesColor: Color4;
  94433. /** @hidden */
  94434. _edgesRenderer: Nullable<IEdgesRenderer>;
  94435. /** @hidden */
  94436. _masterMesh: Nullable<AbstractMesh>;
  94437. /** @hidden */
  94438. _boundingInfo: Nullable<BoundingInfo>;
  94439. /** @hidden */
  94440. _renderId: number;
  94441. /**
  94442. * Gets or sets the list of subMeshes
  94443. * @see http://doc.babylonjs.com/how_to/multi_materials
  94444. */
  94445. subMeshes: SubMesh[];
  94446. /** @hidden */
  94447. _intersectionsInProgress: AbstractMesh[];
  94448. /** @hidden */
  94449. _unIndexed: boolean;
  94450. /** @hidden */
  94451. _lightSources: Light[];
  94452. /** Gets the list of lights affecting that mesh */
  94453. readonly lightSources: Light[];
  94454. /** @hidden */
  94455. readonly _positions: Nullable<Vector3[]>;
  94456. /** @hidden */
  94457. _waitingData: {
  94458. lods: Nullable<any>;
  94459. actions: Nullable<any>;
  94460. freezeWorldMatrix: Nullable<boolean>;
  94461. };
  94462. /** @hidden */
  94463. _bonesTransformMatrices: Nullable<Float32Array>;
  94464. /** @hidden */
  94465. _transformMatrixTexture: Nullable<RawTexture>;
  94466. /**
  94467. * Gets or sets a skeleton to apply skining transformations
  94468. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94469. */
  94470. skeleton: Nullable<Skeleton>;
  94471. /**
  94472. * An event triggered when the mesh is rebuilt.
  94473. */
  94474. onRebuildObservable: Observable<AbstractMesh>;
  94475. /**
  94476. * Creates a new AbstractMesh
  94477. * @param name defines the name of the mesh
  94478. * @param scene defines the hosting scene
  94479. */
  94480. constructor(name: string, scene?: Nullable<Scene>);
  94481. /**
  94482. * Returns the string "AbstractMesh"
  94483. * @returns "AbstractMesh"
  94484. */
  94485. getClassName(): string;
  94486. /**
  94487. * Gets a string representation of the current mesh
  94488. * @param fullDetails defines a boolean indicating if full details must be included
  94489. * @returns a string representation of the current mesh
  94490. */
  94491. toString(fullDetails?: boolean): string;
  94492. /**
  94493. * @hidden
  94494. */
  94495. protected _getEffectiveParent(): Nullable<Node>;
  94496. /** @hidden */
  94497. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94498. /** @hidden */
  94499. _rebuild(): void;
  94500. /** @hidden */
  94501. _resyncLightSources(): void;
  94502. /** @hidden */
  94503. _resyncLighSource(light: Light): void;
  94504. /** @hidden */
  94505. _unBindEffect(): void;
  94506. /** @hidden */
  94507. _removeLightSource(light: Light, dispose: boolean): void;
  94508. private _markSubMeshesAsDirty;
  94509. /** @hidden */
  94510. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94511. /** @hidden */
  94512. _markSubMeshesAsAttributesDirty(): void;
  94513. /** @hidden */
  94514. _markSubMeshesAsMiscDirty(): void;
  94515. /**
  94516. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94517. */
  94518. scaling: Vector3;
  94519. /**
  94520. * Returns true if the mesh is blocked. Implemented by child classes
  94521. */
  94522. readonly isBlocked: boolean;
  94523. /**
  94524. * Returns the mesh itself by default. Implemented by child classes
  94525. * @param camera defines the camera to use to pick the right LOD level
  94526. * @returns the currentAbstractMesh
  94527. */
  94528. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94529. /**
  94530. * Returns 0 by default. Implemented by child classes
  94531. * @returns an integer
  94532. */
  94533. getTotalVertices(): number;
  94534. /**
  94535. * Returns a positive integer : the total number of indices in this mesh geometry.
  94536. * @returns the numner of indices or zero if the mesh has no geometry.
  94537. */
  94538. getTotalIndices(): number;
  94539. /**
  94540. * Returns null by default. Implemented by child classes
  94541. * @returns null
  94542. */
  94543. getIndices(): Nullable<IndicesArray>;
  94544. /**
  94545. * Returns the array of the requested vertex data kind. Implemented by child classes
  94546. * @param kind defines the vertex data kind to use
  94547. * @returns null
  94548. */
  94549. getVerticesData(kind: string): Nullable<FloatArray>;
  94550. /**
  94551. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94552. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94553. * Note that a new underlying VertexBuffer object is created each call.
  94554. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94555. * @param kind defines vertex data kind:
  94556. * * VertexBuffer.PositionKind
  94557. * * VertexBuffer.UVKind
  94558. * * VertexBuffer.UV2Kind
  94559. * * VertexBuffer.UV3Kind
  94560. * * VertexBuffer.UV4Kind
  94561. * * VertexBuffer.UV5Kind
  94562. * * VertexBuffer.UV6Kind
  94563. * * VertexBuffer.ColorKind
  94564. * * VertexBuffer.MatricesIndicesKind
  94565. * * VertexBuffer.MatricesIndicesExtraKind
  94566. * * VertexBuffer.MatricesWeightsKind
  94567. * * VertexBuffer.MatricesWeightsExtraKind
  94568. * @param data defines the data source
  94569. * @param updatable defines if the data must be flagged as updatable (or static)
  94570. * @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
  94571. * @returns the current mesh
  94572. */
  94573. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94574. /**
  94575. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94576. * If the mesh has no geometry, it is simply returned as it is.
  94577. * @param kind defines vertex data kind:
  94578. * * VertexBuffer.PositionKind
  94579. * * VertexBuffer.UVKind
  94580. * * VertexBuffer.UV2Kind
  94581. * * VertexBuffer.UV3Kind
  94582. * * VertexBuffer.UV4Kind
  94583. * * VertexBuffer.UV5Kind
  94584. * * VertexBuffer.UV6Kind
  94585. * * VertexBuffer.ColorKind
  94586. * * VertexBuffer.MatricesIndicesKind
  94587. * * VertexBuffer.MatricesIndicesExtraKind
  94588. * * VertexBuffer.MatricesWeightsKind
  94589. * * VertexBuffer.MatricesWeightsExtraKind
  94590. * @param data defines the data source
  94591. * @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
  94592. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94593. * @returns the current mesh
  94594. */
  94595. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94596. /**
  94597. * Sets the mesh indices,
  94598. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94599. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94600. * @param totalVertices Defines the total number of vertices
  94601. * @returns the current mesh
  94602. */
  94603. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94604. /**
  94605. * Gets a boolean indicating if specific vertex data is present
  94606. * @param kind defines the vertex data kind to use
  94607. * @returns true is data kind is present
  94608. */
  94609. isVerticesDataPresent(kind: string): boolean;
  94610. /**
  94611. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94612. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94613. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94614. * @returns a BoundingInfo
  94615. */
  94616. getBoundingInfo(): BoundingInfo;
  94617. /**
  94618. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94619. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94620. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94621. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94622. * @returns the current mesh
  94623. */
  94624. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94625. /**
  94626. * Overwrite the current bounding info
  94627. * @param boundingInfo defines the new bounding info
  94628. * @returns the current mesh
  94629. */
  94630. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94631. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94632. readonly useBones: boolean;
  94633. /** @hidden */
  94634. _preActivate(): void;
  94635. /** @hidden */
  94636. _preActivateForIntermediateRendering(renderId: number): void;
  94637. /** @hidden */
  94638. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94639. /** @hidden */
  94640. _postActivate(): void;
  94641. /** @hidden */
  94642. _freeze(): void;
  94643. /** @hidden */
  94644. _unFreeze(): void;
  94645. /**
  94646. * Gets the current world matrix
  94647. * @returns a Matrix
  94648. */
  94649. getWorldMatrix(): Matrix;
  94650. /** @hidden */
  94651. _getWorldMatrixDeterminant(): number;
  94652. /**
  94653. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94654. */
  94655. readonly isAnInstance: boolean;
  94656. /**
  94657. * Gets a boolean indicating if this mesh has instances
  94658. */
  94659. readonly hasInstances: boolean;
  94660. /**
  94661. * Perform relative position change from the point of view of behind the front of the mesh.
  94662. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94663. * Supports definition of mesh facing forward or backward
  94664. * @param amountRight defines the distance on the right axis
  94665. * @param amountUp defines the distance on the up axis
  94666. * @param amountForward defines the distance on the forward axis
  94667. * @returns the current mesh
  94668. */
  94669. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94670. /**
  94671. * Calculate relative position change from the point of view of behind the front of the mesh.
  94672. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94673. * Supports definition of mesh facing forward or backward
  94674. * @param amountRight defines the distance on the right axis
  94675. * @param amountUp defines the distance on the up axis
  94676. * @param amountForward defines the distance on the forward axis
  94677. * @returns the new displacement vector
  94678. */
  94679. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94680. /**
  94681. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94682. * Supports definition of mesh facing forward or backward
  94683. * @param flipBack defines the flip
  94684. * @param twirlClockwise defines the twirl
  94685. * @param tiltRight defines the tilt
  94686. * @returns the current mesh
  94687. */
  94688. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94689. /**
  94690. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94691. * Supports definition of mesh facing forward or backward.
  94692. * @param flipBack defines the flip
  94693. * @param twirlClockwise defines the twirl
  94694. * @param tiltRight defines the tilt
  94695. * @returns the new rotation vector
  94696. */
  94697. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94698. /**
  94699. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94700. * This means the mesh underlying bounding box and sphere are recomputed.
  94701. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94702. * @returns the current mesh
  94703. */
  94704. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94705. /** @hidden */
  94706. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94707. /** @hidden */
  94708. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94709. /** @hidden */
  94710. _updateBoundingInfo(): AbstractMesh;
  94711. /** @hidden */
  94712. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94713. /** @hidden */
  94714. protected _afterComputeWorldMatrix(): void;
  94715. /** @hidden */
  94716. readonly _effectiveMesh: AbstractMesh;
  94717. /**
  94718. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94719. * A mesh is in the frustum if its bounding box intersects the frustum
  94720. * @param frustumPlanes defines the frustum to test
  94721. * @returns true if the mesh is in the frustum planes
  94722. */
  94723. isInFrustum(frustumPlanes: Plane[]): boolean;
  94724. /**
  94725. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94726. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94727. * @param frustumPlanes defines the frustum to test
  94728. * @returns true if the mesh is completely in the frustum planes
  94729. */
  94730. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94731. /**
  94732. * True if the mesh intersects another mesh or a SolidParticle object
  94733. * @param mesh defines a target mesh or SolidParticle to test
  94734. * @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)
  94735. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94736. * @returns true if there is an intersection
  94737. */
  94738. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94739. /**
  94740. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94741. * @param point defines the point to test
  94742. * @returns true if there is an intersection
  94743. */
  94744. intersectsPoint(point: Vector3): boolean;
  94745. /**
  94746. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94747. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94748. */
  94749. checkCollisions: boolean;
  94750. /**
  94751. * Gets Collider object used to compute collisions (not physics)
  94752. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94753. */
  94754. readonly collider: Nullable<Collider>;
  94755. /**
  94756. * Move the mesh using collision engine
  94757. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94758. * @param displacement defines the requested displacement vector
  94759. * @returns the current mesh
  94760. */
  94761. moveWithCollisions(displacement: Vector3): AbstractMesh;
  94762. private _onCollisionPositionChange;
  94763. /** @hidden */
  94764. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  94765. /** @hidden */
  94766. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  94767. /** @hidden */
  94768. _checkCollision(collider: Collider): AbstractMesh;
  94769. /** @hidden */
  94770. _generatePointsArray(): boolean;
  94771. /**
  94772. * Checks if the passed Ray intersects with the mesh
  94773. * @param ray defines the ray to use
  94774. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  94775. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94776. * @returns the picking info
  94777. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  94778. */
  94779. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  94780. /**
  94781. * Clones the current mesh
  94782. * @param name defines the mesh name
  94783. * @param newParent defines the new mesh parent
  94784. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  94785. * @returns the new mesh
  94786. */
  94787. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  94788. /**
  94789. * Disposes all the submeshes of the current meshnp
  94790. * @returns the current mesh
  94791. */
  94792. releaseSubMeshes(): AbstractMesh;
  94793. /**
  94794. * Releases resources associated with this abstract mesh.
  94795. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94796. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94797. */
  94798. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94799. /**
  94800. * Adds the passed mesh as a child to the current mesh
  94801. * @param mesh defines the child mesh
  94802. * @returns the current mesh
  94803. */
  94804. addChild(mesh: AbstractMesh): AbstractMesh;
  94805. /**
  94806. * Removes the passed mesh from the current mesh children list
  94807. * @param mesh defines the child mesh
  94808. * @returns the current mesh
  94809. */
  94810. removeChild(mesh: AbstractMesh): AbstractMesh;
  94811. /** @hidden */
  94812. private _initFacetData;
  94813. /**
  94814. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  94815. * This method can be called within the render loop.
  94816. * 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
  94817. * @returns the current mesh
  94818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94819. */
  94820. updateFacetData(): AbstractMesh;
  94821. /**
  94822. * Returns the facetLocalNormals array.
  94823. * The normals are expressed in the mesh local spac
  94824. * @returns an array of Vector3
  94825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94826. */
  94827. getFacetLocalNormals(): Vector3[];
  94828. /**
  94829. * Returns the facetLocalPositions array.
  94830. * The facet positions are expressed in the mesh local space
  94831. * @returns an array of Vector3
  94832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94833. */
  94834. getFacetLocalPositions(): Vector3[];
  94835. /**
  94836. * Returns the facetLocalPartioning array
  94837. * @returns an array of array of numbers
  94838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94839. */
  94840. getFacetLocalPartitioning(): number[][];
  94841. /**
  94842. * Returns the i-th facet position in the world system.
  94843. * This method allocates a new Vector3 per call
  94844. * @param i defines the facet index
  94845. * @returns a new Vector3
  94846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94847. */
  94848. getFacetPosition(i: number): Vector3;
  94849. /**
  94850. * Sets the reference Vector3 with the i-th facet position in the world system
  94851. * @param i defines the facet index
  94852. * @param ref defines the target vector
  94853. * @returns the current mesh
  94854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94855. */
  94856. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94857. /**
  94858. * Returns the i-th facet normal in the world system.
  94859. * This method allocates a new Vector3 per call
  94860. * @param i defines the facet index
  94861. * @returns a new Vector3
  94862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94863. */
  94864. getFacetNormal(i: number): Vector3;
  94865. /**
  94866. * Sets the reference Vector3 with the i-th facet normal in the world system
  94867. * @param i defines the facet index
  94868. * @param ref defines the target vector
  94869. * @returns the current mesh
  94870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94871. */
  94872. getFacetNormalToRef(i: number, ref: Vector3): this;
  94873. /**
  94874. * 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)
  94875. * @param x defines x coordinate
  94876. * @param y defines y coordinate
  94877. * @param z defines z coordinate
  94878. * @returns the array of facet indexes
  94879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94880. */
  94881. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94882. /**
  94883. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94884. * @param projected sets as the (x,y,z) world projection on the facet
  94885. * @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
  94886. * @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
  94887. * @param x defines x coordinate
  94888. * @param y defines y coordinate
  94889. * @param z defines z coordinate
  94890. * @returns the face index if found (or null instead)
  94891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94892. */
  94893. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94894. /**
  94895. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94896. * @param projected sets as the (x,y,z) local projection on the facet
  94897. * @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
  94898. * @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
  94899. * @param x defines x coordinate
  94900. * @param y defines y coordinate
  94901. * @param z defines z coordinate
  94902. * @returns the face index if found (or null instead)
  94903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94904. */
  94905. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94906. /**
  94907. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94908. * @returns the parameters
  94909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94910. */
  94911. getFacetDataParameters(): any;
  94912. /**
  94913. * Disables the feature FacetData and frees the related memory
  94914. * @returns the current mesh
  94915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94916. */
  94917. disableFacetData(): AbstractMesh;
  94918. /**
  94919. * Updates the AbstractMesh indices array
  94920. * @param indices defines the data source
  94921. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94922. * @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)
  94923. * @returns the current mesh
  94924. */
  94925. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94926. /**
  94927. * Creates new normals data for the mesh
  94928. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94929. * @returns the current mesh
  94930. */
  94931. createNormals(updatable: boolean): AbstractMesh;
  94932. /**
  94933. * Align the mesh with a normal
  94934. * @param normal defines the normal to use
  94935. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94936. * @returns the current mesh
  94937. */
  94938. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94939. /** @hidden */
  94940. _checkOcclusionQuery(): boolean;
  94941. /**
  94942. * Disables the mesh edge rendering mode
  94943. * @returns the currentAbstractMesh
  94944. */
  94945. disableEdgesRendering(): AbstractMesh;
  94946. /**
  94947. * Enables the edge rendering mode on the mesh.
  94948. * This mode makes the mesh edges visible
  94949. * @param epsilon defines the maximal distance between two angles to detect a face
  94950. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94951. * @returns the currentAbstractMesh
  94952. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94953. */
  94954. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94955. }
  94956. }
  94957. declare module BABYLON {
  94958. /**
  94959. * Interface used to define ActionEvent
  94960. */
  94961. export interface IActionEvent {
  94962. /** The mesh or sprite that triggered the action */
  94963. source: any;
  94964. /** The X mouse cursor position at the time of the event */
  94965. pointerX: number;
  94966. /** The Y mouse cursor position at the time of the event */
  94967. pointerY: number;
  94968. /** The mesh that is currently pointed at (can be null) */
  94969. meshUnderPointer: Nullable<AbstractMesh>;
  94970. /** the original (browser) event that triggered the ActionEvent */
  94971. sourceEvent?: any;
  94972. /** additional data for the event */
  94973. additionalData?: any;
  94974. }
  94975. /**
  94976. * ActionEvent is the event being sent when an action is triggered.
  94977. */
  94978. export class ActionEvent implements IActionEvent {
  94979. /** The mesh or sprite that triggered the action */
  94980. source: any;
  94981. /** The X mouse cursor position at the time of the event */
  94982. pointerX: number;
  94983. /** The Y mouse cursor position at the time of the event */
  94984. pointerY: number;
  94985. /** The mesh that is currently pointed at (can be null) */
  94986. meshUnderPointer: Nullable<AbstractMesh>;
  94987. /** the original (browser) event that triggered the ActionEvent */
  94988. sourceEvent?: any;
  94989. /** additional data for the event */
  94990. additionalData?: any;
  94991. /**
  94992. * Creates a new ActionEvent
  94993. * @param source The mesh or sprite that triggered the action
  94994. * @param pointerX The X mouse cursor position at the time of the event
  94995. * @param pointerY The Y mouse cursor position at the time of the event
  94996. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94997. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94998. * @param additionalData additional data for the event
  94999. */
  95000. constructor(
  95001. /** The mesh or sprite that triggered the action */
  95002. source: any,
  95003. /** The X mouse cursor position at the time of the event */
  95004. pointerX: number,
  95005. /** The Y mouse cursor position at the time of the event */
  95006. pointerY: number,
  95007. /** The mesh that is currently pointed at (can be null) */
  95008. meshUnderPointer: Nullable<AbstractMesh>,
  95009. /** the original (browser) event that triggered the ActionEvent */
  95010. sourceEvent?: any,
  95011. /** additional data for the event */
  95012. additionalData?: any);
  95013. /**
  95014. * Helper function to auto-create an ActionEvent from a source mesh.
  95015. * @param source The source mesh that triggered the event
  95016. * @param evt The original (browser) event
  95017. * @param additionalData additional data for the event
  95018. * @returns the new ActionEvent
  95019. */
  95020. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95021. /**
  95022. * Helper function to auto-create an ActionEvent from a source sprite
  95023. * @param source The source sprite that triggered the event
  95024. * @param scene Scene associated with the sprite
  95025. * @param evt The original (browser) event
  95026. * @param additionalData additional data for the event
  95027. * @returns the new ActionEvent
  95028. */
  95029. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95030. /**
  95031. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95032. * @param scene the scene where the event occurred
  95033. * @param evt The original (browser) event
  95034. * @returns the new ActionEvent
  95035. */
  95036. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95037. /**
  95038. * Helper function to auto-create an ActionEvent from a primitive
  95039. * @param prim defines the target primitive
  95040. * @param pointerPos defines the pointer position
  95041. * @param evt The original (browser) event
  95042. * @param additionalData additional data for the event
  95043. * @returns the new ActionEvent
  95044. */
  95045. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95046. }
  95047. }
  95048. declare module BABYLON {
  95049. /**
  95050. * Abstract class used to decouple action Manager from scene and meshes.
  95051. * Do not instantiate.
  95052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95053. */
  95054. export abstract class AbstractActionManager implements IDisposable {
  95055. /** Gets the list of active triggers */
  95056. static Triggers: {
  95057. [key: string]: number;
  95058. };
  95059. /** Gets the cursor to use when hovering items */
  95060. hoverCursor: string;
  95061. /** Gets the list of actions */
  95062. actions: IAction[];
  95063. /**
  95064. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95065. */
  95066. isRecursive: boolean;
  95067. /**
  95068. * Releases all associated resources
  95069. */
  95070. abstract dispose(): void;
  95071. /**
  95072. * Does this action manager has pointer triggers
  95073. */
  95074. abstract readonly hasPointerTriggers: boolean;
  95075. /**
  95076. * Does this action manager has pick triggers
  95077. */
  95078. abstract readonly hasPickTriggers: boolean;
  95079. /**
  95080. * Process a specific trigger
  95081. * @param trigger defines the trigger to process
  95082. * @param evt defines the event details to be processed
  95083. */
  95084. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95085. /**
  95086. * Does this action manager handles actions of any of the given triggers
  95087. * @param triggers defines the triggers to be tested
  95088. * @return a boolean indicating whether one (or more) of the triggers is handled
  95089. */
  95090. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95091. /**
  95092. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95093. * speed.
  95094. * @param triggerA defines the trigger to be tested
  95095. * @param triggerB defines the trigger to be tested
  95096. * @return a boolean indicating whether one (or more) of the triggers is handled
  95097. */
  95098. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95099. /**
  95100. * Does this action manager handles actions of a given trigger
  95101. * @param trigger defines the trigger to be tested
  95102. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95103. * @return whether the trigger is handled
  95104. */
  95105. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95106. /**
  95107. * Serialize this manager to a JSON object
  95108. * @param name defines the property name to store this manager
  95109. * @returns a JSON representation of this manager
  95110. */
  95111. abstract serialize(name: string): any;
  95112. /**
  95113. * Registers an action to this action manager
  95114. * @param action defines the action to be registered
  95115. * @return the action amended (prepared) after registration
  95116. */
  95117. abstract registerAction(action: IAction): Nullable<IAction>;
  95118. /**
  95119. * Unregisters an action to this action manager
  95120. * @param action defines the action to be unregistered
  95121. * @return a boolean indicating whether the action has been unregistered
  95122. */
  95123. abstract unregisterAction(action: IAction): Boolean;
  95124. /**
  95125. * Does exist one action manager with at least one trigger
  95126. **/
  95127. static readonly HasTriggers: boolean;
  95128. /**
  95129. * Does exist one action manager with at least one pick trigger
  95130. **/
  95131. static readonly HasPickTriggers: boolean;
  95132. /**
  95133. * Does exist one action manager that handles actions of a given trigger
  95134. * @param trigger defines the trigger to be tested
  95135. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95136. **/
  95137. static HasSpecificTrigger(trigger: number): boolean;
  95138. }
  95139. }
  95140. declare module BABYLON {
  95141. /**
  95142. * Defines how a node can be built from a string name.
  95143. */
  95144. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95145. /**
  95146. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95147. */
  95148. export class Node implements IBehaviorAware<Node> {
  95149. /** @hidden */
  95150. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95151. private static _NodeConstructors;
  95152. /**
  95153. * Add a new node constructor
  95154. * @param type defines the type name of the node to construct
  95155. * @param constructorFunc defines the constructor function
  95156. */
  95157. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95158. /**
  95159. * Returns a node constructor based on type name
  95160. * @param type defines the type name
  95161. * @param name defines the new node name
  95162. * @param scene defines the hosting scene
  95163. * @param options defines optional options to transmit to constructors
  95164. * @returns the new constructor or null
  95165. */
  95166. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95167. /**
  95168. * Gets or sets the name of the node
  95169. */
  95170. name: string;
  95171. /**
  95172. * Gets or sets the id of the node
  95173. */
  95174. id: string;
  95175. /**
  95176. * Gets or sets the unique id of the node
  95177. */
  95178. uniqueId: number;
  95179. /**
  95180. * Gets or sets a string used to store user defined state for the node
  95181. */
  95182. state: string;
  95183. /**
  95184. * Gets or sets an object used to store user defined information for the node
  95185. */
  95186. metadata: any;
  95187. /**
  95188. * For internal use only. Please do not use.
  95189. */
  95190. reservedDataStore: any;
  95191. /**
  95192. * List of inspectable custom properties (used by the Inspector)
  95193. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95194. */
  95195. inspectableCustomProperties: IInspectable[];
  95196. private _doNotSerialize;
  95197. /**
  95198. * Gets or sets a boolean used to define if the node must be serialized
  95199. */
  95200. doNotSerialize: boolean;
  95201. /** @hidden */
  95202. _isDisposed: boolean;
  95203. /**
  95204. * Gets a list of Animations associated with the node
  95205. */
  95206. animations: Animation[];
  95207. protected _ranges: {
  95208. [name: string]: Nullable<AnimationRange>;
  95209. };
  95210. /**
  95211. * Callback raised when the node is ready to be used
  95212. */
  95213. onReady: Nullable<(node: Node) => void>;
  95214. private _isEnabled;
  95215. private _isParentEnabled;
  95216. private _isReady;
  95217. /** @hidden */
  95218. _currentRenderId: number;
  95219. private _parentUpdateId;
  95220. /** @hidden */
  95221. _childUpdateId: number;
  95222. /** @hidden */
  95223. _waitingParentId: Nullable<string>;
  95224. /** @hidden */
  95225. _scene: Scene;
  95226. /** @hidden */
  95227. _cache: any;
  95228. private _parentNode;
  95229. private _children;
  95230. /** @hidden */
  95231. _worldMatrix: Matrix;
  95232. /** @hidden */
  95233. _worldMatrixDeterminant: number;
  95234. /** @hidden */
  95235. _worldMatrixDeterminantIsDirty: boolean;
  95236. /** @hidden */
  95237. private _sceneRootNodesIndex;
  95238. /**
  95239. * Gets a boolean indicating if the node has been disposed
  95240. * @returns true if the node was disposed
  95241. */
  95242. isDisposed(): boolean;
  95243. /**
  95244. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95245. * @see https://doc.babylonjs.com/how_to/parenting
  95246. */
  95247. parent: Nullable<Node>;
  95248. /** @hidden */
  95249. _addToSceneRootNodes(): void;
  95250. /** @hidden */
  95251. _removeFromSceneRootNodes(): void;
  95252. private _animationPropertiesOverride;
  95253. /**
  95254. * Gets or sets the animation properties override
  95255. */
  95256. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95257. /**
  95258. * Gets a string idenfifying the name of the class
  95259. * @returns "Node" string
  95260. */
  95261. getClassName(): string;
  95262. /** @hidden */
  95263. readonly _isNode: boolean;
  95264. /**
  95265. * An event triggered when the mesh is disposed
  95266. */
  95267. onDisposeObservable: Observable<Node>;
  95268. private _onDisposeObserver;
  95269. /**
  95270. * Sets a callback that will be raised when the node will be disposed
  95271. */
  95272. onDispose: () => void;
  95273. /**
  95274. * Creates a new Node
  95275. * @param name the name and id to be given to this node
  95276. * @param scene the scene this node will be added to
  95277. */
  95278. constructor(name: string, scene?: Nullable<Scene>);
  95279. /**
  95280. * Gets the scene of the node
  95281. * @returns a scene
  95282. */
  95283. getScene(): Scene;
  95284. /**
  95285. * Gets the engine of the node
  95286. * @returns a Engine
  95287. */
  95288. getEngine(): Engine;
  95289. private _behaviors;
  95290. /**
  95291. * Attach a behavior to the node
  95292. * @see http://doc.babylonjs.com/features/behaviour
  95293. * @param behavior defines the behavior to attach
  95294. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95295. * @returns the current Node
  95296. */
  95297. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95298. /**
  95299. * Remove an attached behavior
  95300. * @see http://doc.babylonjs.com/features/behaviour
  95301. * @param behavior defines the behavior to attach
  95302. * @returns the current Node
  95303. */
  95304. removeBehavior(behavior: Behavior<Node>): Node;
  95305. /**
  95306. * Gets the list of attached behaviors
  95307. * @see http://doc.babylonjs.com/features/behaviour
  95308. */
  95309. readonly behaviors: Behavior<Node>[];
  95310. /**
  95311. * Gets an attached behavior by name
  95312. * @param name defines the name of the behavior to look for
  95313. * @see http://doc.babylonjs.com/features/behaviour
  95314. * @returns null if behavior was not found else the requested behavior
  95315. */
  95316. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95317. /**
  95318. * Returns the latest update of the World matrix
  95319. * @returns a Matrix
  95320. */
  95321. getWorldMatrix(): Matrix;
  95322. /** @hidden */
  95323. _getWorldMatrixDeterminant(): number;
  95324. /**
  95325. * Returns directly the latest state of the mesh World matrix.
  95326. * A Matrix is returned.
  95327. */
  95328. readonly worldMatrixFromCache: Matrix;
  95329. /** @hidden */
  95330. _initCache(): void;
  95331. /** @hidden */
  95332. updateCache(force?: boolean): void;
  95333. /** @hidden */
  95334. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95335. /** @hidden */
  95336. _updateCache(ignoreParentClass?: boolean): void;
  95337. /** @hidden */
  95338. _isSynchronized(): boolean;
  95339. /** @hidden */
  95340. _markSyncedWithParent(): void;
  95341. /** @hidden */
  95342. isSynchronizedWithParent(): boolean;
  95343. /** @hidden */
  95344. isSynchronized(): boolean;
  95345. /**
  95346. * Is this node ready to be used/rendered
  95347. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95348. * @return true if the node is ready
  95349. */
  95350. isReady(completeCheck?: boolean): boolean;
  95351. /**
  95352. * Is this node enabled?
  95353. * 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
  95354. * @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
  95355. * @return whether this node (and its parent) is enabled
  95356. */
  95357. isEnabled(checkAncestors?: boolean): boolean;
  95358. /** @hidden */
  95359. protected _syncParentEnabledState(): void;
  95360. /**
  95361. * Set the enabled state of this node
  95362. * @param value defines the new enabled state
  95363. */
  95364. setEnabled(value: boolean): void;
  95365. /**
  95366. * Is this node a descendant of the given node?
  95367. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95368. * @param ancestor defines the parent node to inspect
  95369. * @returns a boolean indicating if this node is a descendant of the given node
  95370. */
  95371. isDescendantOf(ancestor: Node): boolean;
  95372. /** @hidden */
  95373. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95374. /**
  95375. * Will return all nodes that have this node as ascendant
  95376. * @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
  95377. * @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
  95378. * @return all children nodes of all types
  95379. */
  95380. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95381. /**
  95382. * Get all child-meshes of this node
  95383. * @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)
  95384. * @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
  95385. * @returns an array of AbstractMesh
  95386. */
  95387. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95388. /**
  95389. * Get all direct children of this node
  95390. * @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
  95391. * @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)
  95392. * @returns an array of Node
  95393. */
  95394. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95395. /** @hidden */
  95396. _setReady(state: boolean): void;
  95397. /**
  95398. * Get an animation by name
  95399. * @param name defines the name of the animation to look for
  95400. * @returns null if not found else the requested animation
  95401. */
  95402. getAnimationByName(name: string): Nullable<Animation>;
  95403. /**
  95404. * Creates an animation range for this node
  95405. * @param name defines the name of the range
  95406. * @param from defines the starting key
  95407. * @param to defines the end key
  95408. */
  95409. createAnimationRange(name: string, from: number, to: number): void;
  95410. /**
  95411. * Delete a specific animation range
  95412. * @param name defines the name of the range to delete
  95413. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95414. */
  95415. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95416. /**
  95417. * Get an animation range by name
  95418. * @param name defines the name of the animation range to look for
  95419. * @returns null if not found else the requested animation range
  95420. */
  95421. getAnimationRange(name: string): Nullable<AnimationRange>;
  95422. /**
  95423. * Gets the list of all animation ranges defined on this node
  95424. * @returns an array
  95425. */
  95426. getAnimationRanges(): Nullable<AnimationRange>[];
  95427. /**
  95428. * Will start the animation sequence
  95429. * @param name defines the range frames for animation sequence
  95430. * @param loop defines if the animation should loop (false by default)
  95431. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95432. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95433. * @returns the object created for this animation. If range does not exist, it will return null
  95434. */
  95435. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95436. /**
  95437. * Serialize animation ranges into a JSON compatible object
  95438. * @returns serialization object
  95439. */
  95440. serializeAnimationRanges(): any;
  95441. /**
  95442. * Computes the world matrix of the node
  95443. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95444. * @returns the world matrix
  95445. */
  95446. computeWorldMatrix(force?: boolean): Matrix;
  95447. /**
  95448. * Releases resources associated with this node.
  95449. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95450. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95451. */
  95452. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95453. /**
  95454. * Parse animation range data from a serialization object and store them into a given node
  95455. * @param node defines where to store the animation ranges
  95456. * @param parsedNode defines the serialization object to read data from
  95457. * @param scene defines the hosting scene
  95458. */
  95459. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95460. /**
  95461. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95462. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95463. * @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
  95464. * @returns the new bounding vectors
  95465. */
  95466. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95467. min: Vector3;
  95468. max: Vector3;
  95469. };
  95470. }
  95471. }
  95472. declare module BABYLON {
  95473. /**
  95474. * @hidden
  95475. */
  95476. export class _IAnimationState {
  95477. key: number;
  95478. repeatCount: number;
  95479. workValue?: any;
  95480. loopMode?: number;
  95481. offsetValue?: any;
  95482. highLimitValue?: any;
  95483. }
  95484. /**
  95485. * Class used to store any kind of animation
  95486. */
  95487. export class Animation {
  95488. /**Name of the animation */
  95489. name: string;
  95490. /**Property to animate */
  95491. targetProperty: string;
  95492. /**The frames per second of the animation */
  95493. framePerSecond: number;
  95494. /**The data type of the animation */
  95495. dataType: number;
  95496. /**The loop mode of the animation */
  95497. loopMode?: number | undefined;
  95498. /**Specifies if blending should be enabled */
  95499. enableBlending?: boolean | undefined;
  95500. /**
  95501. * Use matrix interpolation instead of using direct key value when animating matrices
  95502. */
  95503. static AllowMatricesInterpolation: boolean;
  95504. /**
  95505. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95506. */
  95507. static AllowMatrixDecomposeForInterpolation: boolean;
  95508. /**
  95509. * Stores the key frames of the animation
  95510. */
  95511. private _keys;
  95512. /**
  95513. * Stores the easing function of the animation
  95514. */
  95515. private _easingFunction;
  95516. /**
  95517. * @hidden Internal use only
  95518. */
  95519. _runtimeAnimations: RuntimeAnimation[];
  95520. /**
  95521. * The set of event that will be linked to this animation
  95522. */
  95523. private _events;
  95524. /**
  95525. * Stores an array of target property paths
  95526. */
  95527. targetPropertyPath: string[];
  95528. /**
  95529. * Stores the blending speed of the animation
  95530. */
  95531. blendingSpeed: number;
  95532. /**
  95533. * Stores the animation ranges for the animation
  95534. */
  95535. private _ranges;
  95536. /**
  95537. * @hidden Internal use
  95538. */
  95539. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95540. /**
  95541. * Sets up an animation
  95542. * @param property The property to animate
  95543. * @param animationType The animation type to apply
  95544. * @param framePerSecond The frames per second of the animation
  95545. * @param easingFunction The easing function used in the animation
  95546. * @returns The created animation
  95547. */
  95548. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95549. /**
  95550. * Create and start an animation on a node
  95551. * @param name defines the name of the global animation that will be run on all nodes
  95552. * @param node defines the root node where the animation will take place
  95553. * @param targetProperty defines property to animate
  95554. * @param framePerSecond defines the number of frame per second yo use
  95555. * @param totalFrame defines the number of frames in total
  95556. * @param from defines the initial value
  95557. * @param to defines the final value
  95558. * @param loopMode defines which loop mode you want to use (off by default)
  95559. * @param easingFunction defines the easing function to use (linear by default)
  95560. * @param onAnimationEnd defines the callback to call when animation end
  95561. * @returns the animatable created for this animation
  95562. */
  95563. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95564. /**
  95565. * Create and start an animation on a node and its descendants
  95566. * @param name defines the name of the global animation that will be run on all nodes
  95567. * @param node defines the root node where the animation will take place
  95568. * @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
  95569. * @param targetProperty defines property to animate
  95570. * @param framePerSecond defines the number of frame per second to use
  95571. * @param totalFrame defines the number of frames in total
  95572. * @param from defines the initial value
  95573. * @param to defines the final value
  95574. * @param loopMode defines which loop mode you want to use (off by default)
  95575. * @param easingFunction defines the easing function to use (linear by default)
  95576. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95577. * @returns the list of animatables created for all nodes
  95578. * @example https://www.babylonjs-playground.com/#MH0VLI
  95579. */
  95580. 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[]>;
  95581. /**
  95582. * Creates a new animation, merges it with the existing animations and starts it
  95583. * @param name Name of the animation
  95584. * @param node Node which contains the scene that begins the animations
  95585. * @param targetProperty Specifies which property to animate
  95586. * @param framePerSecond The frames per second of the animation
  95587. * @param totalFrame The total number of frames
  95588. * @param from The frame at the beginning of the animation
  95589. * @param to The frame at the end of the animation
  95590. * @param loopMode Specifies the loop mode of the animation
  95591. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95592. * @param onAnimationEnd Callback to run once the animation is complete
  95593. * @returns Nullable animation
  95594. */
  95595. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95596. /**
  95597. * Transition property of an host to the target Value
  95598. * @param property The property to transition
  95599. * @param targetValue The target Value of the property
  95600. * @param host The object where the property to animate belongs
  95601. * @param scene Scene used to run the animation
  95602. * @param frameRate Framerate (in frame/s) to use
  95603. * @param transition The transition type we want to use
  95604. * @param duration The duration of the animation, in milliseconds
  95605. * @param onAnimationEnd Callback trigger at the end of the animation
  95606. * @returns Nullable animation
  95607. */
  95608. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95609. /**
  95610. * Return the array of runtime animations currently using this animation
  95611. */
  95612. readonly runtimeAnimations: RuntimeAnimation[];
  95613. /**
  95614. * Specifies if any of the runtime animations are currently running
  95615. */
  95616. readonly hasRunningRuntimeAnimations: boolean;
  95617. /**
  95618. * Initializes the animation
  95619. * @param name Name of the animation
  95620. * @param targetProperty Property to animate
  95621. * @param framePerSecond The frames per second of the animation
  95622. * @param dataType The data type of the animation
  95623. * @param loopMode The loop mode of the animation
  95624. * @param enableBlending Specifies if blending should be enabled
  95625. */
  95626. constructor(
  95627. /**Name of the animation */
  95628. name: string,
  95629. /**Property to animate */
  95630. targetProperty: string,
  95631. /**The frames per second of the animation */
  95632. framePerSecond: number,
  95633. /**The data type of the animation */
  95634. dataType: number,
  95635. /**The loop mode of the animation */
  95636. loopMode?: number | undefined,
  95637. /**Specifies if blending should be enabled */
  95638. enableBlending?: boolean | undefined);
  95639. /**
  95640. * Converts the animation to a string
  95641. * @param fullDetails support for multiple levels of logging within scene loading
  95642. * @returns String form of the animation
  95643. */
  95644. toString(fullDetails?: boolean): string;
  95645. /**
  95646. * Add an event to this animation
  95647. * @param event Event to add
  95648. */
  95649. addEvent(event: AnimationEvent): void;
  95650. /**
  95651. * Remove all events found at the given frame
  95652. * @param frame The frame to remove events from
  95653. */
  95654. removeEvents(frame: number): void;
  95655. /**
  95656. * Retrieves all the events from the animation
  95657. * @returns Events from the animation
  95658. */
  95659. getEvents(): AnimationEvent[];
  95660. /**
  95661. * Creates an animation range
  95662. * @param name Name of the animation range
  95663. * @param from Starting frame of the animation range
  95664. * @param to Ending frame of the animation
  95665. */
  95666. createRange(name: string, from: number, to: number): void;
  95667. /**
  95668. * Deletes an animation range by name
  95669. * @param name Name of the animation range to delete
  95670. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95671. */
  95672. deleteRange(name: string, deleteFrames?: boolean): void;
  95673. /**
  95674. * Gets the animation range by name, or null if not defined
  95675. * @param name Name of the animation range
  95676. * @returns Nullable animation range
  95677. */
  95678. getRange(name: string): Nullable<AnimationRange>;
  95679. /**
  95680. * Gets the key frames from the animation
  95681. * @returns The key frames of the animation
  95682. */
  95683. getKeys(): Array<IAnimationKey>;
  95684. /**
  95685. * Gets the highest frame rate of the animation
  95686. * @returns Highest frame rate of the animation
  95687. */
  95688. getHighestFrame(): number;
  95689. /**
  95690. * Gets the easing function of the animation
  95691. * @returns Easing function of the animation
  95692. */
  95693. getEasingFunction(): IEasingFunction;
  95694. /**
  95695. * Sets the easing function of the animation
  95696. * @param easingFunction A custom mathematical formula for animation
  95697. */
  95698. setEasingFunction(easingFunction: EasingFunction): void;
  95699. /**
  95700. * Interpolates a scalar linearly
  95701. * @param startValue Start value of the animation curve
  95702. * @param endValue End value of the animation curve
  95703. * @param gradient Scalar amount to interpolate
  95704. * @returns Interpolated scalar value
  95705. */
  95706. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95707. /**
  95708. * Interpolates a scalar cubically
  95709. * @param startValue Start value of the animation curve
  95710. * @param outTangent End tangent of the animation
  95711. * @param endValue End value of the animation curve
  95712. * @param inTangent Start tangent of the animation curve
  95713. * @param gradient Scalar amount to interpolate
  95714. * @returns Interpolated scalar value
  95715. */
  95716. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95717. /**
  95718. * Interpolates a quaternion using a spherical linear interpolation
  95719. * @param startValue Start value of the animation curve
  95720. * @param endValue End value of the animation curve
  95721. * @param gradient Scalar amount to interpolate
  95722. * @returns Interpolated quaternion value
  95723. */
  95724. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95725. /**
  95726. * Interpolates a quaternion cubically
  95727. * @param startValue Start value of the animation curve
  95728. * @param outTangent End tangent of the animation curve
  95729. * @param endValue End value of the animation curve
  95730. * @param inTangent Start tangent of the animation curve
  95731. * @param gradient Scalar amount to interpolate
  95732. * @returns Interpolated quaternion value
  95733. */
  95734. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95735. /**
  95736. * Interpolates a Vector3 linearl
  95737. * @param startValue Start value of the animation curve
  95738. * @param endValue End value of the animation curve
  95739. * @param gradient Scalar amount to interpolate
  95740. * @returns Interpolated scalar value
  95741. */
  95742. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95743. /**
  95744. * Interpolates a Vector3 cubically
  95745. * @param startValue Start value of the animation curve
  95746. * @param outTangent End tangent of the animation
  95747. * @param endValue End value of the animation curve
  95748. * @param inTangent Start tangent of the animation curve
  95749. * @param gradient Scalar amount to interpolate
  95750. * @returns InterpolatedVector3 value
  95751. */
  95752. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95753. /**
  95754. * Interpolates a Vector2 linearly
  95755. * @param startValue Start value of the animation curve
  95756. * @param endValue End value of the animation curve
  95757. * @param gradient Scalar amount to interpolate
  95758. * @returns Interpolated Vector2 value
  95759. */
  95760. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  95761. /**
  95762. * Interpolates a Vector2 cubically
  95763. * @param startValue Start value of the animation curve
  95764. * @param outTangent End tangent of the animation
  95765. * @param endValue End value of the animation curve
  95766. * @param inTangent Start tangent of the animation curve
  95767. * @param gradient Scalar amount to interpolate
  95768. * @returns Interpolated Vector2 value
  95769. */
  95770. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  95771. /**
  95772. * Interpolates a size linearly
  95773. * @param startValue Start value of the animation curve
  95774. * @param endValue End value of the animation curve
  95775. * @param gradient Scalar amount to interpolate
  95776. * @returns Interpolated Size value
  95777. */
  95778. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  95779. /**
  95780. * Interpolates a Color3 linearly
  95781. * @param startValue Start value of the animation curve
  95782. * @param endValue End value of the animation curve
  95783. * @param gradient Scalar amount to interpolate
  95784. * @returns Interpolated Color3 value
  95785. */
  95786. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  95787. /**
  95788. * Interpolates a Color4 linearly
  95789. * @param startValue Start value of the animation curve
  95790. * @param endValue End value of the animation curve
  95791. * @param gradient Scalar amount to interpolate
  95792. * @returns Interpolated Color3 value
  95793. */
  95794. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  95795. /**
  95796. * @hidden Internal use only
  95797. */
  95798. _getKeyValue(value: any): any;
  95799. /**
  95800. * @hidden Internal use only
  95801. */
  95802. _interpolate(currentFrame: number, state: _IAnimationState): any;
  95803. /**
  95804. * Defines the function to use to interpolate matrices
  95805. * @param startValue defines the start matrix
  95806. * @param endValue defines the end matrix
  95807. * @param gradient defines the gradient between both matrices
  95808. * @param result defines an optional target matrix where to store the interpolation
  95809. * @returns the interpolated matrix
  95810. */
  95811. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  95812. /**
  95813. * Makes a copy of the animation
  95814. * @returns Cloned animation
  95815. */
  95816. clone(): Animation;
  95817. /**
  95818. * Sets the key frames of the animation
  95819. * @param values The animation key frames to set
  95820. */
  95821. setKeys(values: Array<IAnimationKey>): void;
  95822. /**
  95823. * Serializes the animation to an object
  95824. * @returns Serialized object
  95825. */
  95826. serialize(): any;
  95827. /**
  95828. * Float animation type
  95829. */
  95830. static readonly ANIMATIONTYPE_FLOAT: number;
  95831. /**
  95832. * Vector3 animation type
  95833. */
  95834. static readonly ANIMATIONTYPE_VECTOR3: number;
  95835. /**
  95836. * Quaternion animation type
  95837. */
  95838. static readonly ANIMATIONTYPE_QUATERNION: number;
  95839. /**
  95840. * Matrix animation type
  95841. */
  95842. static readonly ANIMATIONTYPE_MATRIX: number;
  95843. /**
  95844. * Color3 animation type
  95845. */
  95846. static readonly ANIMATIONTYPE_COLOR3: number;
  95847. /**
  95848. * Color3 animation type
  95849. */
  95850. static readonly ANIMATIONTYPE_COLOR4: number;
  95851. /**
  95852. * Vector2 animation type
  95853. */
  95854. static readonly ANIMATIONTYPE_VECTOR2: number;
  95855. /**
  95856. * Size animation type
  95857. */
  95858. static readonly ANIMATIONTYPE_SIZE: number;
  95859. /**
  95860. * Relative Loop Mode
  95861. */
  95862. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95863. /**
  95864. * Cycle Loop Mode
  95865. */
  95866. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95867. /**
  95868. * Constant Loop Mode
  95869. */
  95870. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95871. /** @hidden */
  95872. static _UniversalLerp(left: any, right: any, amount: number): any;
  95873. /**
  95874. * Parses an animation object and creates an animation
  95875. * @param parsedAnimation Parsed animation object
  95876. * @returns Animation object
  95877. */
  95878. static Parse(parsedAnimation: any): Animation;
  95879. /**
  95880. * Appends the serialized animations from the source animations
  95881. * @param source Source containing the animations
  95882. * @param destination Target to store the animations
  95883. */
  95884. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95885. }
  95886. }
  95887. declare module BABYLON {
  95888. /**
  95889. * Interface containing an array of animations
  95890. */
  95891. export interface IAnimatable {
  95892. /**
  95893. * Array of animations
  95894. */
  95895. animations: Nullable<Array<Animation>>;
  95896. }
  95897. }
  95898. declare module BABYLON {
  95899. /**
  95900. * This represents all the required information to add a fresnel effect on a material:
  95901. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95902. */
  95903. export class FresnelParameters {
  95904. private _isEnabled;
  95905. /**
  95906. * Define if the fresnel effect is enable or not.
  95907. */
  95908. isEnabled: boolean;
  95909. /**
  95910. * Define the color used on edges (grazing angle)
  95911. */
  95912. leftColor: Color3;
  95913. /**
  95914. * Define the color used on center
  95915. */
  95916. rightColor: Color3;
  95917. /**
  95918. * Define bias applied to computed fresnel term
  95919. */
  95920. bias: number;
  95921. /**
  95922. * Defined the power exponent applied to fresnel term
  95923. */
  95924. power: number;
  95925. /**
  95926. * Clones the current fresnel and its valuues
  95927. * @returns a clone fresnel configuration
  95928. */
  95929. clone(): FresnelParameters;
  95930. /**
  95931. * Serializes the current fresnel parameters to a JSON representation.
  95932. * @return the JSON serialization
  95933. */
  95934. serialize(): any;
  95935. /**
  95936. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95937. * @param parsedFresnelParameters Define the JSON representation
  95938. * @returns the parsed parameters
  95939. */
  95940. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95941. }
  95942. }
  95943. declare module BABYLON {
  95944. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95945. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95946. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95947. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95948. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95949. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95950. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95951. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95952. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95953. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95954. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95955. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95956. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95957. /**
  95958. * Decorator used to define property that can be serialized as reference to a camera
  95959. * @param sourceName defines the name of the property to decorate
  95960. */
  95961. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95962. /**
  95963. * Class used to help serialization objects
  95964. */
  95965. export class SerializationHelper {
  95966. /** @hidden */
  95967. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95968. /** @hidden */
  95969. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95970. /** @hidden */
  95971. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95972. /** @hidden */
  95973. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95974. /**
  95975. * Appends the serialized animations from the source animations
  95976. * @param source Source containing the animations
  95977. * @param destination Target to store the animations
  95978. */
  95979. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95980. /**
  95981. * Static function used to serialized a specific entity
  95982. * @param entity defines the entity to serialize
  95983. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95984. * @returns a JSON compatible object representing the serialization of the entity
  95985. */
  95986. static Serialize<T>(entity: T, serializationObject?: any): any;
  95987. /**
  95988. * Creates a new entity from a serialization data object
  95989. * @param creationFunction defines a function used to instanciated the new entity
  95990. * @param source defines the source serialization data
  95991. * @param scene defines the hosting scene
  95992. * @param rootUrl defines the root url for resources
  95993. * @returns a new entity
  95994. */
  95995. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95996. /**
  95997. * Clones an object
  95998. * @param creationFunction defines the function used to instanciate the new object
  95999. * @param source defines the source object
  96000. * @returns the cloned object
  96001. */
  96002. static Clone<T>(creationFunction: () => T, source: T): T;
  96003. /**
  96004. * Instanciates a new object based on a source one (some data will be shared between both object)
  96005. * @param creationFunction defines the function used to instanciate the new object
  96006. * @param source defines the source object
  96007. * @returns the new object
  96008. */
  96009. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96010. }
  96011. }
  96012. declare module BABYLON {
  96013. /**
  96014. * Class used to manipulate GUIDs
  96015. */
  96016. export class GUID {
  96017. /**
  96018. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96019. * Be aware Math.random() could cause collisions, but:
  96020. * "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"
  96021. * @returns a pseudo random id
  96022. */
  96023. static RandomId(): string;
  96024. }
  96025. }
  96026. declare module BABYLON {
  96027. /**
  96028. * Base class of all the textures in babylon.
  96029. * It groups all the common properties the materials, post process, lights... might need
  96030. * in order to make a correct use of the texture.
  96031. */
  96032. export class BaseTexture implements IAnimatable {
  96033. /**
  96034. * Default anisotropic filtering level for the application.
  96035. * It is set to 4 as a good tradeoff between perf and quality.
  96036. */
  96037. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96038. /**
  96039. * Gets or sets the unique id of the texture
  96040. */
  96041. uniqueId: number;
  96042. /**
  96043. * Define the name of the texture.
  96044. */
  96045. name: string;
  96046. /**
  96047. * Gets or sets an object used to store user defined information.
  96048. */
  96049. metadata: any;
  96050. /**
  96051. * For internal use only. Please do not use.
  96052. */
  96053. reservedDataStore: any;
  96054. private _hasAlpha;
  96055. /**
  96056. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96057. */
  96058. hasAlpha: boolean;
  96059. /**
  96060. * Defines if the alpha value should be determined via the rgb values.
  96061. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96062. */
  96063. getAlphaFromRGB: boolean;
  96064. /**
  96065. * Intensity or strength of the texture.
  96066. * It is commonly used by materials to fine tune the intensity of the texture
  96067. */
  96068. level: number;
  96069. /**
  96070. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96071. * This is part of the texture as textures usually maps to one uv set.
  96072. */
  96073. coordinatesIndex: number;
  96074. private _coordinatesMode;
  96075. /**
  96076. * How a texture is mapped.
  96077. *
  96078. * | Value | Type | Description |
  96079. * | ----- | ----------------------------------- | ----------- |
  96080. * | 0 | EXPLICIT_MODE | |
  96081. * | 1 | SPHERICAL_MODE | |
  96082. * | 2 | PLANAR_MODE | |
  96083. * | 3 | CUBIC_MODE | |
  96084. * | 4 | PROJECTION_MODE | |
  96085. * | 5 | SKYBOX_MODE | |
  96086. * | 6 | INVCUBIC_MODE | |
  96087. * | 7 | EQUIRECTANGULAR_MODE | |
  96088. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96089. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96090. */
  96091. coordinatesMode: number;
  96092. /**
  96093. * | Value | Type | Description |
  96094. * | ----- | ------------------ | ----------- |
  96095. * | 0 | CLAMP_ADDRESSMODE | |
  96096. * | 1 | WRAP_ADDRESSMODE | |
  96097. * | 2 | MIRROR_ADDRESSMODE | |
  96098. */
  96099. wrapU: number;
  96100. /**
  96101. * | Value | Type | Description |
  96102. * | ----- | ------------------ | ----------- |
  96103. * | 0 | CLAMP_ADDRESSMODE | |
  96104. * | 1 | WRAP_ADDRESSMODE | |
  96105. * | 2 | MIRROR_ADDRESSMODE | |
  96106. */
  96107. wrapV: number;
  96108. /**
  96109. * | Value | Type | Description |
  96110. * | ----- | ------------------ | ----------- |
  96111. * | 0 | CLAMP_ADDRESSMODE | |
  96112. * | 1 | WRAP_ADDRESSMODE | |
  96113. * | 2 | MIRROR_ADDRESSMODE | |
  96114. */
  96115. wrapR: number;
  96116. /**
  96117. * With compliant hardware and browser (supporting anisotropic filtering)
  96118. * this defines the level of anisotropic filtering in the texture.
  96119. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96120. */
  96121. anisotropicFilteringLevel: number;
  96122. /**
  96123. * Define if the texture is a cube texture or if false a 2d texture.
  96124. */
  96125. isCube: boolean;
  96126. /**
  96127. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96128. */
  96129. is3D: boolean;
  96130. /**
  96131. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96132. */
  96133. is2DArray: boolean;
  96134. /**
  96135. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96136. * HDR texture are usually stored in linear space.
  96137. * This only impacts the PBR and Background materials
  96138. */
  96139. gammaSpace: boolean;
  96140. /**
  96141. * Gets or sets whether or not the texture contains RGBD data.
  96142. */
  96143. isRGBD: boolean;
  96144. /**
  96145. * Is Z inverted in the texture (useful in a cube texture).
  96146. */
  96147. invertZ: boolean;
  96148. /**
  96149. * Are mip maps generated for this texture or not.
  96150. */
  96151. readonly noMipmap: boolean;
  96152. /**
  96153. * @hidden
  96154. */
  96155. lodLevelInAlpha: boolean;
  96156. /**
  96157. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96158. */
  96159. lodGenerationOffset: number;
  96160. /**
  96161. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96162. */
  96163. lodGenerationScale: number;
  96164. /**
  96165. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96166. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96167. * average roughness values.
  96168. */
  96169. linearSpecularLOD: boolean;
  96170. /**
  96171. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96172. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96173. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96174. */
  96175. irradianceTexture: Nullable<BaseTexture>;
  96176. /**
  96177. * Define if the texture is a render target.
  96178. */
  96179. isRenderTarget: boolean;
  96180. /**
  96181. * Define the unique id of the texture in the scene.
  96182. */
  96183. readonly uid: string;
  96184. /**
  96185. * Return a string representation of the texture.
  96186. * @returns the texture as a string
  96187. */
  96188. toString(): string;
  96189. /**
  96190. * Get the class name of the texture.
  96191. * @returns "BaseTexture"
  96192. */
  96193. getClassName(): string;
  96194. /**
  96195. * Define the list of animation attached to the texture.
  96196. */
  96197. animations: Animation[];
  96198. /**
  96199. * An event triggered when the texture is disposed.
  96200. */
  96201. onDisposeObservable: Observable<BaseTexture>;
  96202. private _onDisposeObserver;
  96203. /**
  96204. * Callback triggered when the texture has been disposed.
  96205. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96206. */
  96207. onDispose: () => void;
  96208. /**
  96209. * Define the current state of the loading sequence when in delayed load mode.
  96210. */
  96211. delayLoadState: number;
  96212. private _scene;
  96213. /** @hidden */
  96214. _texture: Nullable<InternalTexture>;
  96215. private _uid;
  96216. /**
  96217. * Define if the texture is preventinga material to render or not.
  96218. * If not and the texture is not ready, the engine will use a default black texture instead.
  96219. */
  96220. readonly isBlocking: boolean;
  96221. /**
  96222. * Instantiates a new BaseTexture.
  96223. * Base class of all the textures in babylon.
  96224. * It groups all the common properties the materials, post process, lights... might need
  96225. * in order to make a correct use of the texture.
  96226. * @param scene Define the scene the texture blongs to
  96227. */
  96228. constructor(scene: Nullable<Scene>);
  96229. /**
  96230. * Get the scene the texture belongs to.
  96231. * @returns the scene or null if undefined
  96232. */
  96233. getScene(): Nullable<Scene>;
  96234. /**
  96235. * Get the texture transform matrix used to offset tile the texture for istance.
  96236. * @returns the transformation matrix
  96237. */
  96238. getTextureMatrix(): Matrix;
  96239. /**
  96240. * Get the texture reflection matrix used to rotate/transform the reflection.
  96241. * @returns the reflection matrix
  96242. */
  96243. getReflectionTextureMatrix(): Matrix;
  96244. /**
  96245. * Get the underlying lower level texture from Babylon.
  96246. * @returns the insternal texture
  96247. */
  96248. getInternalTexture(): Nullable<InternalTexture>;
  96249. /**
  96250. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96251. * @returns true if ready or not blocking
  96252. */
  96253. isReadyOrNotBlocking(): boolean;
  96254. /**
  96255. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96256. * @returns true if fully ready
  96257. */
  96258. isReady(): boolean;
  96259. private _cachedSize;
  96260. /**
  96261. * Get the size of the texture.
  96262. * @returns the texture size.
  96263. */
  96264. getSize(): ISize;
  96265. /**
  96266. * Get the base size of the texture.
  96267. * It can be different from the size if the texture has been resized for POT for instance
  96268. * @returns the base size
  96269. */
  96270. getBaseSize(): ISize;
  96271. /**
  96272. * Update the sampling mode of the texture.
  96273. * Default is Trilinear mode.
  96274. *
  96275. * | Value | Type | Description |
  96276. * | ----- | ------------------ | ----------- |
  96277. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96278. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96279. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96280. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96281. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96282. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96283. * | 7 | NEAREST_LINEAR | |
  96284. * | 8 | NEAREST_NEAREST | |
  96285. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96286. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96287. * | 11 | LINEAR_LINEAR | |
  96288. * | 12 | LINEAR_NEAREST | |
  96289. *
  96290. * > _mag_: magnification filter (close to the viewer)
  96291. * > _min_: minification filter (far from the viewer)
  96292. * > _mip_: filter used between mip map levels
  96293. *@param samplingMode Define the new sampling mode of the texture
  96294. */
  96295. updateSamplingMode(samplingMode: number): void;
  96296. /**
  96297. * Scales the texture if is `canRescale()`
  96298. * @param ratio the resize factor we want to use to rescale
  96299. */
  96300. scale(ratio: number): void;
  96301. /**
  96302. * Get if the texture can rescale.
  96303. */
  96304. readonly canRescale: boolean;
  96305. /** @hidden */
  96306. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96307. /** @hidden */
  96308. _rebuild(): void;
  96309. /**
  96310. * Triggers the load sequence in delayed load mode.
  96311. */
  96312. delayLoad(): void;
  96313. /**
  96314. * Clones the texture.
  96315. * @returns the cloned texture
  96316. */
  96317. clone(): Nullable<BaseTexture>;
  96318. /**
  96319. * Get the texture underlying type (INT, FLOAT...)
  96320. */
  96321. readonly textureType: number;
  96322. /**
  96323. * Get the texture underlying format (RGB, RGBA...)
  96324. */
  96325. readonly textureFormat: number;
  96326. /**
  96327. * Indicates that textures need to be re-calculated for all materials
  96328. */
  96329. protected _markAllSubMeshesAsTexturesDirty(): void;
  96330. /**
  96331. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96332. * This will returns an RGBA array buffer containing either in values (0-255) or
  96333. * float values (0-1) depending of the underlying buffer type.
  96334. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96335. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96336. * @param buffer defines a user defined buffer to fill with data (can be null)
  96337. * @returns The Array buffer containing the pixels data.
  96338. */
  96339. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96340. /**
  96341. * Release and destroy the underlying lower level texture aka internalTexture.
  96342. */
  96343. releaseInternalTexture(): void;
  96344. /** @hidden */
  96345. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96346. /** @hidden */
  96347. readonly _lodTextureMid: Nullable<BaseTexture>;
  96348. /** @hidden */
  96349. readonly _lodTextureLow: Nullable<BaseTexture>;
  96350. /**
  96351. * Dispose the texture and release its associated resources.
  96352. */
  96353. dispose(): void;
  96354. /**
  96355. * Serialize the texture into a JSON representation that can be parsed later on.
  96356. * @returns the JSON representation of the texture
  96357. */
  96358. serialize(): any;
  96359. /**
  96360. * Helper function to be called back once a list of texture contains only ready textures.
  96361. * @param textures Define the list of textures to wait for
  96362. * @param callback Define the callback triggered once the entire list will be ready
  96363. */
  96364. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96365. }
  96366. }
  96367. declare module BABYLON {
  96368. /**
  96369. * Options to be used when creating an effect.
  96370. */
  96371. export interface IEffectCreationOptions {
  96372. /**
  96373. * Atrributes that will be used in the shader.
  96374. */
  96375. attributes: string[];
  96376. /**
  96377. * Uniform varible names that will be set in the shader.
  96378. */
  96379. uniformsNames: string[];
  96380. /**
  96381. * Uniform buffer varible names that will be set in the shader.
  96382. */
  96383. uniformBuffersNames: string[];
  96384. /**
  96385. * Sampler texture variable names that will be set in the shader.
  96386. */
  96387. samplers: string[];
  96388. /**
  96389. * Define statements that will be set in the shader.
  96390. */
  96391. defines: any;
  96392. /**
  96393. * Possible fallbacks for this effect to improve performance when needed.
  96394. */
  96395. fallbacks: Nullable<IEffectFallbacks>;
  96396. /**
  96397. * Callback that will be called when the shader is compiled.
  96398. */
  96399. onCompiled: Nullable<(effect: Effect) => void>;
  96400. /**
  96401. * Callback that will be called if an error occurs during shader compilation.
  96402. */
  96403. onError: Nullable<(effect: Effect, errors: string) => void>;
  96404. /**
  96405. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96406. */
  96407. indexParameters?: any;
  96408. /**
  96409. * Max number of lights that can be used in the shader.
  96410. */
  96411. maxSimultaneousLights?: number;
  96412. /**
  96413. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96414. */
  96415. transformFeedbackVaryings?: Nullable<string[]>;
  96416. }
  96417. /**
  96418. * Effect containing vertex and fragment shader that can be executed on an object.
  96419. */
  96420. export class Effect implements IDisposable {
  96421. /**
  96422. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96423. */
  96424. static ShadersRepository: string;
  96425. /**
  96426. * Name of the effect.
  96427. */
  96428. name: any;
  96429. /**
  96430. * String container all the define statements that should be set on the shader.
  96431. */
  96432. defines: string;
  96433. /**
  96434. * Callback that will be called when the shader is compiled.
  96435. */
  96436. onCompiled: Nullable<(effect: Effect) => void>;
  96437. /**
  96438. * Callback that will be called if an error occurs during shader compilation.
  96439. */
  96440. onError: Nullable<(effect: Effect, errors: string) => void>;
  96441. /**
  96442. * Callback that will be called when effect is bound.
  96443. */
  96444. onBind: Nullable<(effect: Effect) => void>;
  96445. /**
  96446. * Unique ID of the effect.
  96447. */
  96448. uniqueId: number;
  96449. /**
  96450. * Observable that will be called when the shader is compiled.
  96451. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96452. */
  96453. onCompileObservable: Observable<Effect>;
  96454. /**
  96455. * Observable that will be called if an error occurs during shader compilation.
  96456. */
  96457. onErrorObservable: Observable<Effect>;
  96458. /** @hidden */
  96459. _onBindObservable: Nullable<Observable<Effect>>;
  96460. /**
  96461. * Observable that will be called when effect is bound.
  96462. */
  96463. readonly onBindObservable: Observable<Effect>;
  96464. /** @hidden */
  96465. _bonesComputationForcedToCPU: boolean;
  96466. private static _uniqueIdSeed;
  96467. private _engine;
  96468. private _uniformBuffersNames;
  96469. private _uniformsNames;
  96470. private _samplerList;
  96471. private _samplers;
  96472. private _isReady;
  96473. private _compilationError;
  96474. private _allFallbacksProcessed;
  96475. private _attributesNames;
  96476. private _attributes;
  96477. private _uniforms;
  96478. /**
  96479. * Key for the effect.
  96480. * @hidden
  96481. */
  96482. _key: string;
  96483. private _indexParameters;
  96484. private _fallbacks;
  96485. private _vertexSourceCode;
  96486. private _fragmentSourceCode;
  96487. private _vertexSourceCodeOverride;
  96488. private _fragmentSourceCodeOverride;
  96489. private _transformFeedbackVaryings;
  96490. /**
  96491. * Compiled shader to webGL program.
  96492. * @hidden
  96493. */
  96494. _pipelineContext: Nullable<IPipelineContext>;
  96495. private _valueCache;
  96496. private static _baseCache;
  96497. /**
  96498. * Instantiates an effect.
  96499. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96500. * @param baseName Name of the effect.
  96501. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96502. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96503. * @param samplers List of sampler variables that will be passed to the shader.
  96504. * @param engine Engine to be used to render the effect
  96505. * @param defines Define statements to be added to the shader.
  96506. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96507. * @param onCompiled Callback that will be called when the shader is compiled.
  96508. * @param onError Callback that will be called if an error occurs during shader compilation.
  96509. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96510. */
  96511. 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);
  96512. private _useFinalCode;
  96513. /**
  96514. * Unique key for this effect
  96515. */
  96516. readonly key: string;
  96517. /**
  96518. * If the effect has been compiled and prepared.
  96519. * @returns if the effect is compiled and prepared.
  96520. */
  96521. isReady(): boolean;
  96522. private _isReadyInternal;
  96523. /**
  96524. * The engine the effect was initialized with.
  96525. * @returns the engine.
  96526. */
  96527. getEngine(): Engine;
  96528. /**
  96529. * The pipeline context for this effect
  96530. * @returns the associated pipeline context
  96531. */
  96532. getPipelineContext(): Nullable<IPipelineContext>;
  96533. /**
  96534. * The set of names of attribute variables for the shader.
  96535. * @returns An array of attribute names.
  96536. */
  96537. getAttributesNames(): string[];
  96538. /**
  96539. * Returns the attribute at the given index.
  96540. * @param index The index of the attribute.
  96541. * @returns The location of the attribute.
  96542. */
  96543. getAttributeLocation(index: number): number;
  96544. /**
  96545. * Returns the attribute based on the name of the variable.
  96546. * @param name of the attribute to look up.
  96547. * @returns the attribute location.
  96548. */
  96549. getAttributeLocationByName(name: string): number;
  96550. /**
  96551. * The number of attributes.
  96552. * @returns the numnber of attributes.
  96553. */
  96554. getAttributesCount(): number;
  96555. /**
  96556. * Gets the index of a uniform variable.
  96557. * @param uniformName of the uniform to look up.
  96558. * @returns the index.
  96559. */
  96560. getUniformIndex(uniformName: string): number;
  96561. /**
  96562. * Returns the attribute based on the name of the variable.
  96563. * @param uniformName of the uniform to look up.
  96564. * @returns the location of the uniform.
  96565. */
  96566. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96567. /**
  96568. * Returns an array of sampler variable names
  96569. * @returns The array of sampler variable neames.
  96570. */
  96571. getSamplers(): string[];
  96572. /**
  96573. * The error from the last compilation.
  96574. * @returns the error string.
  96575. */
  96576. getCompilationError(): string;
  96577. /**
  96578. * Gets a boolean indicating that all fallbacks were used during compilation
  96579. * @returns true if all fallbacks were used
  96580. */
  96581. allFallbacksProcessed(): boolean;
  96582. /**
  96583. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96584. * @param func The callback to be used.
  96585. */
  96586. executeWhenCompiled(func: (effect: Effect) => void): void;
  96587. private _checkIsReady;
  96588. private _loadShader;
  96589. /**
  96590. * Recompiles the webGL program
  96591. * @param vertexSourceCode The source code for the vertex shader.
  96592. * @param fragmentSourceCode The source code for the fragment shader.
  96593. * @param onCompiled Callback called when completed.
  96594. * @param onError Callback called on error.
  96595. * @hidden
  96596. */
  96597. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96598. /**
  96599. * Prepares the effect
  96600. * @hidden
  96601. */
  96602. _prepareEffect(): void;
  96603. private _processCompilationErrors;
  96604. /**
  96605. * Checks if the effect is supported. (Must be called after compilation)
  96606. */
  96607. readonly isSupported: boolean;
  96608. /**
  96609. * Binds a texture to the engine to be used as output of the shader.
  96610. * @param channel Name of the output variable.
  96611. * @param texture Texture to bind.
  96612. * @hidden
  96613. */
  96614. _bindTexture(channel: string, texture: InternalTexture): void;
  96615. /**
  96616. * Sets a texture on the engine to be used in the shader.
  96617. * @param channel Name of the sampler variable.
  96618. * @param texture Texture to set.
  96619. */
  96620. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96621. /**
  96622. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96623. * @param channel Name of the sampler variable.
  96624. * @param texture Texture to set.
  96625. */
  96626. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96627. /**
  96628. * Sets an array of textures on the engine to be used in the shader.
  96629. * @param channel Name of the variable.
  96630. * @param textures Textures to set.
  96631. */
  96632. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96633. /**
  96634. * 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)
  96635. * @param channel Name of the sampler variable.
  96636. * @param postProcess Post process to get the input texture from.
  96637. */
  96638. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96639. /**
  96640. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96641. * 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)
  96642. * @param channel Name of the sampler variable.
  96643. * @param postProcess Post process to get the output texture from.
  96644. */
  96645. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96646. /** @hidden */
  96647. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96648. /** @hidden */
  96649. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96650. /** @hidden */
  96651. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96652. /** @hidden */
  96653. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96654. /**
  96655. * Binds a buffer to a uniform.
  96656. * @param buffer Buffer to bind.
  96657. * @param name Name of the uniform variable to bind to.
  96658. */
  96659. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96660. /**
  96661. * Binds block to a uniform.
  96662. * @param blockName Name of the block to bind.
  96663. * @param index Index to bind.
  96664. */
  96665. bindUniformBlock(blockName: string, index: number): void;
  96666. /**
  96667. * Sets an interger value on a uniform variable.
  96668. * @param uniformName Name of the variable.
  96669. * @param value Value to be set.
  96670. * @returns this effect.
  96671. */
  96672. setInt(uniformName: string, value: number): Effect;
  96673. /**
  96674. * Sets an int array on a uniform variable.
  96675. * @param uniformName Name of the variable.
  96676. * @param array array to be set.
  96677. * @returns this effect.
  96678. */
  96679. setIntArray(uniformName: string, array: Int32Array): Effect;
  96680. /**
  96681. * 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)
  96682. * @param uniformName Name of the variable.
  96683. * @param array array to be set.
  96684. * @returns this effect.
  96685. */
  96686. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96687. /**
  96688. * 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)
  96689. * @param uniformName Name of the variable.
  96690. * @param array array to be set.
  96691. * @returns this effect.
  96692. */
  96693. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96694. /**
  96695. * 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)
  96696. * @param uniformName Name of the variable.
  96697. * @param array array to be set.
  96698. * @returns this effect.
  96699. */
  96700. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96701. /**
  96702. * Sets an float array on a uniform variable.
  96703. * @param uniformName Name of the variable.
  96704. * @param array array to be set.
  96705. * @returns this effect.
  96706. */
  96707. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96708. /**
  96709. * 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)
  96710. * @param uniformName Name of the variable.
  96711. * @param array array to be set.
  96712. * @returns this effect.
  96713. */
  96714. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96715. /**
  96716. * 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)
  96717. * @param uniformName Name of the variable.
  96718. * @param array array to be set.
  96719. * @returns this effect.
  96720. */
  96721. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96722. /**
  96723. * 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)
  96724. * @param uniformName Name of the variable.
  96725. * @param array array to be set.
  96726. * @returns this effect.
  96727. */
  96728. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96729. /**
  96730. * Sets an array on a uniform variable.
  96731. * @param uniformName Name of the variable.
  96732. * @param array array to be set.
  96733. * @returns this effect.
  96734. */
  96735. setArray(uniformName: string, array: number[]): Effect;
  96736. /**
  96737. * 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)
  96738. * @param uniformName Name of the variable.
  96739. * @param array array to be set.
  96740. * @returns this effect.
  96741. */
  96742. setArray2(uniformName: string, array: number[]): Effect;
  96743. /**
  96744. * 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)
  96745. * @param uniformName Name of the variable.
  96746. * @param array array to be set.
  96747. * @returns this effect.
  96748. */
  96749. setArray3(uniformName: string, array: number[]): Effect;
  96750. /**
  96751. * 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)
  96752. * @param uniformName Name of the variable.
  96753. * @param array array to be set.
  96754. * @returns this effect.
  96755. */
  96756. setArray4(uniformName: string, array: number[]): Effect;
  96757. /**
  96758. * Sets matrices on a uniform variable.
  96759. * @param uniformName Name of the variable.
  96760. * @param matrices matrices to be set.
  96761. * @returns this effect.
  96762. */
  96763. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  96764. /**
  96765. * Sets matrix on a uniform variable.
  96766. * @param uniformName Name of the variable.
  96767. * @param matrix matrix to be set.
  96768. * @returns this effect.
  96769. */
  96770. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  96771. /**
  96772. * 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)
  96773. * @param uniformName Name of the variable.
  96774. * @param matrix matrix to be set.
  96775. * @returns this effect.
  96776. */
  96777. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  96778. /**
  96779. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  96780. * @param uniformName Name of the variable.
  96781. * @param matrix matrix to be set.
  96782. * @returns this effect.
  96783. */
  96784. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  96785. /**
  96786. * Sets a float on a uniform variable.
  96787. * @param uniformName Name of the variable.
  96788. * @param value value to be set.
  96789. * @returns this effect.
  96790. */
  96791. setFloat(uniformName: string, value: number): Effect;
  96792. /**
  96793. * Sets a boolean on a uniform variable.
  96794. * @param uniformName Name of the variable.
  96795. * @param bool value to be set.
  96796. * @returns this effect.
  96797. */
  96798. setBool(uniformName: string, bool: boolean): Effect;
  96799. /**
  96800. * Sets a Vector2 on a uniform variable.
  96801. * @param uniformName Name of the variable.
  96802. * @param vector2 vector2 to be set.
  96803. * @returns this effect.
  96804. */
  96805. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  96806. /**
  96807. * Sets a float2 on a uniform variable.
  96808. * @param uniformName Name of the variable.
  96809. * @param x First float in float2.
  96810. * @param y Second float in float2.
  96811. * @returns this effect.
  96812. */
  96813. setFloat2(uniformName: string, x: number, y: number): Effect;
  96814. /**
  96815. * Sets a Vector3 on a uniform variable.
  96816. * @param uniformName Name of the variable.
  96817. * @param vector3 Value to be set.
  96818. * @returns this effect.
  96819. */
  96820. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  96821. /**
  96822. * Sets a float3 on a uniform variable.
  96823. * @param uniformName Name of the variable.
  96824. * @param x First float in float3.
  96825. * @param y Second float in float3.
  96826. * @param z Third float in float3.
  96827. * @returns this effect.
  96828. */
  96829. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  96830. /**
  96831. * Sets a Vector4 on a uniform variable.
  96832. * @param uniformName Name of the variable.
  96833. * @param vector4 Value to be set.
  96834. * @returns this effect.
  96835. */
  96836. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  96837. /**
  96838. * Sets a float4 on a uniform variable.
  96839. * @param uniformName Name of the variable.
  96840. * @param x First float in float4.
  96841. * @param y Second float in float4.
  96842. * @param z Third float in float4.
  96843. * @param w Fourth float in float4.
  96844. * @returns this effect.
  96845. */
  96846. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  96847. /**
  96848. * Sets a Color3 on a uniform variable.
  96849. * @param uniformName Name of the variable.
  96850. * @param color3 Value to be set.
  96851. * @returns this effect.
  96852. */
  96853. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96854. /**
  96855. * Sets a Color4 on a uniform variable.
  96856. * @param uniformName Name of the variable.
  96857. * @param color3 Value to be set.
  96858. * @param alpha Alpha value to be set.
  96859. * @returns this effect.
  96860. */
  96861. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96862. /**
  96863. * Sets a Color4 on a uniform variable
  96864. * @param uniformName defines the name of the variable
  96865. * @param color4 defines the value to be set
  96866. * @returns this effect.
  96867. */
  96868. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96869. /** Release all associated resources */
  96870. dispose(): void;
  96871. /**
  96872. * This function will add a new shader to the shader store
  96873. * @param name the name of the shader
  96874. * @param pixelShader optional pixel shader content
  96875. * @param vertexShader optional vertex shader content
  96876. */
  96877. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96878. /**
  96879. * Store of each shader (The can be looked up using effect.key)
  96880. */
  96881. static ShadersStore: {
  96882. [key: string]: string;
  96883. };
  96884. /**
  96885. * Store of each included file for a shader (The can be looked up using effect.key)
  96886. */
  96887. static IncludesShadersStore: {
  96888. [key: string]: string;
  96889. };
  96890. /**
  96891. * Resets the cache of effects.
  96892. */
  96893. static ResetCache(): void;
  96894. }
  96895. }
  96896. declare module BABYLON {
  96897. /**
  96898. * Interface used to describe the capabilities of the engine relatively to the current browser
  96899. */
  96900. export interface EngineCapabilities {
  96901. /** Maximum textures units per fragment shader */
  96902. maxTexturesImageUnits: number;
  96903. /** Maximum texture units per vertex shader */
  96904. maxVertexTextureImageUnits: number;
  96905. /** Maximum textures units in the entire pipeline */
  96906. maxCombinedTexturesImageUnits: number;
  96907. /** Maximum texture size */
  96908. maxTextureSize: number;
  96909. /** Maximum cube texture size */
  96910. maxCubemapTextureSize: number;
  96911. /** Maximum render texture size */
  96912. maxRenderTextureSize: number;
  96913. /** Maximum number of vertex attributes */
  96914. maxVertexAttribs: number;
  96915. /** Maximum number of varyings */
  96916. maxVaryingVectors: number;
  96917. /** Maximum number of uniforms per vertex shader */
  96918. maxVertexUniformVectors: number;
  96919. /** Maximum number of uniforms per fragment shader */
  96920. maxFragmentUniformVectors: number;
  96921. /** Defines if standard derivates (dx/dy) are supported */
  96922. standardDerivatives: boolean;
  96923. /** Defines if s3tc texture compression is supported */
  96924. s3tc?: WEBGL_compressed_texture_s3tc;
  96925. /** Defines if pvrtc texture compression is supported */
  96926. pvrtc: any;
  96927. /** Defines if etc1 texture compression is supported */
  96928. etc1: any;
  96929. /** Defines if etc2 texture compression is supported */
  96930. etc2: any;
  96931. /** Defines if astc texture compression is supported */
  96932. astc: any;
  96933. /** Defines if float textures are supported */
  96934. textureFloat: boolean;
  96935. /** Defines if vertex array objects are supported */
  96936. vertexArrayObject: boolean;
  96937. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96938. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  96939. /** Gets the maximum level of anisotropy supported */
  96940. maxAnisotropy: number;
  96941. /** Defines if instancing is supported */
  96942. instancedArrays: boolean;
  96943. /** Defines if 32 bits indices are supported */
  96944. uintIndices: boolean;
  96945. /** Defines if high precision shaders are supported */
  96946. highPrecisionShaderSupported: boolean;
  96947. /** Defines if depth reading in the fragment shader is supported */
  96948. fragmentDepthSupported: boolean;
  96949. /** Defines if float texture linear filtering is supported*/
  96950. textureFloatLinearFiltering: boolean;
  96951. /** Defines if rendering to float textures is supported */
  96952. textureFloatRender: boolean;
  96953. /** Defines if half float textures are supported*/
  96954. textureHalfFloat: boolean;
  96955. /** Defines if half float texture linear filtering is supported*/
  96956. textureHalfFloatLinearFiltering: boolean;
  96957. /** Defines if rendering to half float textures is supported */
  96958. textureHalfFloatRender: boolean;
  96959. /** Defines if textureLOD shader command is supported */
  96960. textureLOD: boolean;
  96961. /** Defines if draw buffers extension is supported */
  96962. drawBuffersExtension: boolean;
  96963. /** Defines if depth textures are supported */
  96964. depthTextureExtension: boolean;
  96965. /** Defines if float color buffer are supported */
  96966. colorBufferFloat: boolean;
  96967. /** Gets disjoint timer query extension (null if not supported) */
  96968. timerQuery?: EXT_disjoint_timer_query;
  96969. /** Defines if timestamp can be used with timer query */
  96970. canUseTimestampForTimerQuery: boolean;
  96971. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96972. multiview?: any;
  96973. /** Function used to let the system compiles shaders in background */
  96974. parallelShaderCompile?: {
  96975. COMPLETION_STATUS_KHR: number;
  96976. };
  96977. /** Max number of texture samples for MSAA */
  96978. maxMSAASamples: number;
  96979. /** Defines if the blend min max extension is supported */
  96980. blendMinMax: boolean;
  96981. }
  96982. }
  96983. declare module BABYLON {
  96984. /**
  96985. * @hidden
  96986. **/
  96987. export class DepthCullingState {
  96988. private _isDepthTestDirty;
  96989. private _isDepthMaskDirty;
  96990. private _isDepthFuncDirty;
  96991. private _isCullFaceDirty;
  96992. private _isCullDirty;
  96993. private _isZOffsetDirty;
  96994. private _isFrontFaceDirty;
  96995. private _depthTest;
  96996. private _depthMask;
  96997. private _depthFunc;
  96998. private _cull;
  96999. private _cullFace;
  97000. private _zOffset;
  97001. private _frontFace;
  97002. /**
  97003. * Initializes the state.
  97004. */
  97005. constructor();
  97006. readonly isDirty: boolean;
  97007. zOffset: number;
  97008. cullFace: Nullable<number>;
  97009. cull: Nullable<boolean>;
  97010. depthFunc: Nullable<number>;
  97011. depthMask: boolean;
  97012. depthTest: boolean;
  97013. frontFace: Nullable<number>;
  97014. reset(): void;
  97015. apply(gl: WebGLRenderingContext): void;
  97016. }
  97017. }
  97018. declare module BABYLON {
  97019. /**
  97020. * @hidden
  97021. **/
  97022. export class StencilState {
  97023. /** 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 */
  97024. static readonly ALWAYS: number;
  97025. /** Passed to stencilOperation to specify that stencil value must be kept */
  97026. static readonly KEEP: number;
  97027. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97028. static readonly REPLACE: number;
  97029. private _isStencilTestDirty;
  97030. private _isStencilMaskDirty;
  97031. private _isStencilFuncDirty;
  97032. private _isStencilOpDirty;
  97033. private _stencilTest;
  97034. private _stencilMask;
  97035. private _stencilFunc;
  97036. private _stencilFuncRef;
  97037. private _stencilFuncMask;
  97038. private _stencilOpStencilFail;
  97039. private _stencilOpDepthFail;
  97040. private _stencilOpStencilDepthPass;
  97041. readonly isDirty: boolean;
  97042. stencilFunc: number;
  97043. stencilFuncRef: number;
  97044. stencilFuncMask: number;
  97045. stencilOpStencilFail: number;
  97046. stencilOpDepthFail: number;
  97047. stencilOpStencilDepthPass: number;
  97048. stencilMask: number;
  97049. stencilTest: boolean;
  97050. constructor();
  97051. reset(): void;
  97052. apply(gl: WebGLRenderingContext): void;
  97053. }
  97054. }
  97055. declare module BABYLON {
  97056. /**
  97057. * @hidden
  97058. **/
  97059. export class AlphaState {
  97060. private _isAlphaBlendDirty;
  97061. private _isBlendFunctionParametersDirty;
  97062. private _isBlendEquationParametersDirty;
  97063. private _isBlendConstantsDirty;
  97064. private _alphaBlend;
  97065. private _blendFunctionParameters;
  97066. private _blendEquationParameters;
  97067. private _blendConstants;
  97068. /**
  97069. * Initializes the state.
  97070. */
  97071. constructor();
  97072. readonly isDirty: boolean;
  97073. alphaBlend: boolean;
  97074. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97075. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97076. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97077. reset(): void;
  97078. apply(gl: WebGLRenderingContext): void;
  97079. }
  97080. }
  97081. declare module BABYLON {
  97082. /** @hidden */
  97083. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97084. attributeProcessor(attribute: string): string;
  97085. varyingProcessor(varying: string, isFragment: boolean): string;
  97086. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97087. }
  97088. }
  97089. declare module BABYLON {
  97090. /**
  97091. * Interface for attribute information associated with buffer instanciation
  97092. */
  97093. export interface InstancingAttributeInfo {
  97094. /**
  97095. * Index/offset of the attribute in the vertex shader
  97096. */
  97097. index: number;
  97098. /**
  97099. * size of the attribute, 1, 2, 3 or 4
  97100. */
  97101. attributeSize: number;
  97102. /**
  97103. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97104. * default is FLOAT
  97105. */
  97106. attributeType: number;
  97107. /**
  97108. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97109. */
  97110. normalized: boolean;
  97111. /**
  97112. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97113. */
  97114. offset: number;
  97115. /**
  97116. * Name of the GLSL attribute, for debugging purpose only
  97117. */
  97118. attributeName: string;
  97119. }
  97120. }
  97121. declare module BABYLON {
  97122. interface ThinEngine {
  97123. /**
  97124. * Update a video texture
  97125. * @param texture defines the texture to update
  97126. * @param video defines the video element to use
  97127. * @param invertY defines if data must be stored with Y axis inverted
  97128. */
  97129. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97130. }
  97131. }
  97132. declare module BABYLON {
  97133. /**
  97134. * Settings for finer control over video usage
  97135. */
  97136. export interface VideoTextureSettings {
  97137. /**
  97138. * Applies `autoplay` to video, if specified
  97139. */
  97140. autoPlay?: boolean;
  97141. /**
  97142. * Applies `loop` to video, if specified
  97143. */
  97144. loop?: boolean;
  97145. /**
  97146. * Automatically updates internal texture from video at every frame in the render loop
  97147. */
  97148. autoUpdateTexture: boolean;
  97149. /**
  97150. * Image src displayed during the video loading or until the user interacts with the video.
  97151. */
  97152. poster?: string;
  97153. }
  97154. /**
  97155. * If you want to display a video in your scene, this is the special texture for that.
  97156. * This special texture works similar to other textures, with the exception of a few parameters.
  97157. * @see https://doc.babylonjs.com/how_to/video_texture
  97158. */
  97159. export class VideoTexture extends Texture {
  97160. /**
  97161. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97162. */
  97163. readonly autoUpdateTexture: boolean;
  97164. /**
  97165. * The video instance used by the texture internally
  97166. */
  97167. readonly video: HTMLVideoElement;
  97168. private _onUserActionRequestedObservable;
  97169. /**
  97170. * Event triggerd when a dom action is required by the user to play the video.
  97171. * This happens due to recent changes in browser policies preventing video to auto start.
  97172. */
  97173. readonly onUserActionRequestedObservable: Observable<Texture>;
  97174. private _generateMipMaps;
  97175. private _engine;
  97176. private _stillImageCaptured;
  97177. private _displayingPosterTexture;
  97178. private _settings;
  97179. private _createInternalTextureOnEvent;
  97180. private _frameId;
  97181. /**
  97182. * Creates a video texture.
  97183. * If you want to display a video in your scene, this is the special texture for that.
  97184. * This special texture works similar to other textures, with the exception of a few parameters.
  97185. * @see https://doc.babylonjs.com/how_to/video_texture
  97186. * @param name optional name, will detect from video source, if not defined
  97187. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97188. * @param scene is obviously the current scene.
  97189. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97190. * @param invertY is false by default but can be used to invert video on Y axis
  97191. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97192. * @param settings allows finer control over video usage
  97193. */
  97194. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97195. private _getName;
  97196. private _getVideo;
  97197. private _createInternalTexture;
  97198. private reset;
  97199. /**
  97200. * @hidden Internal method to initiate `update`.
  97201. */
  97202. _rebuild(): void;
  97203. /**
  97204. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97205. */
  97206. update(): void;
  97207. /**
  97208. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97209. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97210. */
  97211. updateTexture(isVisible: boolean): void;
  97212. protected _updateInternalTexture: () => void;
  97213. /**
  97214. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97215. * @param url New url.
  97216. */
  97217. updateURL(url: string): void;
  97218. /**
  97219. * Dispose the texture and release its associated resources.
  97220. */
  97221. dispose(): void;
  97222. /**
  97223. * Creates a video texture straight from a stream.
  97224. * @param scene Define the scene the texture should be created in
  97225. * @param stream Define the stream the texture should be created from
  97226. * @returns The created video texture as a promise
  97227. */
  97228. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97229. /**
  97230. * Creates a video texture straight from your WebCam video feed.
  97231. * @param scene Define the scene the texture should be created in
  97232. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97233. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97234. * @returns The created video texture as a promise
  97235. */
  97236. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97237. minWidth: number;
  97238. maxWidth: number;
  97239. minHeight: number;
  97240. maxHeight: number;
  97241. deviceId: string;
  97242. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97243. /**
  97244. * Creates a video texture straight from your WebCam video feed.
  97245. * @param scene Define the scene the texture should be created in
  97246. * @param onReady Define a callback to triggered once the texture will be ready
  97247. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97248. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97249. */
  97250. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97251. minWidth: number;
  97252. maxWidth: number;
  97253. minHeight: number;
  97254. maxHeight: number;
  97255. deviceId: string;
  97256. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97257. }
  97258. }
  97259. declare module BABYLON {
  97260. /**
  97261. * Defines the interface used by objects working like Scene
  97262. * @hidden
  97263. */
  97264. interface ISceneLike {
  97265. _addPendingData(data: any): void;
  97266. _removePendingData(data: any): void;
  97267. offlineProvider: IOfflineProvider;
  97268. }
  97269. /** Interface defining initialization parameters for Engine class */
  97270. export interface EngineOptions extends WebGLContextAttributes {
  97271. /**
  97272. * Defines if the engine should no exceed a specified device ratio
  97273. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97274. */
  97275. limitDeviceRatio?: number;
  97276. /**
  97277. * Defines if webvr should be enabled automatically
  97278. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97279. */
  97280. autoEnableWebVR?: boolean;
  97281. /**
  97282. * Defines if webgl2 should be turned off even if supported
  97283. * @see http://doc.babylonjs.com/features/webgl2
  97284. */
  97285. disableWebGL2Support?: boolean;
  97286. /**
  97287. * Defines if webaudio should be initialized as well
  97288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97289. */
  97290. audioEngine?: boolean;
  97291. /**
  97292. * Defines if animations should run using a deterministic lock step
  97293. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97294. */
  97295. deterministicLockstep?: boolean;
  97296. /** Defines the maximum steps to use with deterministic lock step mode */
  97297. lockstepMaxSteps?: number;
  97298. /**
  97299. * Defines that engine should ignore context lost events
  97300. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97301. */
  97302. doNotHandleContextLost?: boolean;
  97303. /**
  97304. * Defines that engine should ignore modifying touch action attribute and style
  97305. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97306. */
  97307. doNotHandleTouchAction?: boolean;
  97308. /**
  97309. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97310. */
  97311. useHighPrecisionFloats?: boolean;
  97312. }
  97313. /**
  97314. * The base engine class (root of all engines)
  97315. */
  97316. export class ThinEngine {
  97317. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97318. static ExceptionList: ({
  97319. key: string;
  97320. capture: string;
  97321. captureConstraint: number;
  97322. targets: string[];
  97323. } | {
  97324. key: string;
  97325. capture: null;
  97326. captureConstraint: null;
  97327. targets: string[];
  97328. })[];
  97329. /** @hidden */
  97330. static _TextureLoaders: IInternalTextureLoader[];
  97331. /**
  97332. * Returns the current npm package of the sdk
  97333. */
  97334. static readonly NpmPackage: string;
  97335. /**
  97336. * Returns the current version of the framework
  97337. */
  97338. static readonly Version: string;
  97339. /**
  97340. * Returns a string describing the current engine
  97341. */
  97342. readonly description: string;
  97343. /**
  97344. * Gets or sets the epsilon value used by collision engine
  97345. */
  97346. static CollisionsEpsilon: number;
  97347. /**
  97348. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97349. */
  97350. static ShadersRepository: string;
  97351. /** @hidden */
  97352. _shaderProcessor: IShaderProcessor;
  97353. /**
  97354. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97355. */
  97356. forcePOTTextures: boolean;
  97357. /**
  97358. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97359. */
  97360. isFullscreen: boolean;
  97361. /**
  97362. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97363. */
  97364. cullBackFaces: boolean;
  97365. /**
  97366. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97367. */
  97368. renderEvenInBackground: boolean;
  97369. /**
  97370. * Gets or sets a boolean indicating that cache can be kept between frames
  97371. */
  97372. preventCacheWipeBetweenFrames: boolean;
  97373. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97374. validateShaderPrograms: boolean;
  97375. /**
  97376. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97377. */
  97378. disableUniformBuffers: boolean;
  97379. /** @hidden */
  97380. _uniformBuffers: UniformBuffer[];
  97381. /**
  97382. * Gets a boolean indicating that the engine supports uniform buffers
  97383. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97384. */
  97385. readonly supportsUniformBuffers: boolean;
  97386. /** @hidden */
  97387. _gl: WebGLRenderingContext;
  97388. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97389. protected _windowIsBackground: boolean;
  97390. protected _webGLVersion: number;
  97391. protected _creationOptions: EngineOptions;
  97392. protected _highPrecisionShadersAllowed: boolean;
  97393. /** @hidden */
  97394. readonly _shouldUseHighPrecisionShader: boolean;
  97395. /**
  97396. * Gets a boolean indicating that only power of 2 textures are supported
  97397. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97398. */
  97399. readonly needPOTTextures: boolean;
  97400. /** @hidden */
  97401. _badOS: boolean;
  97402. /** @hidden */
  97403. _badDesktopOS: boolean;
  97404. private _hardwareScalingLevel;
  97405. /** @hidden */
  97406. _caps: EngineCapabilities;
  97407. private _isStencilEnable;
  97408. protected _colorWrite: boolean;
  97409. private _glVersion;
  97410. private _glRenderer;
  97411. private _glVendor;
  97412. /** @hidden */
  97413. _videoTextureSupported: boolean;
  97414. protected _renderingQueueLaunched: boolean;
  97415. protected _activeRenderLoops: (() => void)[];
  97416. /**
  97417. * Observable signaled when a context lost event is raised
  97418. */
  97419. onContextLostObservable: Observable<ThinEngine>;
  97420. /**
  97421. * Observable signaled when a context restored event is raised
  97422. */
  97423. onContextRestoredObservable: Observable<ThinEngine>;
  97424. private _onContextLost;
  97425. private _onContextRestored;
  97426. protected _contextWasLost: boolean;
  97427. /** @hidden */
  97428. _doNotHandleContextLost: boolean;
  97429. /**
  97430. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97432. */
  97433. doNotHandleContextLost: boolean;
  97434. /**
  97435. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97436. */
  97437. disableVertexArrayObjects: boolean;
  97438. /** @hidden */
  97439. protected _depthCullingState: DepthCullingState;
  97440. /** @hidden */
  97441. protected _stencilState: StencilState;
  97442. /** @hidden */
  97443. protected _alphaState: AlphaState;
  97444. /** @hidden */
  97445. _internalTexturesCache: InternalTexture[];
  97446. /** @hidden */
  97447. protected _activeChannel: number;
  97448. private _currentTextureChannel;
  97449. /** @hidden */
  97450. protected _boundTexturesCache: {
  97451. [key: string]: Nullable<InternalTexture>;
  97452. };
  97453. /** @hidden */
  97454. protected _currentEffect: Nullable<Effect>;
  97455. /** @hidden */
  97456. protected _currentProgram: Nullable<WebGLProgram>;
  97457. private _compiledEffects;
  97458. private _vertexAttribArraysEnabled;
  97459. /** @hidden */
  97460. protected _cachedViewport: Nullable<IViewportLike>;
  97461. private _cachedVertexArrayObject;
  97462. /** @hidden */
  97463. protected _cachedVertexBuffers: any;
  97464. /** @hidden */
  97465. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97466. /** @hidden */
  97467. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97468. /** @hidden */
  97469. _currentRenderTarget: Nullable<InternalTexture>;
  97470. private _uintIndicesCurrentlySet;
  97471. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97472. /** @hidden */
  97473. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97474. private _currentBufferPointers;
  97475. private _currentInstanceLocations;
  97476. private _currentInstanceBuffers;
  97477. private _textureUnits;
  97478. /** @hidden */
  97479. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97480. /** @hidden */
  97481. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97482. /** @hidden */
  97483. _boundRenderFunction: any;
  97484. private _vaoRecordInProgress;
  97485. private _mustWipeVertexAttributes;
  97486. private _emptyTexture;
  97487. private _emptyCubeTexture;
  97488. private _emptyTexture3D;
  97489. private _emptyTexture2DArray;
  97490. /** @hidden */
  97491. _frameHandler: number;
  97492. private _nextFreeTextureSlots;
  97493. private _maxSimultaneousTextures;
  97494. private _activeRequests;
  97495. protected _texturesSupported: string[];
  97496. /** @hidden */
  97497. _textureFormatInUse: Nullable<string>;
  97498. protected readonly _supportsHardwareTextureRescaling: boolean;
  97499. /**
  97500. * Gets the list of texture formats supported
  97501. */
  97502. readonly texturesSupported: Array<string>;
  97503. /**
  97504. * Gets the list of texture formats in use
  97505. */
  97506. readonly textureFormatInUse: Nullable<string>;
  97507. /**
  97508. * Gets the current viewport
  97509. */
  97510. readonly currentViewport: Nullable<IViewportLike>;
  97511. /**
  97512. * Gets the default empty texture
  97513. */
  97514. readonly emptyTexture: InternalTexture;
  97515. /**
  97516. * Gets the default empty 3D texture
  97517. */
  97518. readonly emptyTexture3D: InternalTexture;
  97519. /**
  97520. * Gets the default empty 2D array texture
  97521. */
  97522. readonly emptyTexture2DArray: InternalTexture;
  97523. /**
  97524. * Gets the default empty cube texture
  97525. */
  97526. readonly emptyCubeTexture: InternalTexture;
  97527. /**
  97528. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97529. */
  97530. readonly premultipliedAlpha: boolean;
  97531. /**
  97532. * Observable event triggered before each texture is initialized
  97533. */
  97534. onBeforeTextureInitObservable: Observable<Texture>;
  97535. /**
  97536. * Creates a new engine
  97537. * @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
  97538. * @param antialias defines enable antialiasing (default: false)
  97539. * @param options defines further options to be sent to the getContext() function
  97540. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97541. */
  97542. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97543. private _rebuildInternalTextures;
  97544. private _rebuildEffects;
  97545. /**
  97546. * Gets a boolean indicating if all created effects are ready
  97547. * @returns true if all effects are ready
  97548. */
  97549. areAllEffectsReady(): boolean;
  97550. protected _rebuildBuffers(): void;
  97551. private _initGLContext;
  97552. /**
  97553. * Gets version of the current webGL context
  97554. */
  97555. readonly webGLVersion: number;
  97556. /**
  97557. * Gets a string idenfifying the name of the class
  97558. * @returns "Engine" string
  97559. */
  97560. getClassName(): string;
  97561. /**
  97562. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97563. */
  97564. readonly isStencilEnable: boolean;
  97565. /** @hidden */
  97566. _prepareWorkingCanvas(): void;
  97567. /**
  97568. * Reset the texture cache to empty state
  97569. */
  97570. resetTextureCache(): void;
  97571. /**
  97572. * Gets an object containing information about the current webGL context
  97573. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97574. */
  97575. getGlInfo(): {
  97576. vendor: string;
  97577. renderer: string;
  97578. version: string;
  97579. };
  97580. /**
  97581. * Defines the hardware scaling level.
  97582. * By default the hardware scaling level is computed from the window device ratio.
  97583. * 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.
  97584. * @param level defines the level to use
  97585. */
  97586. setHardwareScalingLevel(level: number): void;
  97587. /**
  97588. * Gets the current hardware scaling level.
  97589. * By default the hardware scaling level is computed from the window device ratio.
  97590. * 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.
  97591. * @returns a number indicating the current hardware scaling level
  97592. */
  97593. getHardwareScalingLevel(): number;
  97594. /**
  97595. * Gets the list of loaded textures
  97596. * @returns an array containing all loaded textures
  97597. */
  97598. getLoadedTexturesCache(): InternalTexture[];
  97599. /**
  97600. * Gets the object containing all engine capabilities
  97601. * @returns the EngineCapabilities object
  97602. */
  97603. getCaps(): EngineCapabilities;
  97604. /**
  97605. * stop executing a render loop function and remove it from the execution array
  97606. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97607. */
  97608. stopRenderLoop(renderFunction?: () => void): void;
  97609. /** @hidden */
  97610. _renderLoop(): void;
  97611. /**
  97612. * Gets the HTML canvas attached with the current webGL context
  97613. * @returns a HTML canvas
  97614. */
  97615. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97616. /**
  97617. * Gets host window
  97618. * @returns the host window object
  97619. */
  97620. getHostWindow(): Nullable<Window>;
  97621. /**
  97622. * Gets the current render width
  97623. * @param useScreen defines if screen size must be used (or the current render target if any)
  97624. * @returns a number defining the current render width
  97625. */
  97626. getRenderWidth(useScreen?: boolean): number;
  97627. /**
  97628. * Gets the current render height
  97629. * @param useScreen defines if screen size must be used (or the current render target if any)
  97630. * @returns a number defining the current render height
  97631. */
  97632. getRenderHeight(useScreen?: boolean): number;
  97633. /**
  97634. * Can be used to override the current requestAnimationFrame requester.
  97635. * @hidden
  97636. */
  97637. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97638. /**
  97639. * Register and execute a render loop. The engine can have more than one render function
  97640. * @param renderFunction defines the function to continuously execute
  97641. */
  97642. runRenderLoop(renderFunction: () => void): void;
  97643. /**
  97644. * Clear the current render buffer or the current render target (if any is set up)
  97645. * @param color defines the color to use
  97646. * @param backBuffer defines if the back buffer must be cleared
  97647. * @param depth defines if the depth buffer must be cleared
  97648. * @param stencil defines if the stencil buffer must be cleared
  97649. */
  97650. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97651. private _viewportCached;
  97652. /** @hidden */
  97653. _viewport(x: number, y: number, width: number, height: number): void;
  97654. /**
  97655. * Set the WebGL's viewport
  97656. * @param viewport defines the viewport element to be used
  97657. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97658. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97659. */
  97660. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97661. /**
  97662. * Begin a new frame
  97663. */
  97664. beginFrame(): void;
  97665. /**
  97666. * Enf the current frame
  97667. */
  97668. endFrame(): void;
  97669. /**
  97670. * Resize the view according to the canvas' size
  97671. */
  97672. resize(): void;
  97673. /**
  97674. * Force a specific size of the canvas
  97675. * @param width defines the new canvas' width
  97676. * @param height defines the new canvas' height
  97677. */
  97678. setSize(width: number, height: number): void;
  97679. /**
  97680. * Binds the frame buffer to the specified texture.
  97681. * @param texture The texture to render to or null for the default canvas
  97682. * @param faceIndex The face of the texture to render to in case of cube texture
  97683. * @param requiredWidth The width of the target to render to
  97684. * @param requiredHeight The height of the target to render to
  97685. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97686. * @param depthStencilTexture The depth stencil texture to use to render
  97687. * @param lodLevel defines le lod level to bind to the frame buffer
  97688. */
  97689. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97690. /** @hidden */
  97691. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97692. /**
  97693. * Unbind the current render target texture from the webGL context
  97694. * @param texture defines the render target texture to unbind
  97695. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97696. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97697. */
  97698. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97699. /**
  97700. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97701. */
  97702. flushFramebuffer(): void;
  97703. /**
  97704. * Unbind the current render target and bind the default framebuffer
  97705. */
  97706. restoreDefaultFramebuffer(): void;
  97707. /** @hidden */
  97708. protected _resetVertexBufferBinding(): void;
  97709. /**
  97710. * Creates a vertex buffer
  97711. * @param data the data for the vertex buffer
  97712. * @returns the new WebGL static buffer
  97713. */
  97714. createVertexBuffer(data: DataArray): DataBuffer;
  97715. private _createVertexBuffer;
  97716. /**
  97717. * Creates a dynamic vertex buffer
  97718. * @param data the data for the dynamic vertex buffer
  97719. * @returns the new WebGL dynamic buffer
  97720. */
  97721. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97722. protected _resetIndexBufferBinding(): void;
  97723. /**
  97724. * Creates a new index buffer
  97725. * @param indices defines the content of the index buffer
  97726. * @param updatable defines if the index buffer must be updatable
  97727. * @returns a new webGL buffer
  97728. */
  97729. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97730. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97731. /**
  97732. * Bind a webGL buffer to the webGL context
  97733. * @param buffer defines the buffer to bind
  97734. */
  97735. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97736. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97737. private bindBuffer;
  97738. /**
  97739. * update the bound buffer with the given data
  97740. * @param data defines the data to update
  97741. */
  97742. updateArrayBuffer(data: Float32Array): void;
  97743. private _vertexAttribPointer;
  97744. private _bindIndexBufferWithCache;
  97745. private _bindVertexBuffersAttributes;
  97746. /**
  97747. * Records a vertex array object
  97748. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97749. * @param vertexBuffers defines the list of vertex buffers to store
  97750. * @param indexBuffer defines the index buffer to store
  97751. * @param effect defines the effect to store
  97752. * @returns the new vertex array object
  97753. */
  97754. recordVertexArrayObject(vertexBuffers: {
  97755. [key: string]: VertexBuffer;
  97756. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97757. /**
  97758. * Bind a specific vertex array object
  97759. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97760. * @param vertexArrayObject defines the vertex array object to bind
  97761. * @param indexBuffer defines the index buffer to bind
  97762. */
  97763. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  97764. /**
  97765. * Bind webGl buffers directly to the webGL context
  97766. * @param vertexBuffer defines the vertex buffer to bind
  97767. * @param indexBuffer defines the index buffer to bind
  97768. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  97769. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  97770. * @param effect defines the effect associated with the vertex buffer
  97771. */
  97772. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  97773. private _unbindVertexArrayObject;
  97774. /**
  97775. * Bind a list of vertex buffers to the webGL context
  97776. * @param vertexBuffers defines the list of vertex buffers to bind
  97777. * @param indexBuffer defines the index buffer to bind
  97778. * @param effect defines the effect associated with the vertex buffers
  97779. */
  97780. bindBuffers(vertexBuffers: {
  97781. [key: string]: Nullable<VertexBuffer>;
  97782. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  97783. /**
  97784. * Unbind all instance attributes
  97785. */
  97786. unbindInstanceAttributes(): void;
  97787. /**
  97788. * Release and free the memory of a vertex array object
  97789. * @param vao defines the vertex array object to delete
  97790. */
  97791. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  97792. /** @hidden */
  97793. _releaseBuffer(buffer: DataBuffer): boolean;
  97794. protected _deleteBuffer(buffer: DataBuffer): void;
  97795. /**
  97796. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  97797. * @param instancesBuffer defines the webGL buffer to update and bind
  97798. * @param data defines the data to store in the buffer
  97799. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  97800. */
  97801. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  97802. /**
  97803. * Apply all cached states (depth, culling, stencil and alpha)
  97804. */
  97805. applyStates(): void;
  97806. /**
  97807. * Send a draw order
  97808. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97809. * @param indexStart defines the starting index
  97810. * @param indexCount defines the number of index to draw
  97811. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97812. */
  97813. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97814. /**
  97815. * Draw a list of points
  97816. * @param verticesStart defines the index of first vertex to draw
  97817. * @param verticesCount defines the count of vertices to draw
  97818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97819. */
  97820. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97821. /**
  97822. * Draw a list of unindexed primitives
  97823. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97824. * @param verticesStart defines the index of first vertex to draw
  97825. * @param verticesCount defines the count of vertices to draw
  97826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97827. */
  97828. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97829. /**
  97830. * Draw a list of indexed primitives
  97831. * @param fillMode defines the primitive to use
  97832. * @param indexStart defines the starting index
  97833. * @param indexCount defines the number of index to draw
  97834. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97835. */
  97836. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97837. /**
  97838. * Draw a list of unindexed primitives
  97839. * @param fillMode defines the primitive to use
  97840. * @param verticesStart defines the index of first vertex to draw
  97841. * @param verticesCount defines the count of vertices to draw
  97842. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97843. */
  97844. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97845. private _drawMode;
  97846. /** @hidden */
  97847. protected _reportDrawCall(): void;
  97848. /** @hidden */
  97849. _releaseEffect(effect: Effect): void;
  97850. /** @hidden */
  97851. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97852. /**
  97853. * Create a new effect (used to store vertex/fragment shaders)
  97854. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97855. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97856. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97857. * @param samplers defines an array of string used to represent textures
  97858. * @param defines defines the string containing the defines to use to compile the shaders
  97859. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97860. * @param onCompiled defines a function to call when the effect creation is successful
  97861. * @param onError defines a function to call when the effect creation has failed
  97862. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97863. * @returns the new Effect
  97864. */
  97865. 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;
  97866. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97867. private _compileShader;
  97868. private _compileRawShader;
  97869. /**
  97870. * Directly creates a webGL program
  97871. * @param pipelineContext defines the pipeline context to attach to
  97872. * @param vertexCode defines the vertex shader code to use
  97873. * @param fragmentCode defines the fragment shader code to use
  97874. * @param context defines the webGL context to use (if not set, the current one will be used)
  97875. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97876. * @returns the new webGL program
  97877. */
  97878. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97879. /**
  97880. * Creates a webGL program
  97881. * @param pipelineContext defines the pipeline context to attach to
  97882. * @param vertexCode defines the vertex shader code to use
  97883. * @param fragmentCode defines the fragment shader code to use
  97884. * @param defines defines the string containing the defines to use to compile the shaders
  97885. * @param context defines the webGL context to use (if not set, the current one will be used)
  97886. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97887. * @returns the new webGL program
  97888. */
  97889. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97890. /**
  97891. * Creates a new pipeline context
  97892. * @returns the new pipeline
  97893. */
  97894. createPipelineContext(): IPipelineContext;
  97895. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97896. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97897. /** @hidden */
  97898. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97899. /** @hidden */
  97900. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97901. /** @hidden */
  97902. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97903. /**
  97904. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97905. * @param pipelineContext defines the pipeline context to use
  97906. * @param uniformsNames defines the list of uniform names
  97907. * @returns an array of webGL uniform locations
  97908. */
  97909. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97910. /**
  97911. * Gets the lsit of active attributes for a given webGL program
  97912. * @param pipelineContext defines the pipeline context to use
  97913. * @param attributesNames defines the list of attribute names to get
  97914. * @returns an array of indices indicating the offset of each attribute
  97915. */
  97916. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97917. /**
  97918. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97919. * @param effect defines the effect to activate
  97920. */
  97921. enableEffect(effect: Nullable<Effect>): void;
  97922. /**
  97923. * Set the value of an uniform to a number (int)
  97924. * @param uniform defines the webGL uniform location where to store the value
  97925. * @param value defines the int number to store
  97926. */
  97927. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97928. /**
  97929. * Set the value of an uniform to an array of int32
  97930. * @param uniform defines the webGL uniform location where to store the value
  97931. * @param array defines the array of int32 to store
  97932. */
  97933. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97934. /**
  97935. * Set the value of an uniform to an array of int32 (stored as vec2)
  97936. * @param uniform defines the webGL uniform location where to store the value
  97937. * @param array defines the array of int32 to store
  97938. */
  97939. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97940. /**
  97941. * Set the value of an uniform to an array of int32 (stored as vec3)
  97942. * @param uniform defines the webGL uniform location where to store the value
  97943. * @param array defines the array of int32 to store
  97944. */
  97945. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97946. /**
  97947. * Set the value of an uniform to an array of int32 (stored as vec4)
  97948. * @param uniform defines the webGL uniform location where to store the value
  97949. * @param array defines the array of int32 to store
  97950. */
  97951. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97952. /**
  97953. * Set the value of an uniform to an array of number
  97954. * @param uniform defines the webGL uniform location where to store the value
  97955. * @param array defines the array of number to store
  97956. */
  97957. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97958. /**
  97959. * Set the value of an uniform to an array of number (stored as vec2)
  97960. * @param uniform defines the webGL uniform location where to store the value
  97961. * @param array defines the array of number to store
  97962. */
  97963. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97964. /**
  97965. * Set the value of an uniform to an array of number (stored as vec3)
  97966. * @param uniform defines the webGL uniform location where to store the value
  97967. * @param array defines the array of number to store
  97968. */
  97969. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97970. /**
  97971. * Set the value of an uniform to an array of number (stored as vec4)
  97972. * @param uniform defines the webGL uniform location where to store the value
  97973. * @param array defines the array of number to store
  97974. */
  97975. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97976. /**
  97977. * Set the value of an uniform to an array of float32 (stored as matrices)
  97978. * @param uniform defines the webGL uniform location where to store the value
  97979. * @param matrices defines the array of float32 to store
  97980. */
  97981. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97982. /**
  97983. * Set the value of an uniform to a matrix (3x3)
  97984. * @param uniform defines the webGL uniform location where to store the value
  97985. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97986. */
  97987. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97988. /**
  97989. * Set the value of an uniform to a matrix (2x2)
  97990. * @param uniform defines the webGL uniform location where to store the value
  97991. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97992. */
  97993. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97994. /**
  97995. * Set the value of an uniform to a number (float)
  97996. * @param uniform defines the webGL uniform location where to store the value
  97997. * @param value defines the float number to store
  97998. */
  97999. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98000. /**
  98001. * Set the value of an uniform to a vec2
  98002. * @param uniform defines the webGL uniform location where to store the value
  98003. * @param x defines the 1st component of the value
  98004. * @param y defines the 2nd component of the value
  98005. */
  98006. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98007. /**
  98008. * Set the value of an uniform to a vec3
  98009. * @param uniform defines the webGL uniform location where to store the value
  98010. * @param x defines the 1st component of the value
  98011. * @param y defines the 2nd component of the value
  98012. * @param z defines the 3rd component of the value
  98013. */
  98014. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98015. /**
  98016. * Set the value of an uniform to a vec4
  98017. * @param uniform defines the webGL uniform location where to store the value
  98018. * @param x defines the 1st component of the value
  98019. * @param y defines the 2nd component of the value
  98020. * @param z defines the 3rd component of the value
  98021. * @param w defines the 4th component of the value
  98022. */
  98023. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98024. /**
  98025. * Gets the depth culling state manager
  98026. */
  98027. readonly depthCullingState: DepthCullingState;
  98028. /**
  98029. * Gets the alpha state manager
  98030. */
  98031. readonly alphaState: AlphaState;
  98032. /**
  98033. * Gets the stencil state manager
  98034. */
  98035. readonly stencilState: StencilState;
  98036. /**
  98037. * Clears the list of texture accessible through engine.
  98038. * This can help preventing texture load conflict due to name collision.
  98039. */
  98040. clearInternalTexturesCache(): void;
  98041. /**
  98042. * Force the entire cache to be cleared
  98043. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98044. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98045. */
  98046. wipeCaches(bruteForce?: boolean): void;
  98047. /** @hidden */
  98048. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98049. min: number;
  98050. mag: number;
  98051. };
  98052. /** @hidden */
  98053. _createTexture(): WebGLTexture;
  98054. /**
  98055. * Usually called from Texture.ts.
  98056. * Passed information to create a WebGLTexture
  98057. * @param urlArg defines a value which contains one of the following:
  98058. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98059. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98060. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98061. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98062. * @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)
  98063. * @param scene needed for loading to the correct scene
  98064. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98065. * @param onLoad optional callback to be called upon successful completion
  98066. * @param onError optional callback to be called upon failure
  98067. * @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
  98068. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98069. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98070. * @param forcedExtension defines the extension to use to pick the right loader
  98071. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98072. * @param mimeType defines an optional mime type
  98073. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98074. */
  98075. 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;
  98076. /**
  98077. * @hidden
  98078. */
  98079. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98080. /**
  98081. * Creates a raw texture
  98082. * @param data defines the data to store in the texture
  98083. * @param width defines the width of the texture
  98084. * @param height defines the height of the texture
  98085. * @param format defines the format of the data
  98086. * @param generateMipMaps defines if the engine should generate the mip levels
  98087. * @param invertY defines if data must be stored with Y axis inverted
  98088. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98089. * @param compression defines the compression used (null by default)
  98090. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98091. * @returns the raw texture inside an InternalTexture
  98092. */
  98093. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98094. /**
  98095. * Creates a new raw cube texture
  98096. * @param data defines the array of data to use to create each face
  98097. * @param size defines the size of the textures
  98098. * @param format defines the format of the data
  98099. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98100. * @param generateMipMaps defines if the engine should generate the mip levels
  98101. * @param invertY defines if data must be stored with Y axis inverted
  98102. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98103. * @param compression defines the compression used (null by default)
  98104. * @returns the cube texture as an InternalTexture
  98105. */
  98106. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98107. /**
  98108. * Creates a new raw 3D texture
  98109. * @param data defines the data used to create the texture
  98110. * @param width defines the width of the texture
  98111. * @param height defines the height of the texture
  98112. * @param depth defines the depth of the texture
  98113. * @param format defines the format of the texture
  98114. * @param generateMipMaps defines if the engine must generate mip levels
  98115. * @param invertY defines if data must be stored with Y axis inverted
  98116. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98117. * @param compression defines the compressed used (can be null)
  98118. * @param textureType defines the compressed used (can be null)
  98119. * @returns a new raw 3D texture (stored in an InternalTexture)
  98120. */
  98121. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98122. /**
  98123. * Creates a new raw 2D array texture
  98124. * @param data defines the data used to create the texture
  98125. * @param width defines the width of the texture
  98126. * @param height defines the height of the texture
  98127. * @param depth defines the number of layers of the texture
  98128. * @param format defines the format of the texture
  98129. * @param generateMipMaps defines if the engine must generate mip levels
  98130. * @param invertY defines if data must be stored with Y axis inverted
  98131. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98132. * @param compression defines the compressed used (can be null)
  98133. * @param textureType defines the compressed used (can be null)
  98134. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98135. */
  98136. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98137. private _unpackFlipYCached;
  98138. /**
  98139. * In case you are sharing the context with other applications, it might
  98140. * be interested to not cache the unpack flip y state to ensure a consistent
  98141. * value would be set.
  98142. */
  98143. enableUnpackFlipYCached: boolean;
  98144. /** @hidden */
  98145. _unpackFlipY(value: boolean): void;
  98146. /** @hidden */
  98147. _getUnpackAlignement(): number;
  98148. /**
  98149. * Update the sampling mode of a given texture
  98150. * @param samplingMode defines the required sampling mode
  98151. * @param texture defines the texture to update
  98152. */
  98153. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98154. /** @hidden */
  98155. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98156. width: number;
  98157. height: number;
  98158. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98159. /** @hidden */
  98160. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98161. /** @hidden */
  98162. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98163. /** @hidden */
  98164. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98165. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98166. private _prepareWebGLTexture;
  98167. /** @hidden */
  98168. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98169. /** @hidden */
  98170. _releaseFramebufferObjects(texture: InternalTexture): void;
  98171. /** @hidden */
  98172. _releaseTexture(texture: InternalTexture): void;
  98173. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98174. protected _setProgram(program: WebGLProgram): void;
  98175. protected _boundUniforms: {
  98176. [key: number]: WebGLUniformLocation;
  98177. };
  98178. /**
  98179. * Binds an effect to the webGL context
  98180. * @param effect defines the effect to bind
  98181. */
  98182. bindSamplers(effect: Effect): void;
  98183. private _activateCurrentTexture;
  98184. /** @hidden */
  98185. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98186. /** @hidden */
  98187. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98188. /**
  98189. * Unbind all textures from the webGL context
  98190. */
  98191. unbindAllTextures(): void;
  98192. /**
  98193. * Sets a texture to the according uniform.
  98194. * @param channel The texture channel
  98195. * @param uniform The uniform to set
  98196. * @param texture The texture to apply
  98197. */
  98198. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98199. private _bindSamplerUniformToChannel;
  98200. private _getTextureWrapMode;
  98201. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98202. /**
  98203. * Sets an array of texture to the webGL context
  98204. * @param channel defines the channel where the texture array must be set
  98205. * @param uniform defines the associated uniform location
  98206. * @param textures defines the array of textures to bind
  98207. */
  98208. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98209. /** @hidden */
  98210. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98211. private _setTextureParameterFloat;
  98212. private _setTextureParameterInteger;
  98213. /**
  98214. * Unbind all vertex attributes from the webGL context
  98215. */
  98216. unbindAllAttributes(): void;
  98217. /**
  98218. * 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
  98219. */
  98220. releaseEffects(): void;
  98221. /**
  98222. * Dispose and release all associated resources
  98223. */
  98224. dispose(): void;
  98225. /**
  98226. * Attach a new callback raised when context lost event is fired
  98227. * @param callback defines the callback to call
  98228. */
  98229. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98230. /**
  98231. * Attach a new callback raised when context restored event is fired
  98232. * @param callback defines the callback to call
  98233. */
  98234. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98235. /**
  98236. * Get the current error code of the webGL context
  98237. * @returns the error code
  98238. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98239. */
  98240. getError(): number;
  98241. private _canRenderToFloatFramebuffer;
  98242. private _canRenderToHalfFloatFramebuffer;
  98243. private _canRenderToFramebuffer;
  98244. /** @hidden */
  98245. _getWebGLTextureType(type: number): number;
  98246. /** @hidden */
  98247. _getInternalFormat(format: number): number;
  98248. /** @hidden */
  98249. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98250. /** @hidden */
  98251. _getRGBAMultiSampleBufferFormat(type: number): number;
  98252. /** @hidden */
  98253. _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;
  98254. /**
  98255. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98256. * @returns true if the engine can be created
  98257. * @ignorenaming
  98258. */
  98259. static isSupported(): boolean;
  98260. /**
  98261. * Find the next highest power of two.
  98262. * @param x Number to start search from.
  98263. * @return Next highest power of two.
  98264. */
  98265. static CeilingPOT(x: number): number;
  98266. /**
  98267. * Find the next lowest power of two.
  98268. * @param x Number to start search from.
  98269. * @return Next lowest power of two.
  98270. */
  98271. static FloorPOT(x: number): number;
  98272. /**
  98273. * Find the nearest power of two.
  98274. * @param x Number to start search from.
  98275. * @return Next nearest power of two.
  98276. */
  98277. static NearestPOT(x: number): number;
  98278. /**
  98279. * Get the closest exponent of two
  98280. * @param value defines the value to approximate
  98281. * @param max defines the maximum value to return
  98282. * @param mode defines how to define the closest value
  98283. * @returns closest exponent of two of the given value
  98284. */
  98285. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98286. /**
  98287. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98288. * @param func - the function to be called
  98289. * @param requester - the object that will request the next frame. Falls back to window.
  98290. * @returns frame number
  98291. */
  98292. static QueueNewFrame(func: () => void, requester?: any): number;
  98293. }
  98294. }
  98295. declare module BABYLON {
  98296. /**
  98297. * Class representing spherical harmonics coefficients to the 3rd degree
  98298. */
  98299. export class SphericalHarmonics {
  98300. /**
  98301. * Defines whether or not the harmonics have been prescaled for rendering.
  98302. */
  98303. preScaled: boolean;
  98304. /**
  98305. * The l0,0 coefficients of the spherical harmonics
  98306. */
  98307. l00: Vector3;
  98308. /**
  98309. * The l1,-1 coefficients of the spherical harmonics
  98310. */
  98311. l1_1: Vector3;
  98312. /**
  98313. * The l1,0 coefficients of the spherical harmonics
  98314. */
  98315. l10: Vector3;
  98316. /**
  98317. * The l1,1 coefficients of the spherical harmonics
  98318. */
  98319. l11: Vector3;
  98320. /**
  98321. * The l2,-2 coefficients of the spherical harmonics
  98322. */
  98323. l2_2: Vector3;
  98324. /**
  98325. * The l2,-1 coefficients of the spherical harmonics
  98326. */
  98327. l2_1: Vector3;
  98328. /**
  98329. * The l2,0 coefficients of the spherical harmonics
  98330. */
  98331. l20: Vector3;
  98332. /**
  98333. * The l2,1 coefficients of the spherical harmonics
  98334. */
  98335. l21: Vector3;
  98336. /**
  98337. * The l2,2 coefficients of the spherical harmonics
  98338. */
  98339. l22: Vector3;
  98340. /**
  98341. * Adds a light to the spherical harmonics
  98342. * @param direction the direction of the light
  98343. * @param color the color of the light
  98344. * @param deltaSolidAngle the delta solid angle of the light
  98345. */
  98346. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98347. /**
  98348. * Scales the spherical harmonics by the given amount
  98349. * @param scale the amount to scale
  98350. */
  98351. scaleInPlace(scale: number): void;
  98352. /**
  98353. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98354. *
  98355. * ```
  98356. * E_lm = A_l * L_lm
  98357. * ```
  98358. *
  98359. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98360. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98361. * the scaling factors are given in equation 9.
  98362. */
  98363. convertIncidentRadianceToIrradiance(): void;
  98364. /**
  98365. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98366. *
  98367. * ```
  98368. * L = (1/pi) * E * rho
  98369. * ```
  98370. *
  98371. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98372. */
  98373. convertIrradianceToLambertianRadiance(): void;
  98374. /**
  98375. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98376. * required operations at run time.
  98377. *
  98378. * This is simply done by scaling back the SH with Ylm constants parameter.
  98379. * The trigonometric part being applied by the shader at run time.
  98380. */
  98381. preScaleForRendering(): void;
  98382. /**
  98383. * Constructs a spherical harmonics from an array.
  98384. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98385. * @returns the spherical harmonics
  98386. */
  98387. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98388. /**
  98389. * Gets the spherical harmonics from polynomial
  98390. * @param polynomial the spherical polynomial
  98391. * @returns the spherical harmonics
  98392. */
  98393. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98394. }
  98395. /**
  98396. * Class representing spherical polynomial coefficients to the 3rd degree
  98397. */
  98398. export class SphericalPolynomial {
  98399. private _harmonics;
  98400. /**
  98401. * The spherical harmonics used to create the polynomials.
  98402. */
  98403. readonly preScaledHarmonics: SphericalHarmonics;
  98404. /**
  98405. * The x coefficients of the spherical polynomial
  98406. */
  98407. x: Vector3;
  98408. /**
  98409. * The y coefficients of the spherical polynomial
  98410. */
  98411. y: Vector3;
  98412. /**
  98413. * The z coefficients of the spherical polynomial
  98414. */
  98415. z: Vector3;
  98416. /**
  98417. * The xx coefficients of the spherical polynomial
  98418. */
  98419. xx: Vector3;
  98420. /**
  98421. * The yy coefficients of the spherical polynomial
  98422. */
  98423. yy: Vector3;
  98424. /**
  98425. * The zz coefficients of the spherical polynomial
  98426. */
  98427. zz: Vector3;
  98428. /**
  98429. * The xy coefficients of the spherical polynomial
  98430. */
  98431. xy: Vector3;
  98432. /**
  98433. * The yz coefficients of the spherical polynomial
  98434. */
  98435. yz: Vector3;
  98436. /**
  98437. * The zx coefficients of the spherical polynomial
  98438. */
  98439. zx: Vector3;
  98440. /**
  98441. * Adds an ambient color to the spherical polynomial
  98442. * @param color the color to add
  98443. */
  98444. addAmbient(color: Color3): void;
  98445. /**
  98446. * Scales the spherical polynomial by the given amount
  98447. * @param scale the amount to scale
  98448. */
  98449. scaleInPlace(scale: number): void;
  98450. /**
  98451. * Gets the spherical polynomial from harmonics
  98452. * @param harmonics the spherical harmonics
  98453. * @returns the spherical polynomial
  98454. */
  98455. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98456. /**
  98457. * Constructs a spherical polynomial from an array.
  98458. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98459. * @returns the spherical polynomial
  98460. */
  98461. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98462. }
  98463. }
  98464. declare module BABYLON {
  98465. /**
  98466. * Defines the source of the internal texture
  98467. */
  98468. export enum InternalTextureSource {
  98469. /**
  98470. * The source of the texture data is unknown
  98471. */
  98472. Unknown = 0,
  98473. /**
  98474. * Texture data comes from an URL
  98475. */
  98476. Url = 1,
  98477. /**
  98478. * Texture data is only used for temporary storage
  98479. */
  98480. Temp = 2,
  98481. /**
  98482. * Texture data comes from raw data (ArrayBuffer)
  98483. */
  98484. Raw = 3,
  98485. /**
  98486. * Texture content is dynamic (video or dynamic texture)
  98487. */
  98488. Dynamic = 4,
  98489. /**
  98490. * Texture content is generated by rendering to it
  98491. */
  98492. RenderTarget = 5,
  98493. /**
  98494. * Texture content is part of a multi render target process
  98495. */
  98496. MultiRenderTarget = 6,
  98497. /**
  98498. * Texture data comes from a cube data file
  98499. */
  98500. Cube = 7,
  98501. /**
  98502. * Texture data comes from a raw cube data
  98503. */
  98504. CubeRaw = 8,
  98505. /**
  98506. * Texture data come from a prefiltered cube data file
  98507. */
  98508. CubePrefiltered = 9,
  98509. /**
  98510. * Texture content is raw 3D data
  98511. */
  98512. Raw3D = 10,
  98513. /**
  98514. * Texture content is raw 2D array data
  98515. */
  98516. Raw2DArray = 11,
  98517. /**
  98518. * Texture content is a depth texture
  98519. */
  98520. Depth = 12,
  98521. /**
  98522. * Texture data comes from a raw cube data encoded with RGBD
  98523. */
  98524. CubeRawRGBD = 13
  98525. }
  98526. /**
  98527. * Class used to store data associated with WebGL texture data for the engine
  98528. * This class should not be used directly
  98529. */
  98530. export class InternalTexture {
  98531. /** @hidden */
  98532. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98533. /**
  98534. * Defines if the texture is ready
  98535. */
  98536. isReady: boolean;
  98537. /**
  98538. * Defines if the texture is a cube texture
  98539. */
  98540. isCube: boolean;
  98541. /**
  98542. * Defines if the texture contains 3D data
  98543. */
  98544. is3D: boolean;
  98545. /**
  98546. * Defines if the texture contains 2D array data
  98547. */
  98548. is2DArray: boolean;
  98549. /**
  98550. * Defines if the texture contains multiview data
  98551. */
  98552. isMultiview: boolean;
  98553. /**
  98554. * Gets the URL used to load this texture
  98555. */
  98556. url: string;
  98557. /**
  98558. * Gets the sampling mode of the texture
  98559. */
  98560. samplingMode: number;
  98561. /**
  98562. * Gets a boolean indicating if the texture needs mipmaps generation
  98563. */
  98564. generateMipMaps: boolean;
  98565. /**
  98566. * Gets the number of samples used by the texture (WebGL2+ only)
  98567. */
  98568. samples: number;
  98569. /**
  98570. * Gets the type of the texture (int, float...)
  98571. */
  98572. type: number;
  98573. /**
  98574. * Gets the format of the texture (RGB, RGBA...)
  98575. */
  98576. format: number;
  98577. /**
  98578. * Observable called when the texture is loaded
  98579. */
  98580. onLoadedObservable: Observable<InternalTexture>;
  98581. /**
  98582. * Gets the width of the texture
  98583. */
  98584. width: number;
  98585. /**
  98586. * Gets the height of the texture
  98587. */
  98588. height: number;
  98589. /**
  98590. * Gets the depth of the texture
  98591. */
  98592. depth: number;
  98593. /**
  98594. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98595. */
  98596. baseWidth: number;
  98597. /**
  98598. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98599. */
  98600. baseHeight: number;
  98601. /**
  98602. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98603. */
  98604. baseDepth: number;
  98605. /**
  98606. * Gets a boolean indicating if the texture is inverted on Y axis
  98607. */
  98608. invertY: boolean;
  98609. /** @hidden */
  98610. _invertVScale: boolean;
  98611. /** @hidden */
  98612. _associatedChannel: number;
  98613. /** @hidden */
  98614. _source: InternalTextureSource;
  98615. /** @hidden */
  98616. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98617. /** @hidden */
  98618. _bufferView: Nullable<ArrayBufferView>;
  98619. /** @hidden */
  98620. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98621. /** @hidden */
  98622. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98623. /** @hidden */
  98624. _size: number;
  98625. /** @hidden */
  98626. _extension: string;
  98627. /** @hidden */
  98628. _files: Nullable<string[]>;
  98629. /** @hidden */
  98630. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98631. /** @hidden */
  98632. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98633. /** @hidden */
  98634. _framebuffer: Nullable<WebGLFramebuffer>;
  98635. /** @hidden */
  98636. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98637. /** @hidden */
  98638. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98639. /** @hidden */
  98640. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98641. /** @hidden */
  98642. _attachments: Nullable<number[]>;
  98643. /** @hidden */
  98644. _cachedCoordinatesMode: Nullable<number>;
  98645. /** @hidden */
  98646. _cachedWrapU: Nullable<number>;
  98647. /** @hidden */
  98648. _cachedWrapV: Nullable<number>;
  98649. /** @hidden */
  98650. _cachedWrapR: Nullable<number>;
  98651. /** @hidden */
  98652. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98653. /** @hidden */
  98654. _isDisabled: boolean;
  98655. /** @hidden */
  98656. _compression: Nullable<string>;
  98657. /** @hidden */
  98658. _generateStencilBuffer: boolean;
  98659. /** @hidden */
  98660. _generateDepthBuffer: boolean;
  98661. /** @hidden */
  98662. _comparisonFunction: number;
  98663. /** @hidden */
  98664. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98665. /** @hidden */
  98666. _lodGenerationScale: number;
  98667. /** @hidden */
  98668. _lodGenerationOffset: number;
  98669. /** @hidden */
  98670. _colorTextureArray: Nullable<WebGLTexture>;
  98671. /** @hidden */
  98672. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98673. /** @hidden */
  98674. _lodTextureHigh: Nullable<BaseTexture>;
  98675. /** @hidden */
  98676. _lodTextureMid: Nullable<BaseTexture>;
  98677. /** @hidden */
  98678. _lodTextureLow: Nullable<BaseTexture>;
  98679. /** @hidden */
  98680. _isRGBD: boolean;
  98681. /** @hidden */
  98682. _linearSpecularLOD: boolean;
  98683. /** @hidden */
  98684. _irradianceTexture: Nullable<BaseTexture>;
  98685. /** @hidden */
  98686. _webGLTexture: Nullable<WebGLTexture>;
  98687. /** @hidden */
  98688. _references: number;
  98689. private _engine;
  98690. /**
  98691. * Gets the Engine the texture belongs to.
  98692. * @returns The babylon engine
  98693. */
  98694. getEngine(): ThinEngine;
  98695. /**
  98696. * Gets the data source type of the texture
  98697. */
  98698. readonly source: InternalTextureSource;
  98699. /**
  98700. * Creates a new InternalTexture
  98701. * @param engine defines the engine to use
  98702. * @param source defines the type of data that will be used
  98703. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98704. */
  98705. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98706. /**
  98707. * Increments the number of references (ie. the number of Texture that point to it)
  98708. */
  98709. incrementReferences(): void;
  98710. /**
  98711. * Change the size of the texture (not the size of the content)
  98712. * @param width defines the new width
  98713. * @param height defines the new height
  98714. * @param depth defines the new depth (1 by default)
  98715. */
  98716. updateSize(width: int, height: int, depth?: int): void;
  98717. /** @hidden */
  98718. _rebuild(): void;
  98719. /** @hidden */
  98720. _swapAndDie(target: InternalTexture): void;
  98721. /**
  98722. * Dispose the current allocated resources
  98723. */
  98724. dispose(): void;
  98725. }
  98726. }
  98727. declare module BABYLON {
  98728. /**
  98729. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98731. */
  98732. export class Analyser {
  98733. /**
  98734. * Gets or sets the smoothing
  98735. * @ignorenaming
  98736. */
  98737. SMOOTHING: number;
  98738. /**
  98739. * Gets or sets the FFT table size
  98740. * @ignorenaming
  98741. */
  98742. FFT_SIZE: number;
  98743. /**
  98744. * Gets or sets the bar graph amplitude
  98745. * @ignorenaming
  98746. */
  98747. BARGRAPHAMPLITUDE: number;
  98748. /**
  98749. * Gets or sets the position of the debug canvas
  98750. * @ignorenaming
  98751. */
  98752. DEBUGCANVASPOS: {
  98753. x: number;
  98754. y: number;
  98755. };
  98756. /**
  98757. * Gets or sets the debug canvas size
  98758. * @ignorenaming
  98759. */
  98760. DEBUGCANVASSIZE: {
  98761. width: number;
  98762. height: number;
  98763. };
  98764. private _byteFreqs;
  98765. private _byteTime;
  98766. private _floatFreqs;
  98767. private _webAudioAnalyser;
  98768. private _debugCanvas;
  98769. private _debugCanvasContext;
  98770. private _scene;
  98771. private _registerFunc;
  98772. private _audioEngine;
  98773. /**
  98774. * Creates a new analyser
  98775. * @param scene defines hosting scene
  98776. */
  98777. constructor(scene: Scene);
  98778. /**
  98779. * Get the number of data values you will have to play with for the visualization
  98780. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98781. * @returns a number
  98782. */
  98783. getFrequencyBinCount(): number;
  98784. /**
  98785. * Gets the current frequency data as a byte array
  98786. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98787. * @returns a Uint8Array
  98788. */
  98789. getByteFrequencyData(): Uint8Array;
  98790. /**
  98791. * Gets the current waveform as a byte array
  98792. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  98793. * @returns a Uint8Array
  98794. */
  98795. getByteTimeDomainData(): Uint8Array;
  98796. /**
  98797. * Gets the current frequency data as a float array
  98798. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98799. * @returns a Float32Array
  98800. */
  98801. getFloatFrequencyData(): Float32Array;
  98802. /**
  98803. * Renders the debug canvas
  98804. */
  98805. drawDebugCanvas(): void;
  98806. /**
  98807. * Stops rendering the debug canvas and removes it
  98808. */
  98809. stopDebugCanvas(): void;
  98810. /**
  98811. * Connects two audio nodes
  98812. * @param inputAudioNode defines first node to connect
  98813. * @param outputAudioNode defines second node to connect
  98814. */
  98815. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  98816. /**
  98817. * Releases all associated resources
  98818. */
  98819. dispose(): void;
  98820. }
  98821. }
  98822. declare module BABYLON {
  98823. /**
  98824. * This represents an audio engine and it is responsible
  98825. * to play, synchronize and analyse sounds throughout the application.
  98826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98827. */
  98828. export interface IAudioEngine extends IDisposable {
  98829. /**
  98830. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98831. */
  98832. readonly canUseWebAudio: boolean;
  98833. /**
  98834. * Gets the current AudioContext if available.
  98835. */
  98836. readonly audioContext: Nullable<AudioContext>;
  98837. /**
  98838. * The master gain node defines the global audio volume of your audio engine.
  98839. */
  98840. readonly masterGain: GainNode;
  98841. /**
  98842. * Gets whether or not mp3 are supported by your browser.
  98843. */
  98844. readonly isMP3supported: boolean;
  98845. /**
  98846. * Gets whether or not ogg are supported by your browser.
  98847. */
  98848. readonly isOGGsupported: boolean;
  98849. /**
  98850. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98851. * @ignoreNaming
  98852. */
  98853. WarnedWebAudioUnsupported: boolean;
  98854. /**
  98855. * Defines if the audio engine relies on a custom unlocked button.
  98856. * In this case, the embedded button will not be displayed.
  98857. */
  98858. useCustomUnlockedButton: boolean;
  98859. /**
  98860. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98861. */
  98862. readonly unlocked: boolean;
  98863. /**
  98864. * Event raised when audio has been unlocked on the browser.
  98865. */
  98866. onAudioUnlockedObservable: Observable<AudioEngine>;
  98867. /**
  98868. * Event raised when audio has been locked on the browser.
  98869. */
  98870. onAudioLockedObservable: Observable<AudioEngine>;
  98871. /**
  98872. * Flags the audio engine in Locked state.
  98873. * This happens due to new browser policies preventing audio to autoplay.
  98874. */
  98875. lock(): void;
  98876. /**
  98877. * Unlocks the audio engine once a user action has been done on the dom.
  98878. * This is helpful to resume play once browser policies have been satisfied.
  98879. */
  98880. unlock(): void;
  98881. }
  98882. /**
  98883. * This represents the default audio engine used in babylon.
  98884. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98886. */
  98887. export class AudioEngine implements IAudioEngine {
  98888. private _audioContext;
  98889. private _audioContextInitialized;
  98890. private _muteButton;
  98891. private _hostElement;
  98892. /**
  98893. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98894. */
  98895. canUseWebAudio: boolean;
  98896. /**
  98897. * The master gain node defines the global audio volume of your audio engine.
  98898. */
  98899. masterGain: GainNode;
  98900. /**
  98901. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98902. * @ignoreNaming
  98903. */
  98904. WarnedWebAudioUnsupported: boolean;
  98905. /**
  98906. * Gets whether or not mp3 are supported by your browser.
  98907. */
  98908. isMP3supported: boolean;
  98909. /**
  98910. * Gets whether or not ogg are supported by your browser.
  98911. */
  98912. isOGGsupported: boolean;
  98913. /**
  98914. * Gets whether audio has been unlocked on the device.
  98915. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98916. * a user interaction has happened.
  98917. */
  98918. unlocked: boolean;
  98919. /**
  98920. * Defines if the audio engine relies on a custom unlocked button.
  98921. * In this case, the embedded button will not be displayed.
  98922. */
  98923. useCustomUnlockedButton: boolean;
  98924. /**
  98925. * Event raised when audio has been unlocked on the browser.
  98926. */
  98927. onAudioUnlockedObservable: Observable<AudioEngine>;
  98928. /**
  98929. * Event raised when audio has been locked on the browser.
  98930. */
  98931. onAudioLockedObservable: Observable<AudioEngine>;
  98932. /**
  98933. * Gets the current AudioContext if available.
  98934. */
  98935. readonly audioContext: Nullable<AudioContext>;
  98936. private _connectedAnalyser;
  98937. /**
  98938. * Instantiates a new audio engine.
  98939. *
  98940. * There should be only one per page as some browsers restrict the number
  98941. * of audio contexts you can create.
  98942. * @param hostElement defines the host element where to display the mute icon if necessary
  98943. */
  98944. constructor(hostElement?: Nullable<HTMLElement>);
  98945. /**
  98946. * Flags the audio engine in Locked state.
  98947. * This happens due to new browser policies preventing audio to autoplay.
  98948. */
  98949. lock(): void;
  98950. /**
  98951. * Unlocks the audio engine once a user action has been done on the dom.
  98952. * This is helpful to resume play once browser policies have been satisfied.
  98953. */
  98954. unlock(): void;
  98955. private _resumeAudioContext;
  98956. private _initializeAudioContext;
  98957. private _tryToRun;
  98958. private _triggerRunningState;
  98959. private _triggerSuspendedState;
  98960. private _displayMuteButton;
  98961. private _moveButtonToTopLeft;
  98962. private _onResize;
  98963. private _hideMuteButton;
  98964. /**
  98965. * Destroy and release the resources associated with the audio ccontext.
  98966. */
  98967. dispose(): void;
  98968. /**
  98969. * Gets the global volume sets on the master gain.
  98970. * @returns the global volume if set or -1 otherwise
  98971. */
  98972. getGlobalVolume(): number;
  98973. /**
  98974. * Sets the global volume of your experience (sets on the master gain).
  98975. * @param newVolume Defines the new global volume of the application
  98976. */
  98977. setGlobalVolume(newVolume: number): void;
  98978. /**
  98979. * Connect the audio engine to an audio analyser allowing some amazing
  98980. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98982. * @param analyser The analyser to connect to the engine
  98983. */
  98984. connectToAnalyser(analyser: Analyser): void;
  98985. }
  98986. }
  98987. declare module BABYLON {
  98988. /**
  98989. * Interface used to present a loading screen while loading a scene
  98990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98991. */
  98992. export interface ILoadingScreen {
  98993. /**
  98994. * Function called to display the loading screen
  98995. */
  98996. displayLoadingUI: () => void;
  98997. /**
  98998. * Function called to hide the loading screen
  98999. */
  99000. hideLoadingUI: () => void;
  99001. /**
  99002. * Gets or sets the color to use for the background
  99003. */
  99004. loadingUIBackgroundColor: string;
  99005. /**
  99006. * Gets or sets the text to display while loading
  99007. */
  99008. loadingUIText: string;
  99009. }
  99010. /**
  99011. * Class used for the default loading screen
  99012. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99013. */
  99014. export class DefaultLoadingScreen implements ILoadingScreen {
  99015. private _renderingCanvas;
  99016. private _loadingText;
  99017. private _loadingDivBackgroundColor;
  99018. private _loadingDiv;
  99019. private _loadingTextDiv;
  99020. /** Gets or sets the logo url to use for the default loading screen */
  99021. static DefaultLogoUrl: string;
  99022. /** Gets or sets the spinner url to use for the default loading screen */
  99023. static DefaultSpinnerUrl: string;
  99024. /**
  99025. * Creates a new default loading screen
  99026. * @param _renderingCanvas defines the canvas used to render the scene
  99027. * @param _loadingText defines the default text to display
  99028. * @param _loadingDivBackgroundColor defines the default background color
  99029. */
  99030. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99031. /**
  99032. * Function called to display the loading screen
  99033. */
  99034. displayLoadingUI(): void;
  99035. /**
  99036. * Function called to hide the loading screen
  99037. */
  99038. hideLoadingUI(): void;
  99039. /**
  99040. * Gets or sets the text to display while loading
  99041. */
  99042. loadingUIText: string;
  99043. /**
  99044. * Gets or sets the color to use for the background
  99045. */
  99046. loadingUIBackgroundColor: string;
  99047. private _resizeLoadingUI;
  99048. }
  99049. }
  99050. declare module BABYLON {
  99051. /**
  99052. * Interface for any object that can request an animation frame
  99053. */
  99054. export interface ICustomAnimationFrameRequester {
  99055. /**
  99056. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99057. */
  99058. renderFunction?: Function;
  99059. /**
  99060. * Called to request the next frame to render to
  99061. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99062. */
  99063. requestAnimationFrame: Function;
  99064. /**
  99065. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99066. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99067. */
  99068. requestID?: number;
  99069. }
  99070. }
  99071. declare module BABYLON {
  99072. /**
  99073. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99074. */
  99075. export class PerformanceMonitor {
  99076. private _enabled;
  99077. private _rollingFrameTime;
  99078. private _lastFrameTimeMs;
  99079. /**
  99080. * constructor
  99081. * @param frameSampleSize The number of samples required to saturate the sliding window
  99082. */
  99083. constructor(frameSampleSize?: number);
  99084. /**
  99085. * Samples current frame
  99086. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99087. */
  99088. sampleFrame(timeMs?: number): void;
  99089. /**
  99090. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99091. */
  99092. readonly averageFrameTime: number;
  99093. /**
  99094. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99095. */
  99096. readonly averageFrameTimeVariance: number;
  99097. /**
  99098. * Returns the frame time of the most recent frame
  99099. */
  99100. readonly instantaneousFrameTime: number;
  99101. /**
  99102. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99103. */
  99104. readonly averageFPS: number;
  99105. /**
  99106. * Returns the average framerate in frames per second using the most recent frame time
  99107. */
  99108. readonly instantaneousFPS: number;
  99109. /**
  99110. * Returns true if enough samples have been taken to completely fill the sliding window
  99111. */
  99112. readonly isSaturated: boolean;
  99113. /**
  99114. * Enables contributions to the sliding window sample set
  99115. */
  99116. enable(): void;
  99117. /**
  99118. * Disables contributions to the sliding window sample set
  99119. * Samples will not be interpolated over the disabled period
  99120. */
  99121. disable(): void;
  99122. /**
  99123. * Returns true if sampling is enabled
  99124. */
  99125. readonly isEnabled: boolean;
  99126. /**
  99127. * Resets performance monitor
  99128. */
  99129. reset(): void;
  99130. }
  99131. /**
  99132. * RollingAverage
  99133. *
  99134. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99135. */
  99136. export class RollingAverage {
  99137. /**
  99138. * Current average
  99139. */
  99140. average: number;
  99141. /**
  99142. * Current variance
  99143. */
  99144. variance: number;
  99145. protected _samples: Array<number>;
  99146. protected _sampleCount: number;
  99147. protected _pos: number;
  99148. protected _m2: number;
  99149. /**
  99150. * constructor
  99151. * @param length The number of samples required to saturate the sliding window
  99152. */
  99153. constructor(length: number);
  99154. /**
  99155. * Adds a sample to the sample set
  99156. * @param v The sample value
  99157. */
  99158. add(v: number): void;
  99159. /**
  99160. * Returns previously added values or null if outside of history or outside the sliding window domain
  99161. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99162. * @return Value previously recorded with add() or null if outside of range
  99163. */
  99164. history(i: number): number;
  99165. /**
  99166. * Returns true if enough samples have been taken to completely fill the sliding window
  99167. * @return true if sample-set saturated
  99168. */
  99169. isSaturated(): boolean;
  99170. /**
  99171. * Resets the rolling average (equivalent to 0 samples taken so far)
  99172. */
  99173. reset(): void;
  99174. /**
  99175. * Wraps a value around the sample range boundaries
  99176. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99177. * @return Wrapped position in sample range
  99178. */
  99179. protected _wrapPosition(i: number): number;
  99180. }
  99181. }
  99182. declare module BABYLON {
  99183. /**
  99184. * This class is used to track a performance counter which is number based.
  99185. * The user has access to many properties which give statistics of different nature.
  99186. *
  99187. * The implementer can track two kinds of Performance Counter: time and count.
  99188. * 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.
  99189. * 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.
  99190. */
  99191. export class PerfCounter {
  99192. /**
  99193. * Gets or sets a global boolean to turn on and off all the counters
  99194. */
  99195. static Enabled: boolean;
  99196. /**
  99197. * Returns the smallest value ever
  99198. */
  99199. readonly min: number;
  99200. /**
  99201. * Returns the biggest value ever
  99202. */
  99203. readonly max: number;
  99204. /**
  99205. * Returns the average value since the performance counter is running
  99206. */
  99207. readonly average: number;
  99208. /**
  99209. * Returns the average value of the last second the counter was monitored
  99210. */
  99211. readonly lastSecAverage: number;
  99212. /**
  99213. * Returns the current value
  99214. */
  99215. readonly current: number;
  99216. /**
  99217. * Gets the accumulated total
  99218. */
  99219. readonly total: number;
  99220. /**
  99221. * Gets the total value count
  99222. */
  99223. readonly count: number;
  99224. /**
  99225. * Creates a new counter
  99226. */
  99227. constructor();
  99228. /**
  99229. * Call this method to start monitoring a new frame.
  99230. * 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.
  99231. */
  99232. fetchNewFrame(): void;
  99233. /**
  99234. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99235. * @param newCount the count value to add to the monitored count
  99236. * @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.
  99237. */
  99238. addCount(newCount: number, fetchResult: boolean): void;
  99239. /**
  99240. * Start monitoring this performance counter
  99241. */
  99242. beginMonitoring(): void;
  99243. /**
  99244. * Compute the time lapsed since the previous beginMonitoring() call.
  99245. * @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
  99246. */
  99247. endMonitoring(newFrame?: boolean): void;
  99248. private _fetchResult;
  99249. private _startMonitoringTime;
  99250. private _min;
  99251. private _max;
  99252. private _average;
  99253. private _current;
  99254. private _totalValueCount;
  99255. private _totalAccumulated;
  99256. private _lastSecAverage;
  99257. private _lastSecAccumulated;
  99258. private _lastSecTime;
  99259. private _lastSecValueCount;
  99260. }
  99261. }
  99262. declare module BABYLON {
  99263. /**
  99264. * Defines the interface used by display changed events
  99265. */
  99266. export interface IDisplayChangedEventArgs {
  99267. /** Gets the vrDisplay object (if any) */
  99268. vrDisplay: Nullable<any>;
  99269. /** Gets a boolean indicating if webVR is supported */
  99270. vrSupported: boolean;
  99271. }
  99272. /**
  99273. * Defines the interface used by objects containing a viewport (like a camera)
  99274. */
  99275. interface IViewportOwnerLike {
  99276. /**
  99277. * Gets or sets the viewport
  99278. */
  99279. viewport: IViewportLike;
  99280. }
  99281. /**
  99282. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99283. */
  99284. export class Engine extends ThinEngine {
  99285. /** Defines that alpha blending is disabled */
  99286. static readonly ALPHA_DISABLE: number;
  99287. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99288. static readonly ALPHA_ADD: number;
  99289. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99290. static readonly ALPHA_COMBINE: number;
  99291. /** Defines that alpha blending to DEST - SRC * DEST */
  99292. static readonly ALPHA_SUBTRACT: number;
  99293. /** Defines that alpha blending to SRC * DEST */
  99294. static readonly ALPHA_MULTIPLY: number;
  99295. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99296. static readonly ALPHA_MAXIMIZED: number;
  99297. /** Defines that alpha blending to SRC + DEST */
  99298. static readonly ALPHA_ONEONE: number;
  99299. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99300. static readonly ALPHA_PREMULTIPLIED: number;
  99301. /**
  99302. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99303. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99304. */
  99305. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99306. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99307. static readonly ALPHA_INTERPOLATE: number;
  99308. /**
  99309. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99310. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99311. */
  99312. static readonly ALPHA_SCREENMODE: number;
  99313. /** Defines that the ressource is not delayed*/
  99314. static readonly DELAYLOADSTATE_NONE: number;
  99315. /** Defines that the ressource was successfully delay loaded */
  99316. static readonly DELAYLOADSTATE_LOADED: number;
  99317. /** Defines that the ressource is currently delay loading */
  99318. static readonly DELAYLOADSTATE_LOADING: number;
  99319. /** Defines that the ressource is delayed and has not started loading */
  99320. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99321. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99322. static readonly NEVER: number;
  99323. /** 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 */
  99324. static readonly ALWAYS: number;
  99325. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99326. static readonly LESS: number;
  99327. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99328. static readonly EQUAL: number;
  99329. /** 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 */
  99330. static readonly LEQUAL: number;
  99331. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99332. static readonly GREATER: number;
  99333. /** 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 */
  99334. static readonly GEQUAL: number;
  99335. /** 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 */
  99336. static readonly NOTEQUAL: number;
  99337. /** Passed to stencilOperation to specify that stencil value must be kept */
  99338. static readonly KEEP: number;
  99339. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99340. static readonly REPLACE: number;
  99341. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99342. static readonly INCR: number;
  99343. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99344. static readonly DECR: number;
  99345. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99346. static readonly INVERT: number;
  99347. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99348. static readonly INCR_WRAP: number;
  99349. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99350. static readonly DECR_WRAP: number;
  99351. /** Texture is not repeating outside of 0..1 UVs */
  99352. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99353. /** Texture is repeating outside of 0..1 UVs */
  99354. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99355. /** Texture is repeating and mirrored */
  99356. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99357. /** ALPHA */
  99358. static readonly TEXTUREFORMAT_ALPHA: number;
  99359. /** LUMINANCE */
  99360. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99361. /** LUMINANCE_ALPHA */
  99362. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99363. /** RGB */
  99364. static readonly TEXTUREFORMAT_RGB: number;
  99365. /** RGBA */
  99366. static readonly TEXTUREFORMAT_RGBA: number;
  99367. /** RED */
  99368. static readonly TEXTUREFORMAT_RED: number;
  99369. /** RED (2nd reference) */
  99370. static readonly TEXTUREFORMAT_R: number;
  99371. /** RG */
  99372. static readonly TEXTUREFORMAT_RG: number;
  99373. /** RED_INTEGER */
  99374. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99375. /** RED_INTEGER (2nd reference) */
  99376. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99377. /** RG_INTEGER */
  99378. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99379. /** RGB_INTEGER */
  99380. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99381. /** RGBA_INTEGER */
  99382. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99383. /** UNSIGNED_BYTE */
  99384. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99385. /** UNSIGNED_BYTE (2nd reference) */
  99386. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99387. /** FLOAT */
  99388. static readonly TEXTURETYPE_FLOAT: number;
  99389. /** HALF_FLOAT */
  99390. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99391. /** BYTE */
  99392. static readonly TEXTURETYPE_BYTE: number;
  99393. /** SHORT */
  99394. static readonly TEXTURETYPE_SHORT: number;
  99395. /** UNSIGNED_SHORT */
  99396. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99397. /** INT */
  99398. static readonly TEXTURETYPE_INT: number;
  99399. /** UNSIGNED_INT */
  99400. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99401. /** UNSIGNED_SHORT_4_4_4_4 */
  99402. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99403. /** UNSIGNED_SHORT_5_5_5_1 */
  99404. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99405. /** UNSIGNED_SHORT_5_6_5 */
  99406. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99407. /** UNSIGNED_INT_2_10_10_10_REV */
  99408. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99409. /** UNSIGNED_INT_24_8 */
  99410. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99411. /** UNSIGNED_INT_10F_11F_11F_REV */
  99412. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99413. /** UNSIGNED_INT_5_9_9_9_REV */
  99414. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99415. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99416. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99417. /** nearest is mag = nearest and min = nearest and mip = linear */
  99418. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99419. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99420. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99421. /** Trilinear is mag = linear and min = linear and mip = linear */
  99422. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99423. /** nearest is mag = nearest and min = nearest and mip = linear */
  99424. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99425. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99426. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99427. /** Trilinear is mag = linear and min = linear and mip = linear */
  99428. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99429. /** mag = nearest and min = nearest and mip = nearest */
  99430. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99431. /** mag = nearest and min = linear and mip = nearest */
  99432. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99433. /** mag = nearest and min = linear and mip = linear */
  99434. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99435. /** mag = nearest and min = linear and mip = none */
  99436. static readonly TEXTURE_NEAREST_LINEAR: number;
  99437. /** mag = nearest and min = nearest and mip = none */
  99438. static readonly TEXTURE_NEAREST_NEAREST: number;
  99439. /** mag = linear and min = nearest and mip = nearest */
  99440. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99441. /** mag = linear and min = nearest and mip = linear */
  99442. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99443. /** mag = linear and min = linear and mip = none */
  99444. static readonly TEXTURE_LINEAR_LINEAR: number;
  99445. /** mag = linear and min = nearest and mip = none */
  99446. static readonly TEXTURE_LINEAR_NEAREST: number;
  99447. /** Explicit coordinates mode */
  99448. static readonly TEXTURE_EXPLICIT_MODE: number;
  99449. /** Spherical coordinates mode */
  99450. static readonly TEXTURE_SPHERICAL_MODE: number;
  99451. /** Planar coordinates mode */
  99452. static readonly TEXTURE_PLANAR_MODE: number;
  99453. /** Cubic coordinates mode */
  99454. static readonly TEXTURE_CUBIC_MODE: number;
  99455. /** Projection coordinates mode */
  99456. static readonly TEXTURE_PROJECTION_MODE: number;
  99457. /** Skybox coordinates mode */
  99458. static readonly TEXTURE_SKYBOX_MODE: number;
  99459. /** Inverse Cubic coordinates mode */
  99460. static readonly TEXTURE_INVCUBIC_MODE: number;
  99461. /** Equirectangular coordinates mode */
  99462. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99463. /** Equirectangular Fixed coordinates mode */
  99464. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99465. /** Equirectangular Fixed Mirrored coordinates mode */
  99466. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99467. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99468. static readonly SCALEMODE_FLOOR: number;
  99469. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99470. static readonly SCALEMODE_NEAREST: number;
  99471. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99472. static readonly SCALEMODE_CEILING: number;
  99473. /**
  99474. * Returns the current npm package of the sdk
  99475. */
  99476. static readonly NpmPackage: string;
  99477. /**
  99478. * Returns the current version of the framework
  99479. */
  99480. static readonly Version: string;
  99481. /** Gets the list of created engines */
  99482. static readonly Instances: Engine[];
  99483. /**
  99484. * Gets the latest created engine
  99485. */
  99486. static readonly LastCreatedEngine: Nullable<Engine>;
  99487. /**
  99488. * Gets the latest created scene
  99489. */
  99490. static readonly LastCreatedScene: Nullable<Scene>;
  99491. /**
  99492. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99493. * @param flag defines which part of the materials must be marked as dirty
  99494. * @param predicate defines a predicate used to filter which materials should be affected
  99495. */
  99496. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99497. /**
  99498. * Method called to create the default loading screen.
  99499. * This can be overriden in your own app.
  99500. * @param canvas The rendering canvas element
  99501. * @returns The loading screen
  99502. */
  99503. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99504. /**
  99505. * Method called to create the default rescale post process on each engine.
  99506. */
  99507. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99508. /**
  99509. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99510. **/
  99511. enableOfflineSupport: boolean;
  99512. /**
  99513. * 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)
  99514. **/
  99515. disableManifestCheck: boolean;
  99516. /**
  99517. * Gets the list of created scenes
  99518. */
  99519. scenes: Scene[];
  99520. /**
  99521. * Event raised when a new scene is created
  99522. */
  99523. onNewSceneAddedObservable: Observable<Scene>;
  99524. /**
  99525. * Gets the list of created postprocesses
  99526. */
  99527. postProcesses: PostProcess[];
  99528. /**
  99529. * Gets a boolean indicating if the pointer is currently locked
  99530. */
  99531. isPointerLock: boolean;
  99532. /**
  99533. * Observable event triggered each time the rendering canvas is resized
  99534. */
  99535. onResizeObservable: Observable<Engine>;
  99536. /**
  99537. * Observable event triggered each time the canvas loses focus
  99538. */
  99539. onCanvasBlurObservable: Observable<Engine>;
  99540. /**
  99541. * Observable event triggered each time the canvas gains focus
  99542. */
  99543. onCanvasFocusObservable: Observable<Engine>;
  99544. /**
  99545. * Observable event triggered each time the canvas receives pointerout event
  99546. */
  99547. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99548. /**
  99549. * Observable raised when the engine begins a new frame
  99550. */
  99551. onBeginFrameObservable: Observable<Engine>;
  99552. /**
  99553. * If set, will be used to request the next animation frame for the render loop
  99554. */
  99555. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99556. /**
  99557. * Observable raised when the engine ends the current frame
  99558. */
  99559. onEndFrameObservable: Observable<Engine>;
  99560. /**
  99561. * Observable raised when the engine is about to compile a shader
  99562. */
  99563. onBeforeShaderCompilationObservable: Observable<Engine>;
  99564. /**
  99565. * Observable raised when the engine has jsut compiled a shader
  99566. */
  99567. onAfterShaderCompilationObservable: Observable<Engine>;
  99568. /**
  99569. * Gets the audio engine
  99570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99571. * @ignorenaming
  99572. */
  99573. static audioEngine: IAudioEngine;
  99574. /**
  99575. * Default AudioEngine factory responsible of creating the Audio Engine.
  99576. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99577. */
  99578. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99579. /**
  99580. * Default offline support factory responsible of creating a tool used to store data locally.
  99581. * By default, this will create a Database object if the workload has been embedded.
  99582. */
  99583. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99584. private _loadingScreen;
  99585. private _pointerLockRequested;
  99586. private _dummyFramebuffer;
  99587. private _rescalePostProcess;
  99588. /** @hidden */
  99589. protected _alphaMode: number;
  99590. /** @hidden */
  99591. protected _alphaEquation: number;
  99592. private _deterministicLockstep;
  99593. private _lockstepMaxSteps;
  99594. protected readonly _supportsHardwareTextureRescaling: boolean;
  99595. private _fps;
  99596. private _deltaTime;
  99597. /** @hidden */
  99598. _drawCalls: PerfCounter;
  99599. /**
  99600. * Turn this value on if you want to pause FPS computation when in background
  99601. */
  99602. disablePerformanceMonitorInBackground: boolean;
  99603. private _performanceMonitor;
  99604. /**
  99605. * Gets the performance monitor attached to this engine
  99606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99607. */
  99608. readonly performanceMonitor: PerformanceMonitor;
  99609. private _onFocus;
  99610. private _onBlur;
  99611. private _onCanvasPointerOut;
  99612. private _onCanvasBlur;
  99613. private _onCanvasFocus;
  99614. private _onFullscreenChange;
  99615. private _onPointerLockChange;
  99616. /**
  99617. * Gets the HTML element used to attach event listeners
  99618. * @returns a HTML element
  99619. */
  99620. getInputElement(): Nullable<HTMLElement>;
  99621. /**
  99622. * Creates a new engine
  99623. * @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
  99624. * @param antialias defines enable antialiasing (default: false)
  99625. * @param options defines further options to be sent to the getContext() function
  99626. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99627. */
  99628. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99629. /**
  99630. * Gets current aspect ratio
  99631. * @param viewportOwner defines the camera to use to get the aspect ratio
  99632. * @param useScreen defines if screen size must be used (or the current render target if any)
  99633. * @returns a number defining the aspect ratio
  99634. */
  99635. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99636. /**
  99637. * Gets current screen aspect ratio
  99638. * @returns a number defining the aspect ratio
  99639. */
  99640. getScreenAspectRatio(): number;
  99641. /**
  99642. * Gets host document
  99643. * @returns the host document object
  99644. */
  99645. getHostDocument(): Document;
  99646. /**
  99647. * Gets the client rect of the HTML canvas attached with the current webGL context
  99648. * @returns a client rectanglee
  99649. */
  99650. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99651. /**
  99652. * Gets the client rect of the HTML element used for events
  99653. * @returns a client rectanglee
  99654. */
  99655. getInputElementClientRect(): Nullable<ClientRect>;
  99656. /**
  99657. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99659. * @returns true if engine is in deterministic lock step mode
  99660. */
  99661. isDeterministicLockStep(): boolean;
  99662. /**
  99663. * Gets the max steps when engine is running in deterministic lock step
  99664. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99665. * @returns the max steps
  99666. */
  99667. getLockstepMaxSteps(): number;
  99668. /**
  99669. * Force the mipmap generation for the given render target texture
  99670. * @param texture defines the render target texture to use
  99671. */
  99672. generateMipMapsForCubemap(texture: InternalTexture): void;
  99673. /** States */
  99674. /**
  99675. * Set various states to the webGL context
  99676. * @param culling defines backface culling state
  99677. * @param zOffset defines the value to apply to zOffset (0 by default)
  99678. * @param force defines if states must be applied even if cache is up to date
  99679. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99680. */
  99681. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99682. /**
  99683. * Set the z offset to apply to current rendering
  99684. * @param value defines the offset to apply
  99685. */
  99686. setZOffset(value: number): void;
  99687. /**
  99688. * Gets the current value of the zOffset
  99689. * @returns the current zOffset state
  99690. */
  99691. getZOffset(): number;
  99692. /**
  99693. * Enable or disable depth buffering
  99694. * @param enable defines the state to set
  99695. */
  99696. setDepthBuffer(enable: boolean): void;
  99697. /**
  99698. * Gets a boolean indicating if depth writing is enabled
  99699. * @returns the current depth writing state
  99700. */
  99701. getDepthWrite(): boolean;
  99702. /**
  99703. * Enable or disable depth writing
  99704. * @param enable defines the state to set
  99705. */
  99706. setDepthWrite(enable: boolean): void;
  99707. /**
  99708. * Enable or disable color writing
  99709. * @param enable defines the state to set
  99710. */
  99711. setColorWrite(enable: boolean): void;
  99712. /**
  99713. * Gets a boolean indicating if color writing is enabled
  99714. * @returns the current color writing state
  99715. */
  99716. getColorWrite(): boolean;
  99717. /**
  99718. * Sets alpha constants used by some alpha blending modes
  99719. * @param r defines the red component
  99720. * @param g defines the green component
  99721. * @param b defines the blue component
  99722. * @param a defines the alpha component
  99723. */
  99724. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99725. /**
  99726. * Sets the current alpha mode
  99727. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99728. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99729. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99730. */
  99731. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99732. /**
  99733. * Gets the current alpha mode
  99734. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99735. * @returns the current alpha mode
  99736. */
  99737. getAlphaMode(): number;
  99738. /**
  99739. * Sets the current alpha equation
  99740. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99741. */
  99742. setAlphaEquation(equation: number): void;
  99743. /**
  99744. * Gets the current alpha equation.
  99745. * @returns the current alpha equation
  99746. */
  99747. getAlphaEquation(): number;
  99748. /**
  99749. * Gets a boolean indicating if stencil buffer is enabled
  99750. * @returns the current stencil buffer state
  99751. */
  99752. getStencilBuffer(): boolean;
  99753. /**
  99754. * Enable or disable the stencil buffer
  99755. * @param enable defines if the stencil buffer must be enabled or disabled
  99756. */
  99757. setStencilBuffer(enable: boolean): void;
  99758. /**
  99759. * Gets the current stencil mask
  99760. * @returns a number defining the new stencil mask to use
  99761. */
  99762. getStencilMask(): number;
  99763. /**
  99764. * Sets the current stencil mask
  99765. * @param mask defines the new stencil mask to use
  99766. */
  99767. setStencilMask(mask: number): void;
  99768. /**
  99769. * Gets the current stencil function
  99770. * @returns a number defining the stencil function to use
  99771. */
  99772. getStencilFunction(): number;
  99773. /**
  99774. * Gets the current stencil reference value
  99775. * @returns a number defining the stencil reference value to use
  99776. */
  99777. getStencilFunctionReference(): number;
  99778. /**
  99779. * Gets the current stencil mask
  99780. * @returns a number defining the stencil mask to use
  99781. */
  99782. getStencilFunctionMask(): number;
  99783. /**
  99784. * Sets the current stencil function
  99785. * @param stencilFunc defines the new stencil function to use
  99786. */
  99787. setStencilFunction(stencilFunc: number): void;
  99788. /**
  99789. * Sets the current stencil reference
  99790. * @param reference defines the new stencil reference to use
  99791. */
  99792. setStencilFunctionReference(reference: number): void;
  99793. /**
  99794. * Sets the current stencil mask
  99795. * @param mask defines the new stencil mask to use
  99796. */
  99797. setStencilFunctionMask(mask: number): void;
  99798. /**
  99799. * Gets the current stencil operation when stencil fails
  99800. * @returns a number defining stencil operation to use when stencil fails
  99801. */
  99802. getStencilOperationFail(): number;
  99803. /**
  99804. * Gets the current stencil operation when depth fails
  99805. * @returns a number defining stencil operation to use when depth fails
  99806. */
  99807. getStencilOperationDepthFail(): number;
  99808. /**
  99809. * Gets the current stencil operation when stencil passes
  99810. * @returns a number defining stencil operation to use when stencil passes
  99811. */
  99812. getStencilOperationPass(): number;
  99813. /**
  99814. * Sets the stencil operation to use when stencil fails
  99815. * @param operation defines the stencil operation to use when stencil fails
  99816. */
  99817. setStencilOperationFail(operation: number): void;
  99818. /**
  99819. * Sets the stencil operation to use when depth fails
  99820. * @param operation defines the stencil operation to use when depth fails
  99821. */
  99822. setStencilOperationDepthFail(operation: number): void;
  99823. /**
  99824. * Sets the stencil operation to use when stencil passes
  99825. * @param operation defines the stencil operation to use when stencil passes
  99826. */
  99827. setStencilOperationPass(operation: number): void;
  99828. /**
  99829. * Sets a boolean indicating if the dithering state is enabled or disabled
  99830. * @param value defines the dithering state
  99831. */
  99832. setDitheringState(value: boolean): void;
  99833. /**
  99834. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99835. * @param value defines the rasterizer state
  99836. */
  99837. setRasterizerState(value: boolean): void;
  99838. /**
  99839. * Gets the current depth function
  99840. * @returns a number defining the depth function
  99841. */
  99842. getDepthFunction(): Nullable<number>;
  99843. /**
  99844. * Sets the current depth function
  99845. * @param depthFunc defines the function to use
  99846. */
  99847. setDepthFunction(depthFunc: number): void;
  99848. /**
  99849. * Sets the current depth function to GREATER
  99850. */
  99851. setDepthFunctionToGreater(): void;
  99852. /**
  99853. * Sets the current depth function to GEQUAL
  99854. */
  99855. setDepthFunctionToGreaterOrEqual(): void;
  99856. /**
  99857. * Sets the current depth function to LESS
  99858. */
  99859. setDepthFunctionToLess(): void;
  99860. /**
  99861. * Sets the current depth function to LEQUAL
  99862. */
  99863. setDepthFunctionToLessOrEqual(): void;
  99864. private _cachedStencilBuffer;
  99865. private _cachedStencilFunction;
  99866. private _cachedStencilMask;
  99867. private _cachedStencilOperationPass;
  99868. private _cachedStencilOperationFail;
  99869. private _cachedStencilOperationDepthFail;
  99870. private _cachedStencilReference;
  99871. /**
  99872. * Caches the the state of the stencil buffer
  99873. */
  99874. cacheStencilState(): void;
  99875. /**
  99876. * Restores the state of the stencil buffer
  99877. */
  99878. restoreStencilState(): void;
  99879. /**
  99880. * Directly set the WebGL Viewport
  99881. * @param x defines the x coordinate of the viewport (in screen space)
  99882. * @param y defines the y coordinate of the viewport (in screen space)
  99883. * @param width defines the width of the viewport (in screen space)
  99884. * @param height defines the height of the viewport (in screen space)
  99885. * @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
  99886. */
  99887. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99888. /**
  99889. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99890. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99891. * @param y defines the y-coordinate of the corner of the clear rectangle
  99892. * @param width defines the width of the clear rectangle
  99893. * @param height defines the height of the clear rectangle
  99894. * @param clearColor defines the clear color
  99895. */
  99896. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99897. /**
  99898. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99899. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99900. * @param y defines the y-coordinate of the corner of the clear rectangle
  99901. * @param width defines the width of the clear rectangle
  99902. * @param height defines the height of the clear rectangle
  99903. */
  99904. enableScissor(x: number, y: number, width: number, height: number): void;
  99905. /**
  99906. * Disable previously set scissor test rectangle
  99907. */
  99908. disableScissor(): void;
  99909. protected _reportDrawCall(): void;
  99910. /**
  99911. * Initializes a webVR display and starts listening to display change events
  99912. * The onVRDisplayChangedObservable will be notified upon these changes
  99913. * @returns The onVRDisplayChangedObservable
  99914. */
  99915. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99916. /** @hidden */
  99917. _prepareVRComponent(): void;
  99918. /** @hidden */
  99919. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99920. /** @hidden */
  99921. _submitVRFrame(): void;
  99922. /**
  99923. * Call this function to leave webVR mode
  99924. * Will do nothing if webVR is not supported or if there is no webVR device
  99925. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99926. */
  99927. disableVR(): void;
  99928. /**
  99929. * Gets a boolean indicating that the system is in VR mode and is presenting
  99930. * @returns true if VR mode is engaged
  99931. */
  99932. isVRPresenting(): boolean;
  99933. /** @hidden */
  99934. _requestVRFrame(): void;
  99935. /** @hidden */
  99936. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99937. /**
  99938. * Gets the source code of the vertex shader associated with a specific webGL program
  99939. * @param program defines the program to use
  99940. * @returns a string containing the source code of the vertex shader associated with the program
  99941. */
  99942. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99943. /**
  99944. * Gets the source code of the fragment shader associated with a specific webGL program
  99945. * @param program defines the program to use
  99946. * @returns a string containing the source code of the fragment shader associated with the program
  99947. */
  99948. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99949. /**
  99950. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99951. * @param x defines the x coordinate of the rectangle where pixels must be read
  99952. * @param y defines the y coordinate of the rectangle where pixels must be read
  99953. * @param width defines the width of the rectangle where pixels must be read
  99954. * @param height defines the height of the rectangle where pixels must be read
  99955. * @returns a Uint8Array containing RGBA colors
  99956. */
  99957. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99958. /**
  99959. * Sets a depth stencil texture from a render target to the according uniform.
  99960. * @param channel The texture channel
  99961. * @param uniform The uniform to set
  99962. * @param texture The render target texture containing the depth stencil texture to apply
  99963. */
  99964. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99965. /**
  99966. * Sets a texture to the webGL context from a postprocess
  99967. * @param channel defines the channel to use
  99968. * @param postProcess defines the source postprocess
  99969. */
  99970. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99971. /**
  99972. * Binds the output of the passed in post process to the texture channel specified
  99973. * @param channel The channel the texture should be bound to
  99974. * @param postProcess The post process which's output should be bound
  99975. */
  99976. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99977. /** @hidden */
  99978. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99979. protected _rebuildBuffers(): void;
  99980. /** @hidden */
  99981. _renderFrame(): void;
  99982. _renderLoop(): void;
  99983. /** @hidden */
  99984. _renderViews(): boolean;
  99985. /**
  99986. * Toggle full screen mode
  99987. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99988. */
  99989. switchFullscreen(requestPointerLock: boolean): void;
  99990. /**
  99991. * Enters full screen mode
  99992. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99993. */
  99994. enterFullscreen(requestPointerLock: boolean): void;
  99995. /**
  99996. * Exits full screen mode
  99997. */
  99998. exitFullscreen(): void;
  99999. /**
  100000. * Enters Pointerlock mode
  100001. */
  100002. enterPointerlock(): void;
  100003. /**
  100004. * Exits Pointerlock mode
  100005. */
  100006. exitPointerlock(): void;
  100007. /**
  100008. * Begin a new frame
  100009. */
  100010. beginFrame(): void;
  100011. /**
  100012. * Enf the current frame
  100013. */
  100014. endFrame(): void;
  100015. resize(): void;
  100016. /**
  100017. * Set the compressed texture format to use, based on the formats you have, and the formats
  100018. * supported by the hardware / browser.
  100019. *
  100020. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100021. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100022. * to API arguments needed to compressed textures. This puts the burden on the container
  100023. * generator to house the arcane code for determining these for current & future formats.
  100024. *
  100025. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100026. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100027. *
  100028. * Note: The result of this call is not taken into account when a texture is base64.
  100029. *
  100030. * @param formatsAvailable defines the list of those format families you have created
  100031. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100032. *
  100033. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100034. * @returns The extension selected.
  100035. */
  100036. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100037. /**
  100038. * Force a specific size of the canvas
  100039. * @param width defines the new canvas' width
  100040. * @param height defines the new canvas' height
  100041. */
  100042. setSize(width: number, height: number): void;
  100043. /**
  100044. * Updates a dynamic vertex buffer.
  100045. * @param vertexBuffer the vertex buffer to update
  100046. * @param data the data used to update the vertex buffer
  100047. * @param byteOffset the byte offset of the data
  100048. * @param byteLength the byte length of the data
  100049. */
  100050. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100051. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100052. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100053. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100054. _releaseTexture(texture: InternalTexture): void;
  100055. /**
  100056. * @hidden
  100057. * Rescales a texture
  100058. * @param source input texutre
  100059. * @param destination destination texture
  100060. * @param scene scene to use to render the resize
  100061. * @param internalFormat format to use when resizing
  100062. * @param onComplete callback to be called when resize has completed
  100063. */
  100064. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100065. /**
  100066. * Gets the current framerate
  100067. * @returns a number representing the framerate
  100068. */
  100069. getFps(): number;
  100070. /**
  100071. * Gets the time spent between current and previous frame
  100072. * @returns a number representing the delta time in ms
  100073. */
  100074. getDeltaTime(): number;
  100075. private _measureFps;
  100076. /** @hidden */
  100077. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100078. /**
  100079. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100080. * @param renderTarget The render target to set the frame buffer for
  100081. */
  100082. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100083. /**
  100084. * Update a dynamic index buffer
  100085. * @param indexBuffer defines the target index buffer
  100086. * @param indices defines the data to update
  100087. * @param offset defines the offset in the target index buffer where update should start
  100088. */
  100089. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100090. /**
  100091. * Updates the sample count of a render target texture
  100092. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100093. * @param texture defines the texture to update
  100094. * @param samples defines the sample count to set
  100095. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100096. */
  100097. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100098. /**
  100099. * Updates a depth texture Comparison Mode and Function.
  100100. * If the comparison Function is equal to 0, the mode will be set to none.
  100101. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100102. * @param texture The texture to set the comparison function for
  100103. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100104. */
  100105. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100106. /**
  100107. * Creates a webGL buffer to use with instanciation
  100108. * @param capacity defines the size of the buffer
  100109. * @returns the webGL buffer
  100110. */
  100111. createInstancesBuffer(capacity: number): DataBuffer;
  100112. /**
  100113. * Delete a webGL buffer used with instanciation
  100114. * @param buffer defines the webGL buffer to delete
  100115. */
  100116. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100117. /** @hidden */
  100118. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100119. dispose(): void;
  100120. private _disableTouchAction;
  100121. /**
  100122. * Display the loading screen
  100123. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100124. */
  100125. displayLoadingUI(): void;
  100126. /**
  100127. * Hide the loading screen
  100128. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100129. */
  100130. hideLoadingUI(): void;
  100131. /**
  100132. * Gets the current loading screen object
  100133. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100134. */
  100135. /**
  100136. * Sets the current loading screen object
  100137. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100138. */
  100139. loadingScreen: ILoadingScreen;
  100140. /**
  100141. * Sets the current loading screen text
  100142. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100143. */
  100144. loadingUIText: string;
  100145. /**
  100146. * Sets the current loading screen background color
  100147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100148. */
  100149. loadingUIBackgroundColor: string;
  100150. /** Pointerlock and fullscreen */
  100151. /**
  100152. * Ask the browser to promote the current element to pointerlock mode
  100153. * @param element defines the DOM element to promote
  100154. */
  100155. static _RequestPointerlock(element: HTMLElement): void;
  100156. /**
  100157. * Asks the browser to exit pointerlock mode
  100158. */
  100159. static _ExitPointerlock(): void;
  100160. /**
  100161. * Ask the browser to promote the current element to fullscreen rendering mode
  100162. * @param element defines the DOM element to promote
  100163. */
  100164. static _RequestFullscreen(element: HTMLElement): void;
  100165. /**
  100166. * Asks the browser to exit fullscreen mode
  100167. */
  100168. static _ExitFullscreen(): void;
  100169. }
  100170. }
  100171. declare module BABYLON {
  100172. /**
  100173. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100174. * during the life time of the application.
  100175. */
  100176. export class EngineStore {
  100177. /** Gets the list of created engines */
  100178. static Instances: Engine[];
  100179. /** @hidden */
  100180. static _LastCreatedScene: Nullable<Scene>;
  100181. /**
  100182. * Gets the latest created engine
  100183. */
  100184. static readonly LastCreatedEngine: Nullable<Engine>;
  100185. /**
  100186. * Gets the latest created scene
  100187. */
  100188. static readonly LastCreatedScene: Nullable<Scene>;
  100189. /**
  100190. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100191. * @ignorenaming
  100192. */
  100193. static UseFallbackTexture: boolean;
  100194. /**
  100195. * Texture content used if a texture cannot loaded
  100196. * @ignorenaming
  100197. */
  100198. static FallbackTexture: string;
  100199. }
  100200. }
  100201. declare module BABYLON {
  100202. /**
  100203. * Helper class that provides a small promise polyfill
  100204. */
  100205. export class PromisePolyfill {
  100206. /**
  100207. * Static function used to check if the polyfill is required
  100208. * If this is the case then the function will inject the polyfill to window.Promise
  100209. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100210. */
  100211. static Apply(force?: boolean): void;
  100212. }
  100213. }
  100214. declare module BABYLON {
  100215. /**
  100216. * Interface for screenshot methods with describe argument called `size` as object with options
  100217. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100218. */
  100219. export interface IScreenshotSize {
  100220. /**
  100221. * number in pixels for canvas height
  100222. */
  100223. height?: number;
  100224. /**
  100225. * multiplier allowing render at a higher or lower resolution
  100226. * If value is defined then height and width will be ignored and taken from camera
  100227. */
  100228. precision?: number;
  100229. /**
  100230. * number in pixels for canvas width
  100231. */
  100232. width?: number;
  100233. }
  100234. }
  100235. declare module BABYLON {
  100236. interface IColor4Like {
  100237. r: float;
  100238. g: float;
  100239. b: float;
  100240. a: float;
  100241. }
  100242. /**
  100243. * Class containing a set of static utilities functions
  100244. */
  100245. export class Tools {
  100246. /**
  100247. * Gets or sets the base URL to use to load assets
  100248. */
  100249. static BaseUrl: string;
  100250. /**
  100251. * Enable/Disable Custom HTTP Request Headers globally.
  100252. * default = false
  100253. * @see CustomRequestHeaders
  100254. */
  100255. static UseCustomRequestHeaders: boolean;
  100256. /**
  100257. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100258. * i.e. when loading files, where the server/service expects an Authorization header
  100259. */
  100260. static CustomRequestHeaders: {
  100261. [key: string]: string;
  100262. };
  100263. /**
  100264. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100265. */
  100266. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100267. /**
  100268. * Default behaviour for cors in the application.
  100269. * It can be a string if the expected behavior is identical in the entire app.
  100270. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100271. */
  100272. static CorsBehavior: string | ((url: string | string[]) => string);
  100273. /**
  100274. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100275. * @ignorenaming
  100276. */
  100277. static UseFallbackTexture: boolean;
  100278. /**
  100279. * Use this object to register external classes like custom textures or material
  100280. * to allow the laoders to instantiate them
  100281. */
  100282. static RegisteredExternalClasses: {
  100283. [key: string]: Object;
  100284. };
  100285. /**
  100286. * Texture content used if a texture cannot loaded
  100287. * @ignorenaming
  100288. */
  100289. static fallbackTexture: string;
  100290. /**
  100291. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100292. * @param u defines the coordinate on X axis
  100293. * @param v defines the coordinate on Y axis
  100294. * @param width defines the width of the source data
  100295. * @param height defines the height of the source data
  100296. * @param pixels defines the source byte array
  100297. * @param color defines the output color
  100298. */
  100299. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100300. /**
  100301. * Interpolates between a and b via alpha
  100302. * @param a The lower value (returned when alpha = 0)
  100303. * @param b The upper value (returned when alpha = 1)
  100304. * @param alpha The interpolation-factor
  100305. * @return The mixed value
  100306. */
  100307. static Mix(a: number, b: number, alpha: number): number;
  100308. /**
  100309. * Tries to instantiate a new object from a given class name
  100310. * @param className defines the class name to instantiate
  100311. * @returns the new object or null if the system was not able to do the instantiation
  100312. */
  100313. static Instantiate(className: string): any;
  100314. /**
  100315. * Provides a slice function that will work even on IE
  100316. * @param data defines the array to slice
  100317. * @param start defines the start of the data (optional)
  100318. * @param end defines the end of the data (optional)
  100319. * @returns the new sliced array
  100320. */
  100321. static Slice<T>(data: T, start?: number, end?: number): T;
  100322. /**
  100323. * Polyfill for setImmediate
  100324. * @param action defines the action to execute after the current execution block
  100325. */
  100326. static SetImmediate(action: () => void): void;
  100327. /**
  100328. * Function indicating if a number is an exponent of 2
  100329. * @param value defines the value to test
  100330. * @returns true if the value is an exponent of 2
  100331. */
  100332. static IsExponentOfTwo(value: number): boolean;
  100333. private static _tmpFloatArray;
  100334. /**
  100335. * Returns the nearest 32-bit single precision float representation of a Number
  100336. * @param value A Number. If the parameter is of a different type, it will get converted
  100337. * to a number or to NaN if it cannot be converted
  100338. * @returns number
  100339. */
  100340. static FloatRound(value: number): number;
  100341. /**
  100342. * Extracts the filename from a path
  100343. * @param path defines the path to use
  100344. * @returns the filename
  100345. */
  100346. static GetFilename(path: string): string;
  100347. /**
  100348. * Extracts the "folder" part of a path (everything before the filename).
  100349. * @param uri The URI to extract the info from
  100350. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100351. * @returns The "folder" part of the path
  100352. */
  100353. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100354. /**
  100355. * Extracts text content from a DOM element hierarchy
  100356. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100357. */
  100358. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100359. /**
  100360. * Convert an angle in radians to degrees
  100361. * @param angle defines the angle to convert
  100362. * @returns the angle in degrees
  100363. */
  100364. static ToDegrees(angle: number): number;
  100365. /**
  100366. * Convert an angle in degrees to radians
  100367. * @param angle defines the angle to convert
  100368. * @returns the angle in radians
  100369. */
  100370. static ToRadians(angle: number): number;
  100371. /**
  100372. * Returns an array if obj is not an array
  100373. * @param obj defines the object to evaluate as an array
  100374. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100375. * @returns either obj directly if obj is an array or a new array containing obj
  100376. */
  100377. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100378. /**
  100379. * Gets the pointer prefix to use
  100380. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100381. */
  100382. static GetPointerPrefix(): string;
  100383. /**
  100384. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100385. * @param url define the url we are trying
  100386. * @param element define the dom element where to configure the cors policy
  100387. */
  100388. static SetCorsBehavior(url: string | string[], element: {
  100389. crossOrigin: string | null;
  100390. }): void;
  100391. /**
  100392. * Removes unwanted characters from an url
  100393. * @param url defines the url to clean
  100394. * @returns the cleaned url
  100395. */
  100396. static CleanUrl(url: string): string;
  100397. /**
  100398. * Gets or sets a function used to pre-process url before using them to load assets
  100399. */
  100400. static PreprocessUrl: (url: string) => string;
  100401. /**
  100402. * Loads an image as an HTMLImageElement.
  100403. * @param input url string, ArrayBuffer, or Blob to load
  100404. * @param onLoad callback called when the image successfully loads
  100405. * @param onError callback called when the image fails to load
  100406. * @param offlineProvider offline provider for caching
  100407. * @param mimeType optional mime type
  100408. * @returns the HTMLImageElement of the loaded image
  100409. */
  100410. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100411. /**
  100412. * Loads a file from a url
  100413. * @param url url string, ArrayBuffer, or Blob to load
  100414. * @param onSuccess callback called when the file successfully loads
  100415. * @param onProgress callback called while file is loading (if the server supports this mode)
  100416. * @param offlineProvider defines the offline provider for caching
  100417. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100418. * @param onError callback called when the file fails to load
  100419. * @returns a file request object
  100420. */
  100421. 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;
  100422. /**
  100423. * Loads a file from a url
  100424. * @param url the file url to load
  100425. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100426. */
  100427. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100428. /**
  100429. * Load a script (identified by an url). When the url returns, the
  100430. * content of this file is added into a new script element, attached to the DOM (body element)
  100431. * @param scriptUrl defines the url of the script to laod
  100432. * @param onSuccess defines the callback called when the script is loaded
  100433. * @param onError defines the callback to call if an error occurs
  100434. * @param scriptId defines the id of the script element
  100435. */
  100436. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100437. /**
  100438. * Load an asynchronous script (identified by an url). When the url returns, the
  100439. * content of this file is added into a new script element, attached to the DOM (body element)
  100440. * @param scriptUrl defines the url of the script to laod
  100441. * @param scriptId defines the id of the script element
  100442. * @returns a promise request object
  100443. */
  100444. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100445. /**
  100446. * Loads a file from a blob
  100447. * @param fileToLoad defines the blob to use
  100448. * @param callback defines the callback to call when data is loaded
  100449. * @param progressCallback defines the callback to call during loading process
  100450. * @returns a file request object
  100451. */
  100452. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100453. /**
  100454. * Reads a file from a File object
  100455. * @param file defines the file to load
  100456. * @param onSuccess defines the callback to call when data is loaded
  100457. * @param onProgress defines the callback to call during loading process
  100458. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100459. * @param onError defines the callback to call when an error occurs
  100460. * @returns a file request object
  100461. */
  100462. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100463. /**
  100464. * Creates a data url from a given string content
  100465. * @param content defines the content to convert
  100466. * @returns the new data url link
  100467. */
  100468. static FileAsURL(content: string): string;
  100469. /**
  100470. * Format the given number to a specific decimal format
  100471. * @param value defines the number to format
  100472. * @param decimals defines the number of decimals to use
  100473. * @returns the formatted string
  100474. */
  100475. static Format(value: number, decimals?: number): string;
  100476. /**
  100477. * Tries to copy an object by duplicating every property
  100478. * @param source defines the source object
  100479. * @param destination defines the target object
  100480. * @param doNotCopyList defines a list of properties to avoid
  100481. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100482. */
  100483. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100484. /**
  100485. * Gets a boolean indicating if the given object has no own property
  100486. * @param obj defines the object to test
  100487. * @returns true if object has no own property
  100488. */
  100489. static IsEmpty(obj: any): boolean;
  100490. /**
  100491. * Function used to register events at window level
  100492. * @param windowElement defines the Window object to use
  100493. * @param events defines the events to register
  100494. */
  100495. static RegisterTopRootEvents(windowElement: Window, events: {
  100496. name: string;
  100497. handler: Nullable<(e: FocusEvent) => any>;
  100498. }[]): void;
  100499. /**
  100500. * Function used to unregister events from window level
  100501. * @param windowElement defines the Window object to use
  100502. * @param events defines the events to unregister
  100503. */
  100504. static UnregisterTopRootEvents(windowElement: Window, events: {
  100505. name: string;
  100506. handler: Nullable<(e: FocusEvent) => any>;
  100507. }[]): void;
  100508. /**
  100509. * @ignore
  100510. */
  100511. static _ScreenshotCanvas: HTMLCanvasElement;
  100512. /**
  100513. * Dumps the current bound framebuffer
  100514. * @param width defines the rendering width
  100515. * @param height defines the rendering height
  100516. * @param engine defines the hosting engine
  100517. * @param successCallback defines the callback triggered once the data are available
  100518. * @param mimeType defines the mime type of the result
  100519. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100520. */
  100521. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100522. /**
  100523. * Converts the canvas data to blob.
  100524. * This acts as a polyfill for browsers not supporting the to blob function.
  100525. * @param canvas Defines the canvas to extract the data from
  100526. * @param successCallback Defines the callback triggered once the data are available
  100527. * @param mimeType Defines the mime type of the result
  100528. */
  100529. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100530. /**
  100531. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100532. * @param successCallback defines the callback triggered once the data are available
  100533. * @param mimeType defines the mime type of the result
  100534. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100535. */
  100536. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100537. /**
  100538. * Downloads a blob in the browser
  100539. * @param blob defines the blob to download
  100540. * @param fileName defines the name of the downloaded file
  100541. */
  100542. static Download(blob: Blob, fileName: string): void;
  100543. /**
  100544. * Captures a screenshot of the current rendering
  100545. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100546. * @param engine defines the rendering engine
  100547. * @param camera defines the source camera
  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 defines 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 defines the MIME type of the screenshot image (default: image/png).
  100557. * Check your browser for supported MIME types
  100558. */
  100559. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100560. /**
  100561. * Captures a screenshot of the current rendering
  100562. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100563. * @param engine defines the rendering engine
  100564. * @param camera defines the source camera
  100565. * @param size This parameter can be set to a single number or to an object with the
  100566. * following (optional) properties: precision, width, height. If a single number is passed,
  100567. * it will be used for both width and height. If an object is passed, the screenshot size
  100568. * will be derived from the parameters. The precision property is a multiplier allowing
  100569. * rendering at a higher or lower resolution
  100570. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100571. * Check your browser for supported MIME types
  100572. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100573. * to the src parameter of an <img> to display it
  100574. */
  100575. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100576. /**
  100577. * Generates an image screenshot from the specified camera.
  100578. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100579. * @param engine The engine to use for rendering
  100580. * @param camera The camera to use for rendering
  100581. * @param size This parameter can be set to a single number or to an object with the
  100582. * following (optional) properties: precision, width, height. If a single number is passed,
  100583. * it will be used for both width and height. If an object is passed, the screenshot size
  100584. * will be derived from the parameters. The precision property is a multiplier allowing
  100585. * rendering at a higher or lower resolution
  100586. * @param successCallback The callback receives a single parameter which contains the
  100587. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100588. * src parameter of an <img> to display it
  100589. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100590. * Check your browser for supported MIME types
  100591. * @param samples Texture samples (default: 1)
  100592. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100593. * @param fileName A name for for the downloaded file.
  100594. */
  100595. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100596. /**
  100597. * Generates an image screenshot from the specified camera.
  100598. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100599. * @param engine The engine to use for rendering
  100600. * @param camera The camera to use for rendering
  100601. * @param size This parameter can be set to a single number or to an object with the
  100602. * following (optional) properties: precision, width, height. If a single number is passed,
  100603. * it will be used for both width and height. If an object is passed, the screenshot size
  100604. * will be derived from the parameters. The precision property is a multiplier allowing
  100605. * rendering at a higher or lower resolution
  100606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100607. * Check your browser for supported MIME types
  100608. * @param samples Texture samples (default: 1)
  100609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100610. * @param fileName A name for for the downloaded file.
  100611. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100612. * to the src parameter of an <img> to display it
  100613. */
  100614. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100615. /**
  100616. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100617. * Be aware Math.random() could cause collisions, but:
  100618. * "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"
  100619. * @returns a pseudo random id
  100620. */
  100621. static RandomId(): string;
  100622. /**
  100623. * Test if the given uri is a base64 string
  100624. * @param uri The uri to test
  100625. * @return True if the uri is a base64 string or false otherwise
  100626. */
  100627. static IsBase64(uri: string): boolean;
  100628. /**
  100629. * Decode the given base64 uri.
  100630. * @param uri The uri to decode
  100631. * @return The decoded base64 data.
  100632. */
  100633. static DecodeBase64(uri: string): ArrayBuffer;
  100634. /**
  100635. * Gets the absolute url.
  100636. * @param url the input url
  100637. * @return the absolute url
  100638. */
  100639. static GetAbsoluteUrl(url: string): string;
  100640. /**
  100641. * No log
  100642. */
  100643. static readonly NoneLogLevel: number;
  100644. /**
  100645. * Only message logs
  100646. */
  100647. static readonly MessageLogLevel: number;
  100648. /**
  100649. * Only warning logs
  100650. */
  100651. static readonly WarningLogLevel: number;
  100652. /**
  100653. * Only error logs
  100654. */
  100655. static readonly ErrorLogLevel: number;
  100656. /**
  100657. * All logs
  100658. */
  100659. static readonly AllLogLevel: number;
  100660. /**
  100661. * Gets a value indicating the number of loading errors
  100662. * @ignorenaming
  100663. */
  100664. static readonly errorsCount: number;
  100665. /**
  100666. * Callback called when a new log is added
  100667. */
  100668. static OnNewCacheEntry: (entry: string) => void;
  100669. /**
  100670. * Log a message to the console
  100671. * @param message defines the message to log
  100672. */
  100673. static Log(message: string): void;
  100674. /**
  100675. * Write a warning message to the console
  100676. * @param message defines the message to log
  100677. */
  100678. static Warn(message: string): void;
  100679. /**
  100680. * Write an error message to the console
  100681. * @param message defines the message to log
  100682. */
  100683. static Error(message: string): void;
  100684. /**
  100685. * Gets current log cache (list of logs)
  100686. */
  100687. static readonly LogCache: string;
  100688. /**
  100689. * Clears the log cache
  100690. */
  100691. static ClearLogCache(): void;
  100692. /**
  100693. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100694. */
  100695. static LogLevels: number;
  100696. /**
  100697. * Checks if the window object exists
  100698. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100699. */
  100700. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100701. /**
  100702. * No performance log
  100703. */
  100704. static readonly PerformanceNoneLogLevel: number;
  100705. /**
  100706. * Use user marks to log performance
  100707. */
  100708. static readonly PerformanceUserMarkLogLevel: number;
  100709. /**
  100710. * Log performance to the console
  100711. */
  100712. static readonly PerformanceConsoleLogLevel: number;
  100713. private static _performance;
  100714. /**
  100715. * Sets the current performance log level
  100716. */
  100717. static PerformanceLogLevel: number;
  100718. private static _StartPerformanceCounterDisabled;
  100719. private static _EndPerformanceCounterDisabled;
  100720. private static _StartUserMark;
  100721. private static _EndUserMark;
  100722. private static _StartPerformanceConsole;
  100723. private static _EndPerformanceConsole;
  100724. /**
  100725. * Starts a performance counter
  100726. */
  100727. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100728. /**
  100729. * Ends a specific performance coutner
  100730. */
  100731. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100732. /**
  100733. * Gets either window.performance.now() if supported or Date.now() else
  100734. */
  100735. static readonly Now: number;
  100736. /**
  100737. * This method will return the name of the class used to create the instance of the given object.
  100738. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100739. * @param object the object to get the class name from
  100740. * @param isType defines if the object is actually a type
  100741. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100742. */
  100743. static GetClassName(object: any, isType?: boolean): string;
  100744. /**
  100745. * Gets the first element of an array satisfying a given predicate
  100746. * @param array defines the array to browse
  100747. * @param predicate defines the predicate to use
  100748. * @returns null if not found or the element
  100749. */
  100750. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100751. /**
  100752. * This method will return the name of the full name of the class, including its owning module (if any).
  100753. * 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).
  100754. * @param object the object to get the class name from
  100755. * @param isType defines if the object is actually a type
  100756. * @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.
  100757. * @ignorenaming
  100758. */
  100759. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100760. /**
  100761. * Returns a promise that resolves after the given amount of time.
  100762. * @param delay Number of milliseconds to delay
  100763. * @returns Promise that resolves after the given amount of time
  100764. */
  100765. static DelayAsync(delay: number): Promise<void>;
  100766. }
  100767. /**
  100768. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100769. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100770. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100771. * @param name The name of the class, case should be preserved
  100772. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100773. */
  100774. export function className(name: string, module?: string): (target: Object) => void;
  100775. /**
  100776. * An implementation of a loop for asynchronous functions.
  100777. */
  100778. export class AsyncLoop {
  100779. /**
  100780. * Defines the number of iterations for the loop
  100781. */
  100782. iterations: number;
  100783. /**
  100784. * Defines the current index of the loop.
  100785. */
  100786. index: number;
  100787. private _done;
  100788. private _fn;
  100789. private _successCallback;
  100790. /**
  100791. * Constructor.
  100792. * @param iterations the number of iterations.
  100793. * @param func the function to run each iteration
  100794. * @param successCallback the callback that will be called upon succesful execution
  100795. * @param offset starting offset.
  100796. */
  100797. constructor(
  100798. /**
  100799. * Defines the number of iterations for the loop
  100800. */
  100801. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  100802. /**
  100803. * Execute the next iteration. Must be called after the last iteration was finished.
  100804. */
  100805. executeNext(): void;
  100806. /**
  100807. * Break the loop and run the success callback.
  100808. */
  100809. breakLoop(): void;
  100810. /**
  100811. * Create and run an async loop.
  100812. * @param iterations the number of iterations.
  100813. * @param fn the function to run each iteration
  100814. * @param successCallback the callback that will be called upon succesful execution
  100815. * @param offset starting offset.
  100816. * @returns the created async loop object
  100817. */
  100818. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  100819. /**
  100820. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100821. * @param iterations total number of iterations
  100822. * @param syncedIterations number of synchronous iterations in each async iteration.
  100823. * @param fn the function to call each iteration.
  100824. * @param callback a success call back that will be called when iterating stops.
  100825. * @param breakFunction a break condition (optional)
  100826. * @param timeout timeout settings for the setTimeout function. default - 0.
  100827. * @returns the created async loop object
  100828. */
  100829. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  100830. }
  100831. }
  100832. declare module BABYLON {
  100833. /**
  100834. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100835. * The underlying implementation relies on an associative array to ensure the best performances.
  100836. * The value can be anything including 'null' but except 'undefined'
  100837. */
  100838. export class StringDictionary<T> {
  100839. /**
  100840. * This will clear this dictionary and copy the content from the 'source' one.
  100841. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100842. * @param source the dictionary to take the content from and copy to this dictionary
  100843. */
  100844. copyFrom(source: StringDictionary<T>): void;
  100845. /**
  100846. * Get a value based from its key
  100847. * @param key the given key to get the matching value from
  100848. * @return the value if found, otherwise undefined is returned
  100849. */
  100850. get(key: string): T | undefined;
  100851. /**
  100852. * Get a value from its key or add it if it doesn't exist.
  100853. * This method will ensure you that a given key/data will be present in the dictionary.
  100854. * @param key the given key to get the matching value from
  100855. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100856. * The factory will only be invoked if there's no data for the given key.
  100857. * @return the value corresponding to the key.
  100858. */
  100859. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100860. /**
  100861. * Get a value from its key if present in the dictionary otherwise add it
  100862. * @param key the key to get the value from
  100863. * @param val if there's no such key/value pair in the dictionary add it with this value
  100864. * @return the value corresponding to the key
  100865. */
  100866. getOrAdd(key: string, val: T): T;
  100867. /**
  100868. * Check if there's a given key in the dictionary
  100869. * @param key the key to check for
  100870. * @return true if the key is present, false otherwise
  100871. */
  100872. contains(key: string): boolean;
  100873. /**
  100874. * Add a new key and its corresponding value
  100875. * @param key the key to add
  100876. * @param value the value corresponding to the key
  100877. * @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
  100878. */
  100879. add(key: string, value: T): boolean;
  100880. /**
  100881. * Update a specific value associated to a key
  100882. * @param key defines the key to use
  100883. * @param value defines the value to store
  100884. * @returns true if the value was updated (or false if the key was not found)
  100885. */
  100886. set(key: string, value: T): boolean;
  100887. /**
  100888. * Get the element of the given key and remove it from the dictionary
  100889. * @param key defines the key to search
  100890. * @returns the value associated with the key or null if not found
  100891. */
  100892. getAndRemove(key: string): Nullable<T>;
  100893. /**
  100894. * Remove a key/value from the dictionary.
  100895. * @param key the key to remove
  100896. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100897. */
  100898. remove(key: string): boolean;
  100899. /**
  100900. * Clear the whole content of the dictionary
  100901. */
  100902. clear(): void;
  100903. /**
  100904. * Gets the current count
  100905. */
  100906. readonly count: number;
  100907. /**
  100908. * Execute a callback on each key/val of the dictionary.
  100909. * Note that you can remove any element in this dictionary in the callback implementation
  100910. * @param callback the callback to execute on a given key/value pair
  100911. */
  100912. forEach(callback: (key: string, val: T) => void): void;
  100913. /**
  100914. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100915. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100916. * Note that you can remove any element in this dictionary in the callback implementation
  100917. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100918. * @returns the first item
  100919. */
  100920. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100921. private _count;
  100922. private _data;
  100923. }
  100924. }
  100925. declare module BABYLON {
  100926. /** @hidden */
  100927. export interface ICollisionCoordinator {
  100928. createCollider(): Collider;
  100929. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100930. init(scene: Scene): void;
  100931. }
  100932. /** @hidden */
  100933. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100934. private _scene;
  100935. private _scaledPosition;
  100936. private _scaledVelocity;
  100937. private _finalPosition;
  100938. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100939. createCollider(): Collider;
  100940. init(scene: Scene): void;
  100941. private _collideWithWorld;
  100942. }
  100943. }
  100944. declare module BABYLON {
  100945. /**
  100946. * Class used to manage all inputs for the scene.
  100947. */
  100948. export class InputManager {
  100949. /** The distance in pixel that you have to move to prevent some events */
  100950. static DragMovementThreshold: number;
  100951. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100952. static LongPressDelay: number;
  100953. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100954. static DoubleClickDelay: number;
  100955. /** If you need to check double click without raising a single click at first click, enable this flag */
  100956. static ExclusiveDoubleClickMode: boolean;
  100957. private _wheelEventName;
  100958. private _onPointerMove;
  100959. private _onPointerDown;
  100960. private _onPointerUp;
  100961. private _initClickEvent;
  100962. private _initActionManager;
  100963. private _delayedSimpleClick;
  100964. private _delayedSimpleClickTimeout;
  100965. private _previousDelayedSimpleClickTimeout;
  100966. private _meshPickProceed;
  100967. private _previousButtonPressed;
  100968. private _currentPickResult;
  100969. private _previousPickResult;
  100970. private _totalPointersPressed;
  100971. private _doubleClickOccured;
  100972. private _pointerOverMesh;
  100973. private _pickedDownMesh;
  100974. private _pickedUpMesh;
  100975. private _pointerX;
  100976. private _pointerY;
  100977. private _unTranslatedPointerX;
  100978. private _unTranslatedPointerY;
  100979. private _startingPointerPosition;
  100980. private _previousStartingPointerPosition;
  100981. private _startingPointerTime;
  100982. private _previousStartingPointerTime;
  100983. private _pointerCaptures;
  100984. private _onKeyDown;
  100985. private _onKeyUp;
  100986. private _onCanvasFocusObserver;
  100987. private _onCanvasBlurObserver;
  100988. private _scene;
  100989. /**
  100990. * Creates a new InputManager
  100991. * @param scene defines the hosting scene
  100992. */
  100993. constructor(scene: Scene);
  100994. /**
  100995. * Gets the mesh that is currently under the pointer
  100996. */
  100997. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100998. /**
  100999. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101000. */
  101001. readonly unTranslatedPointer: Vector2;
  101002. /**
  101003. * Gets or sets the current on-screen X position of the pointer
  101004. */
  101005. pointerX: number;
  101006. /**
  101007. * Gets or sets the current on-screen Y position of the pointer
  101008. */
  101009. pointerY: number;
  101010. private _updatePointerPosition;
  101011. private _processPointerMove;
  101012. private _setRayOnPointerInfo;
  101013. private _checkPrePointerObservable;
  101014. /**
  101015. * Use this method to simulate a pointer move on a mesh
  101016. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101017. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101018. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101019. */
  101020. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101021. /**
  101022. * Use this method to simulate a pointer down on a mesh
  101023. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101024. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101025. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101026. */
  101027. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101028. private _processPointerDown;
  101029. /** @hidden */
  101030. _isPointerSwiping(): boolean;
  101031. /**
  101032. * Use this method to simulate a pointer up on a mesh
  101033. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101034. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101035. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101036. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101037. */
  101038. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101039. private _processPointerUp;
  101040. /**
  101041. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101042. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101043. * @returns true if the pointer was captured
  101044. */
  101045. isPointerCaptured(pointerId?: number): boolean;
  101046. /**
  101047. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101048. * @param attachUp defines if you want to attach events to pointerup
  101049. * @param attachDown defines if you want to attach events to pointerdown
  101050. * @param attachMove defines if you want to attach events to pointermove
  101051. */
  101052. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101053. /**
  101054. * Detaches all event handlers
  101055. */
  101056. detachControl(): void;
  101057. /**
  101058. * Force the value of meshUnderPointer
  101059. * @param mesh defines the mesh to use
  101060. */
  101061. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101062. /**
  101063. * Gets the mesh under the pointer
  101064. * @returns a Mesh or null if no mesh is under the pointer
  101065. */
  101066. getPointerOverMesh(): Nullable<AbstractMesh>;
  101067. }
  101068. }
  101069. declare module BABYLON {
  101070. /**
  101071. * Helper class used to generate session unique ID
  101072. */
  101073. export class UniqueIdGenerator {
  101074. private static _UniqueIdCounter;
  101075. /**
  101076. * Gets an unique (relatively to the current scene) Id
  101077. */
  101078. static readonly UniqueId: number;
  101079. }
  101080. }
  101081. declare module BABYLON {
  101082. /**
  101083. * This class defines the direct association between an animation and a target
  101084. */
  101085. export class TargetedAnimation {
  101086. /**
  101087. * Animation to perform
  101088. */
  101089. animation: Animation;
  101090. /**
  101091. * Target to animate
  101092. */
  101093. target: any;
  101094. /**
  101095. * Serialize the object
  101096. * @returns the JSON object representing the current entity
  101097. */
  101098. serialize(): any;
  101099. }
  101100. /**
  101101. * Use this class to create coordinated animations on multiple targets
  101102. */
  101103. export class AnimationGroup implements IDisposable {
  101104. /** The name of the animation group */
  101105. name: string;
  101106. private _scene;
  101107. private _targetedAnimations;
  101108. private _animatables;
  101109. private _from;
  101110. private _to;
  101111. private _isStarted;
  101112. private _isPaused;
  101113. private _speedRatio;
  101114. private _loopAnimation;
  101115. /**
  101116. * Gets or sets the unique id of the node
  101117. */
  101118. uniqueId: number;
  101119. /**
  101120. * This observable will notify when one animation have ended
  101121. */
  101122. onAnimationEndObservable: Observable<TargetedAnimation>;
  101123. /**
  101124. * Observer raised when one animation loops
  101125. */
  101126. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101127. /**
  101128. * Observer raised when all animations have looped
  101129. */
  101130. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101131. /**
  101132. * This observable will notify when all animations have ended.
  101133. */
  101134. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101135. /**
  101136. * This observable will notify when all animations have paused.
  101137. */
  101138. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101139. /**
  101140. * This observable will notify when all animations are playing.
  101141. */
  101142. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101143. /**
  101144. * Gets the first frame
  101145. */
  101146. readonly from: number;
  101147. /**
  101148. * Gets the last frame
  101149. */
  101150. readonly to: number;
  101151. /**
  101152. * Define if the animations are started
  101153. */
  101154. readonly isStarted: boolean;
  101155. /**
  101156. * Gets a value indicating that the current group is playing
  101157. */
  101158. readonly isPlaying: boolean;
  101159. /**
  101160. * Gets or sets the speed ratio to use for all animations
  101161. */
  101162. /**
  101163. * Gets or sets the speed ratio to use for all animations
  101164. */
  101165. speedRatio: number;
  101166. /**
  101167. * Gets or sets if all animations should loop or not
  101168. */
  101169. loopAnimation: boolean;
  101170. /**
  101171. * Gets the targeted animations for this animation group
  101172. */
  101173. readonly targetedAnimations: Array<TargetedAnimation>;
  101174. /**
  101175. * returning the list of animatables controlled by this animation group.
  101176. */
  101177. readonly animatables: Array<Animatable>;
  101178. /**
  101179. * Instantiates a new Animation Group.
  101180. * This helps managing several animations at once.
  101181. * @see http://doc.babylonjs.com/how_to/group
  101182. * @param name Defines the name of the group
  101183. * @param scene Defines the scene the group belongs to
  101184. */
  101185. constructor(
  101186. /** The name of the animation group */
  101187. name: string, scene?: Nullable<Scene>);
  101188. /**
  101189. * Add an animation (with its target) in the group
  101190. * @param animation defines the animation we want to add
  101191. * @param target defines the target of the animation
  101192. * @returns the TargetedAnimation object
  101193. */
  101194. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101195. /**
  101196. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101197. * It can add constant keys at begin or end
  101198. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101199. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101200. * @returns the animation group
  101201. */
  101202. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101203. private _animationLoopCount;
  101204. private _animationLoopFlags;
  101205. private _processLoop;
  101206. /**
  101207. * Start all animations on given targets
  101208. * @param loop defines if animations must loop
  101209. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101210. * @param from defines the from key (optional)
  101211. * @param to defines the to key (optional)
  101212. * @returns the current animation group
  101213. */
  101214. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101215. /**
  101216. * Pause all animations
  101217. * @returns the animation group
  101218. */
  101219. pause(): AnimationGroup;
  101220. /**
  101221. * Play all animations to initial state
  101222. * This function will start() the animations if they were not started or will restart() them if they were paused
  101223. * @param loop defines if animations must loop
  101224. * @returns the animation group
  101225. */
  101226. play(loop?: boolean): AnimationGroup;
  101227. /**
  101228. * Reset all animations to initial state
  101229. * @returns the animation group
  101230. */
  101231. reset(): AnimationGroup;
  101232. /**
  101233. * Restart animations from key 0
  101234. * @returns the animation group
  101235. */
  101236. restart(): AnimationGroup;
  101237. /**
  101238. * Stop all animations
  101239. * @returns the animation group
  101240. */
  101241. stop(): AnimationGroup;
  101242. /**
  101243. * Set animation weight for all animatables
  101244. * @param weight defines the weight to use
  101245. * @return the animationGroup
  101246. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101247. */
  101248. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101249. /**
  101250. * Synchronize and normalize all animatables with a source animatable
  101251. * @param root defines the root animatable to synchronize with
  101252. * @return the animationGroup
  101253. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101254. */
  101255. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101256. /**
  101257. * Goes to a specific frame in this animation group
  101258. * @param frame the frame number to go to
  101259. * @return the animationGroup
  101260. */
  101261. goToFrame(frame: number): AnimationGroup;
  101262. /**
  101263. * Dispose all associated resources
  101264. */
  101265. dispose(): void;
  101266. private _checkAnimationGroupEnded;
  101267. /**
  101268. * Clone the current animation group and returns a copy
  101269. * @param newName defines the name of the new group
  101270. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101271. * @returns the new aniamtion group
  101272. */
  101273. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101274. /**
  101275. * Serializes the animationGroup to an object
  101276. * @returns Serialized object
  101277. */
  101278. serialize(): any;
  101279. /**
  101280. * Returns a new AnimationGroup object parsed from the source provided.
  101281. * @param parsedAnimationGroup defines the source
  101282. * @param scene defines the scene that will receive the animationGroup
  101283. * @returns a new AnimationGroup
  101284. */
  101285. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101286. /**
  101287. * Returns the string "AnimationGroup"
  101288. * @returns "AnimationGroup"
  101289. */
  101290. getClassName(): string;
  101291. /**
  101292. * Creates a detailled string about the object
  101293. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101294. * @returns a string representing the object
  101295. */
  101296. toString(fullDetails?: boolean): string;
  101297. }
  101298. }
  101299. declare module BABYLON {
  101300. /**
  101301. * Define an interface for all classes that will hold resources
  101302. */
  101303. export interface IDisposable {
  101304. /**
  101305. * Releases all held resources
  101306. */
  101307. dispose(): void;
  101308. }
  101309. /** Interface defining initialization parameters for Scene class */
  101310. export interface SceneOptions {
  101311. /**
  101312. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101313. * It will improve performance when the number of geometries becomes important.
  101314. */
  101315. useGeometryUniqueIdsMap?: boolean;
  101316. /**
  101317. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101318. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101319. */
  101320. useMaterialMeshMap?: boolean;
  101321. /**
  101322. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101323. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101324. */
  101325. useClonedMeshhMap?: boolean;
  101326. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101327. virtual?: boolean;
  101328. }
  101329. /**
  101330. * Represents a scene to be rendered by the engine.
  101331. * @see http://doc.babylonjs.com/features/scene
  101332. */
  101333. export class Scene extends AbstractScene implements IAnimatable {
  101334. /** The fog is deactivated */
  101335. static readonly FOGMODE_NONE: number;
  101336. /** The fog density is following an exponential function */
  101337. static readonly FOGMODE_EXP: number;
  101338. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101339. static readonly FOGMODE_EXP2: number;
  101340. /** The fog density is following a linear function. */
  101341. static readonly FOGMODE_LINEAR: number;
  101342. /**
  101343. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101344. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101345. */
  101346. static MinDeltaTime: number;
  101347. /**
  101348. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101349. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101350. */
  101351. static MaxDeltaTime: number;
  101352. /**
  101353. * Factory used to create the default material.
  101354. * @param name The name of the material to create
  101355. * @param scene The scene to create the material for
  101356. * @returns The default material
  101357. */
  101358. static DefaultMaterialFactory(scene: Scene): Material;
  101359. /**
  101360. * Factory used to create the a collision coordinator.
  101361. * @returns The collision coordinator
  101362. */
  101363. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101364. /** @hidden */
  101365. _inputManager: InputManager;
  101366. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101367. cameraToUseForPointers: Nullable<Camera>;
  101368. /** @hidden */
  101369. readonly _isScene: boolean;
  101370. /**
  101371. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101372. */
  101373. autoClear: boolean;
  101374. /**
  101375. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101376. */
  101377. autoClearDepthAndStencil: boolean;
  101378. /**
  101379. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101380. */
  101381. clearColor: Color4;
  101382. /**
  101383. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101384. */
  101385. ambientColor: Color3;
  101386. /**
  101387. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101388. * It should only be one of the following (if not the default embedded one):
  101389. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101390. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101391. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101392. * The material properties need to be setup according to the type of texture in use.
  101393. */
  101394. environmentBRDFTexture: BaseTexture;
  101395. /** @hidden */
  101396. protected _environmentTexture: Nullable<BaseTexture>;
  101397. /**
  101398. * Texture used in all pbr material as the reflection texture.
  101399. * As in the majority of the scene they are the same (exception for multi room and so on),
  101400. * this is easier to reference from here than from all the materials.
  101401. */
  101402. /**
  101403. * Texture used in all pbr material as the reflection texture.
  101404. * As in the majority of the scene they are the same (exception for multi room and so on),
  101405. * this is easier to set here than in all the materials.
  101406. */
  101407. environmentTexture: Nullable<BaseTexture>;
  101408. /** @hidden */
  101409. protected _environmentIntensity: number;
  101410. /**
  101411. * Intensity of the environment in all pbr material.
  101412. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101413. * As in the majority of the scene they are the same (exception for multi room and so on),
  101414. * this is easier to reference from here than from all the materials.
  101415. */
  101416. /**
  101417. * Intensity of the environment in all pbr material.
  101418. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101419. * As in the majority of the scene they are the same (exception for multi room and so on),
  101420. * this is easier to set here than in all the materials.
  101421. */
  101422. environmentIntensity: number;
  101423. /** @hidden */
  101424. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101425. /**
  101426. * Default image processing configuration used either in the rendering
  101427. * Forward main pass or through the imageProcessingPostProcess if present.
  101428. * As in the majority of the scene they are the same (exception for multi camera),
  101429. * this is easier to reference from here than from all the materials and post process.
  101430. *
  101431. * No setter as we it is a shared configuration, you can set the values instead.
  101432. */
  101433. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101434. private _forceWireframe;
  101435. /**
  101436. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101437. */
  101438. forceWireframe: boolean;
  101439. private _forcePointsCloud;
  101440. /**
  101441. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101442. */
  101443. forcePointsCloud: boolean;
  101444. /**
  101445. * Gets or sets the active clipplane 1
  101446. */
  101447. clipPlane: Nullable<Plane>;
  101448. /**
  101449. * Gets or sets the active clipplane 2
  101450. */
  101451. clipPlane2: Nullable<Plane>;
  101452. /**
  101453. * Gets or sets the active clipplane 3
  101454. */
  101455. clipPlane3: Nullable<Plane>;
  101456. /**
  101457. * Gets or sets the active clipplane 4
  101458. */
  101459. clipPlane4: Nullable<Plane>;
  101460. /**
  101461. * Gets or sets a boolean indicating if animations are enabled
  101462. */
  101463. animationsEnabled: boolean;
  101464. private _animationPropertiesOverride;
  101465. /**
  101466. * Gets or sets the animation properties override
  101467. */
  101468. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101469. /**
  101470. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101471. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101472. */
  101473. useConstantAnimationDeltaTime: boolean;
  101474. /**
  101475. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101476. * Please note that it requires to run a ray cast through the scene on every frame
  101477. */
  101478. constantlyUpdateMeshUnderPointer: boolean;
  101479. /**
  101480. * Defines the HTML cursor to use when hovering over interactive elements
  101481. */
  101482. hoverCursor: string;
  101483. /**
  101484. * Defines the HTML default cursor to use (empty by default)
  101485. */
  101486. defaultCursor: string;
  101487. /**
  101488. * Defines wether cursors are handled by the scene.
  101489. */
  101490. doNotHandleCursors: boolean;
  101491. /**
  101492. * This is used to call preventDefault() on pointer down
  101493. * in order to block unwanted artifacts like system double clicks
  101494. */
  101495. preventDefaultOnPointerDown: boolean;
  101496. /**
  101497. * This is used to call preventDefault() on pointer up
  101498. * in order to block unwanted artifacts like system double clicks
  101499. */
  101500. preventDefaultOnPointerUp: boolean;
  101501. /**
  101502. * Gets or sets user defined metadata
  101503. */
  101504. metadata: any;
  101505. /**
  101506. * For internal use only. Please do not use.
  101507. */
  101508. reservedDataStore: any;
  101509. /**
  101510. * Gets the name of the plugin used to load this scene (null by default)
  101511. */
  101512. loadingPluginName: string;
  101513. /**
  101514. * Use this array to add regular expressions used to disable offline support for specific urls
  101515. */
  101516. disableOfflineSupportExceptionRules: RegExp[];
  101517. /**
  101518. * An event triggered when the scene is disposed.
  101519. */
  101520. onDisposeObservable: Observable<Scene>;
  101521. private _onDisposeObserver;
  101522. /** Sets a function to be executed when this scene is disposed. */
  101523. onDispose: () => void;
  101524. /**
  101525. * An event triggered before rendering the scene (right after animations and physics)
  101526. */
  101527. onBeforeRenderObservable: Observable<Scene>;
  101528. private _onBeforeRenderObserver;
  101529. /** Sets a function to be executed before rendering this scene */
  101530. beforeRender: Nullable<() => void>;
  101531. /**
  101532. * An event triggered after rendering the scene
  101533. */
  101534. onAfterRenderObservable: Observable<Scene>;
  101535. /**
  101536. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101537. */
  101538. onAfterRenderCameraObservable: Observable<Camera>;
  101539. private _onAfterRenderObserver;
  101540. /** Sets a function to be executed after rendering this scene */
  101541. afterRender: Nullable<() => void>;
  101542. /**
  101543. * An event triggered before animating the scene
  101544. */
  101545. onBeforeAnimationsObservable: Observable<Scene>;
  101546. /**
  101547. * An event triggered after animations processing
  101548. */
  101549. onAfterAnimationsObservable: Observable<Scene>;
  101550. /**
  101551. * An event triggered before draw calls are ready to be sent
  101552. */
  101553. onBeforeDrawPhaseObservable: Observable<Scene>;
  101554. /**
  101555. * An event triggered after draw calls have been sent
  101556. */
  101557. onAfterDrawPhaseObservable: Observable<Scene>;
  101558. /**
  101559. * An event triggered when the scene is ready
  101560. */
  101561. onReadyObservable: Observable<Scene>;
  101562. /**
  101563. * An event triggered before rendering a camera
  101564. */
  101565. onBeforeCameraRenderObservable: Observable<Camera>;
  101566. private _onBeforeCameraRenderObserver;
  101567. /** Sets a function to be executed before rendering a camera*/
  101568. beforeCameraRender: () => void;
  101569. /**
  101570. * An event triggered after rendering a camera
  101571. */
  101572. onAfterCameraRenderObservable: Observable<Camera>;
  101573. private _onAfterCameraRenderObserver;
  101574. /** Sets a function to be executed after rendering a camera*/
  101575. afterCameraRender: () => void;
  101576. /**
  101577. * An event triggered when active meshes evaluation is about to start
  101578. */
  101579. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101580. /**
  101581. * An event triggered when active meshes evaluation is done
  101582. */
  101583. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101584. /**
  101585. * An event triggered when particles rendering is about to start
  101586. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101587. */
  101588. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101589. /**
  101590. * An event triggered when particles rendering is done
  101591. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101592. */
  101593. onAfterParticlesRenderingObservable: Observable<Scene>;
  101594. /**
  101595. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101596. */
  101597. onDataLoadedObservable: Observable<Scene>;
  101598. /**
  101599. * An event triggered when a camera is created
  101600. */
  101601. onNewCameraAddedObservable: Observable<Camera>;
  101602. /**
  101603. * An event triggered when a camera is removed
  101604. */
  101605. onCameraRemovedObservable: Observable<Camera>;
  101606. /**
  101607. * An event triggered when a light is created
  101608. */
  101609. onNewLightAddedObservable: Observable<Light>;
  101610. /**
  101611. * An event triggered when a light is removed
  101612. */
  101613. onLightRemovedObservable: Observable<Light>;
  101614. /**
  101615. * An event triggered when a geometry is created
  101616. */
  101617. onNewGeometryAddedObservable: Observable<Geometry>;
  101618. /**
  101619. * An event triggered when a geometry is removed
  101620. */
  101621. onGeometryRemovedObservable: Observable<Geometry>;
  101622. /**
  101623. * An event triggered when a transform node is created
  101624. */
  101625. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101626. /**
  101627. * An event triggered when a transform node is removed
  101628. */
  101629. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101630. /**
  101631. * An event triggered when a mesh is created
  101632. */
  101633. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101634. /**
  101635. * An event triggered when a mesh is removed
  101636. */
  101637. onMeshRemovedObservable: Observable<AbstractMesh>;
  101638. /**
  101639. * An event triggered when a skeleton is created
  101640. */
  101641. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101642. /**
  101643. * An event triggered when a skeleton is removed
  101644. */
  101645. onSkeletonRemovedObservable: Observable<Skeleton>;
  101646. /**
  101647. * An event triggered when a material is created
  101648. */
  101649. onNewMaterialAddedObservable: Observable<Material>;
  101650. /**
  101651. * An event triggered when a material is removed
  101652. */
  101653. onMaterialRemovedObservable: Observable<Material>;
  101654. /**
  101655. * An event triggered when a texture is created
  101656. */
  101657. onNewTextureAddedObservable: Observable<BaseTexture>;
  101658. /**
  101659. * An event triggered when a texture is removed
  101660. */
  101661. onTextureRemovedObservable: Observable<BaseTexture>;
  101662. /**
  101663. * An event triggered when render targets are about to be rendered
  101664. * Can happen multiple times per frame.
  101665. */
  101666. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101667. /**
  101668. * An event triggered when render targets were rendered.
  101669. * Can happen multiple times per frame.
  101670. */
  101671. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101672. /**
  101673. * An event triggered before calculating deterministic simulation step
  101674. */
  101675. onBeforeStepObservable: Observable<Scene>;
  101676. /**
  101677. * An event triggered after calculating deterministic simulation step
  101678. */
  101679. onAfterStepObservable: Observable<Scene>;
  101680. /**
  101681. * An event triggered when the activeCamera property is updated
  101682. */
  101683. onActiveCameraChanged: Observable<Scene>;
  101684. /**
  101685. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101686. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101687. * 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)
  101688. */
  101689. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101690. /**
  101691. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101692. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101693. * 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)
  101694. */
  101695. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101696. /**
  101697. * This Observable will when a mesh has been imported into the scene.
  101698. */
  101699. onMeshImportedObservable: Observable<AbstractMesh>;
  101700. /**
  101701. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101702. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101703. */
  101704. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101705. /** @hidden */
  101706. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101707. /**
  101708. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101709. */
  101710. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101711. /**
  101712. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101713. */
  101714. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101715. /**
  101716. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101717. */
  101718. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101719. /** Callback called when a pointer move is detected */
  101720. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101721. /** Callback called when a pointer down is detected */
  101722. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101723. /** Callback called when a pointer up is detected */
  101724. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101725. /** Callback called when a pointer pick is detected */
  101726. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101727. /**
  101728. * 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).
  101729. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101730. */
  101731. onPrePointerObservable: Observable<PointerInfoPre>;
  101732. /**
  101733. * Observable event triggered each time an input event is received from the rendering canvas
  101734. */
  101735. onPointerObservable: Observable<PointerInfo>;
  101736. /**
  101737. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101738. */
  101739. readonly unTranslatedPointer: Vector2;
  101740. /**
  101741. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101742. */
  101743. static DragMovementThreshold: number;
  101744. /**
  101745. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101746. */
  101747. static LongPressDelay: number;
  101748. /**
  101749. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101750. */
  101751. static DoubleClickDelay: number;
  101752. /** If you need to check double click without raising a single click at first click, enable this flag */
  101753. static ExclusiveDoubleClickMode: boolean;
  101754. /** @hidden */
  101755. _mirroredCameraPosition: Nullable<Vector3>;
  101756. /**
  101757. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101758. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101759. */
  101760. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  101761. /**
  101762. * Observable event triggered each time an keyboard event is received from the hosting window
  101763. */
  101764. onKeyboardObservable: Observable<KeyboardInfo>;
  101765. private _useRightHandedSystem;
  101766. /**
  101767. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  101768. */
  101769. useRightHandedSystem: boolean;
  101770. private _timeAccumulator;
  101771. private _currentStepId;
  101772. private _currentInternalStep;
  101773. /**
  101774. * Sets the step Id used by deterministic lock step
  101775. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101776. * @param newStepId defines the step Id
  101777. */
  101778. setStepId(newStepId: number): void;
  101779. /**
  101780. * Gets the step Id used by deterministic lock step
  101781. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101782. * @returns the step Id
  101783. */
  101784. getStepId(): number;
  101785. /**
  101786. * Gets the internal step used by deterministic lock step
  101787. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101788. * @returns the internal step
  101789. */
  101790. getInternalStep(): number;
  101791. private _fogEnabled;
  101792. /**
  101793. * Gets or sets a boolean indicating if fog is enabled on this scene
  101794. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101795. * (Default is true)
  101796. */
  101797. fogEnabled: boolean;
  101798. private _fogMode;
  101799. /**
  101800. * Gets or sets the fog mode to use
  101801. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101802. * | mode | value |
  101803. * | --- | --- |
  101804. * | FOGMODE_NONE | 0 |
  101805. * | FOGMODE_EXP | 1 |
  101806. * | FOGMODE_EXP2 | 2 |
  101807. * | FOGMODE_LINEAR | 3 |
  101808. */
  101809. fogMode: number;
  101810. /**
  101811. * Gets or sets the fog color to use
  101812. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101813. * (Default is Color3(0.2, 0.2, 0.3))
  101814. */
  101815. fogColor: Color3;
  101816. /**
  101817. * Gets or sets the fog density to use
  101818. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101819. * (Default is 0.1)
  101820. */
  101821. fogDensity: number;
  101822. /**
  101823. * Gets or sets the fog start distance to use
  101824. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101825. * (Default is 0)
  101826. */
  101827. fogStart: number;
  101828. /**
  101829. * Gets or sets the fog end distance to use
  101830. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101831. * (Default is 1000)
  101832. */
  101833. fogEnd: number;
  101834. private _shadowsEnabled;
  101835. /**
  101836. * Gets or sets a boolean indicating if shadows are enabled on this scene
  101837. */
  101838. shadowsEnabled: boolean;
  101839. private _lightsEnabled;
  101840. /**
  101841. * Gets or sets a boolean indicating if lights are enabled on this scene
  101842. */
  101843. lightsEnabled: boolean;
  101844. /** All of the active cameras added to this scene. */
  101845. activeCameras: Camera[];
  101846. /** @hidden */
  101847. _activeCamera: Nullable<Camera>;
  101848. /** Gets or sets the current active camera */
  101849. activeCamera: Nullable<Camera>;
  101850. private _defaultMaterial;
  101851. /** The default material used on meshes when no material is affected */
  101852. /** The default material used on meshes when no material is affected */
  101853. defaultMaterial: Material;
  101854. private _texturesEnabled;
  101855. /**
  101856. * Gets or sets a boolean indicating if textures are enabled on this scene
  101857. */
  101858. texturesEnabled: boolean;
  101859. /**
  101860. * Gets or sets a boolean indicating if particles are enabled on this scene
  101861. */
  101862. particlesEnabled: boolean;
  101863. /**
  101864. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101865. */
  101866. spritesEnabled: boolean;
  101867. private _skeletonsEnabled;
  101868. /**
  101869. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101870. */
  101871. skeletonsEnabled: boolean;
  101872. /**
  101873. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101874. */
  101875. lensFlaresEnabled: boolean;
  101876. /**
  101877. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101878. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101879. */
  101880. collisionsEnabled: boolean;
  101881. private _collisionCoordinator;
  101882. /** @hidden */
  101883. readonly collisionCoordinator: ICollisionCoordinator;
  101884. /**
  101885. * Defines the gravity applied to this scene (used only for collisions)
  101886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101887. */
  101888. gravity: Vector3;
  101889. /**
  101890. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101891. */
  101892. postProcessesEnabled: boolean;
  101893. /**
  101894. * The list of postprocesses added to the scene
  101895. */
  101896. postProcesses: PostProcess[];
  101897. /**
  101898. * Gets the current postprocess manager
  101899. */
  101900. postProcessManager: PostProcessManager;
  101901. /**
  101902. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101903. */
  101904. renderTargetsEnabled: boolean;
  101905. /**
  101906. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101907. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101908. */
  101909. dumpNextRenderTargets: boolean;
  101910. /**
  101911. * The list of user defined render targets added to the scene
  101912. */
  101913. customRenderTargets: RenderTargetTexture[];
  101914. /**
  101915. * Defines if texture loading must be delayed
  101916. * If true, textures will only be loaded when they need to be rendered
  101917. */
  101918. useDelayedTextureLoading: boolean;
  101919. /**
  101920. * Gets the list of meshes imported to the scene through SceneLoader
  101921. */
  101922. importedMeshesFiles: String[];
  101923. /**
  101924. * Gets or sets a boolean indicating if probes are enabled on this scene
  101925. */
  101926. probesEnabled: boolean;
  101927. /**
  101928. * Gets or sets the current offline provider to use to store scene data
  101929. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101930. */
  101931. offlineProvider: IOfflineProvider;
  101932. /**
  101933. * Gets or sets the action manager associated with the scene
  101934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101935. */
  101936. actionManager: AbstractActionManager;
  101937. private _meshesForIntersections;
  101938. /**
  101939. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101940. */
  101941. proceduralTexturesEnabled: boolean;
  101942. private _engine;
  101943. private _totalVertices;
  101944. /** @hidden */
  101945. _activeIndices: PerfCounter;
  101946. /** @hidden */
  101947. _activeParticles: PerfCounter;
  101948. /** @hidden */
  101949. _activeBones: PerfCounter;
  101950. private _animationRatio;
  101951. /** @hidden */
  101952. _animationTimeLast: number;
  101953. /** @hidden */
  101954. _animationTime: number;
  101955. /**
  101956. * Gets or sets a general scale for animation speed
  101957. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101958. */
  101959. animationTimeScale: number;
  101960. /** @hidden */
  101961. _cachedMaterial: Nullable<Material>;
  101962. /** @hidden */
  101963. _cachedEffect: Nullable<Effect>;
  101964. /** @hidden */
  101965. _cachedVisibility: Nullable<number>;
  101966. private _renderId;
  101967. private _frameId;
  101968. private _executeWhenReadyTimeoutId;
  101969. private _intermediateRendering;
  101970. private _viewUpdateFlag;
  101971. private _projectionUpdateFlag;
  101972. /** @hidden */
  101973. _toBeDisposed: Nullable<IDisposable>[];
  101974. private _activeRequests;
  101975. /** @hidden */
  101976. _pendingData: any[];
  101977. private _isDisposed;
  101978. /**
  101979. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101980. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101981. */
  101982. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101983. private _activeMeshes;
  101984. private _processedMaterials;
  101985. private _renderTargets;
  101986. /** @hidden */
  101987. _activeParticleSystems: SmartArray<IParticleSystem>;
  101988. private _activeSkeletons;
  101989. private _softwareSkinnedMeshes;
  101990. private _renderingManager;
  101991. /** @hidden */
  101992. _activeAnimatables: Animatable[];
  101993. private _transformMatrix;
  101994. private _sceneUbo;
  101995. /** @hidden */
  101996. _viewMatrix: Matrix;
  101997. private _projectionMatrix;
  101998. /** @hidden */
  101999. _forcedViewPosition: Nullable<Vector3>;
  102000. /** @hidden */
  102001. _frustumPlanes: Plane[];
  102002. /**
  102003. * Gets the list of frustum planes (built from the active camera)
  102004. */
  102005. readonly frustumPlanes: Plane[];
  102006. /**
  102007. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102008. * This is useful if there are more lights that the maximum simulteanous authorized
  102009. */
  102010. requireLightSorting: boolean;
  102011. /** @hidden */
  102012. readonly useMaterialMeshMap: boolean;
  102013. /** @hidden */
  102014. readonly useClonedMeshhMap: boolean;
  102015. private _externalData;
  102016. private _uid;
  102017. /**
  102018. * @hidden
  102019. * Backing store of defined scene components.
  102020. */
  102021. _components: ISceneComponent[];
  102022. /**
  102023. * @hidden
  102024. * Backing store of defined scene components.
  102025. */
  102026. _serializableComponents: ISceneSerializableComponent[];
  102027. /**
  102028. * List of components to register on the next registration step.
  102029. */
  102030. private _transientComponents;
  102031. /**
  102032. * Registers the transient components if needed.
  102033. */
  102034. private _registerTransientComponents;
  102035. /**
  102036. * @hidden
  102037. * Add a component to the scene.
  102038. * Note that the ccomponent could be registered on th next frame if this is called after
  102039. * the register component stage.
  102040. * @param component Defines the component to add to the scene
  102041. */
  102042. _addComponent(component: ISceneComponent): void;
  102043. /**
  102044. * @hidden
  102045. * Gets a component from the scene.
  102046. * @param name defines the name of the component to retrieve
  102047. * @returns the component or null if not present
  102048. */
  102049. _getComponent(name: string): Nullable<ISceneComponent>;
  102050. /**
  102051. * @hidden
  102052. * Defines the actions happening before camera updates.
  102053. */
  102054. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102055. /**
  102056. * @hidden
  102057. * Defines the actions happening before clear the canvas.
  102058. */
  102059. _beforeClearStage: Stage<SimpleStageAction>;
  102060. /**
  102061. * @hidden
  102062. * Defines the actions when collecting render targets for the frame.
  102063. */
  102064. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102065. /**
  102066. * @hidden
  102067. * Defines the actions happening for one camera in the frame.
  102068. */
  102069. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102070. /**
  102071. * @hidden
  102072. * Defines the actions happening during the per mesh ready checks.
  102073. */
  102074. _isReadyForMeshStage: Stage<MeshStageAction>;
  102075. /**
  102076. * @hidden
  102077. * Defines the actions happening before evaluate active mesh checks.
  102078. */
  102079. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102080. /**
  102081. * @hidden
  102082. * Defines the actions happening during the evaluate sub mesh checks.
  102083. */
  102084. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102085. /**
  102086. * @hidden
  102087. * Defines the actions happening during the active mesh stage.
  102088. */
  102089. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102090. /**
  102091. * @hidden
  102092. * Defines the actions happening during the per camera render target step.
  102093. */
  102094. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102095. /**
  102096. * @hidden
  102097. * Defines the actions happening just before the active camera is drawing.
  102098. */
  102099. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102100. /**
  102101. * @hidden
  102102. * Defines the actions happening just before a render target is drawing.
  102103. */
  102104. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102105. /**
  102106. * @hidden
  102107. * Defines the actions happening just before a rendering group is drawing.
  102108. */
  102109. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102110. /**
  102111. * @hidden
  102112. * Defines the actions happening just before a mesh is drawing.
  102113. */
  102114. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102115. /**
  102116. * @hidden
  102117. * Defines the actions happening just after a mesh has been drawn.
  102118. */
  102119. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102120. /**
  102121. * @hidden
  102122. * Defines the actions happening just after a rendering group has been drawn.
  102123. */
  102124. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102125. /**
  102126. * @hidden
  102127. * Defines the actions happening just after the active camera has been drawn.
  102128. */
  102129. _afterCameraDrawStage: Stage<CameraStageAction>;
  102130. /**
  102131. * @hidden
  102132. * Defines the actions happening just after a render target has been drawn.
  102133. */
  102134. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102135. /**
  102136. * @hidden
  102137. * Defines the actions happening just after rendering all cameras and computing intersections.
  102138. */
  102139. _afterRenderStage: Stage<SimpleStageAction>;
  102140. /**
  102141. * @hidden
  102142. * Defines the actions happening when a pointer move event happens.
  102143. */
  102144. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102145. /**
  102146. * @hidden
  102147. * Defines the actions happening when a pointer down event happens.
  102148. */
  102149. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102150. /**
  102151. * @hidden
  102152. * Defines the actions happening when a pointer up event happens.
  102153. */
  102154. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102155. /**
  102156. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102157. */
  102158. private geometriesByUniqueId;
  102159. /**
  102160. * Creates a new Scene
  102161. * @param engine defines the engine to use to render this scene
  102162. * @param options defines the scene options
  102163. */
  102164. constructor(engine: Engine, options?: SceneOptions);
  102165. /**
  102166. * Gets a string idenfifying the name of the class
  102167. * @returns "Scene" string
  102168. */
  102169. getClassName(): string;
  102170. private _defaultMeshCandidates;
  102171. /**
  102172. * @hidden
  102173. */
  102174. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102175. private _defaultSubMeshCandidates;
  102176. /**
  102177. * @hidden
  102178. */
  102179. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102180. /**
  102181. * Sets the default candidate providers for the scene.
  102182. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102183. * and getCollidingSubMeshCandidates to their default function
  102184. */
  102185. setDefaultCandidateProviders(): void;
  102186. /**
  102187. * Gets the mesh that is currently under the pointer
  102188. */
  102189. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102190. /**
  102191. * Gets or sets the current on-screen X position of the pointer
  102192. */
  102193. pointerX: number;
  102194. /**
  102195. * Gets or sets the current on-screen Y position of the pointer
  102196. */
  102197. pointerY: number;
  102198. /**
  102199. * Gets the cached material (ie. the latest rendered one)
  102200. * @returns the cached material
  102201. */
  102202. getCachedMaterial(): Nullable<Material>;
  102203. /**
  102204. * Gets the cached effect (ie. the latest rendered one)
  102205. * @returns the cached effect
  102206. */
  102207. getCachedEffect(): Nullable<Effect>;
  102208. /**
  102209. * Gets the cached visibility state (ie. the latest rendered one)
  102210. * @returns the cached visibility state
  102211. */
  102212. getCachedVisibility(): Nullable<number>;
  102213. /**
  102214. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102215. * @param material defines the current material
  102216. * @param effect defines the current effect
  102217. * @param visibility defines the current visibility state
  102218. * @returns true if one parameter is not cached
  102219. */
  102220. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102221. /**
  102222. * Gets the engine associated with the scene
  102223. * @returns an Engine
  102224. */
  102225. getEngine(): Engine;
  102226. /**
  102227. * Gets the total number of vertices rendered per frame
  102228. * @returns the total number of vertices rendered per frame
  102229. */
  102230. getTotalVertices(): number;
  102231. /**
  102232. * Gets the performance counter for total vertices
  102233. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102234. */
  102235. readonly totalVerticesPerfCounter: PerfCounter;
  102236. /**
  102237. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102238. * @returns the total number of active indices rendered per frame
  102239. */
  102240. getActiveIndices(): number;
  102241. /**
  102242. * Gets the performance counter for active indices
  102243. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102244. */
  102245. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102246. /**
  102247. * Gets the total number of active particles rendered per frame
  102248. * @returns the total number of active particles rendered per frame
  102249. */
  102250. getActiveParticles(): number;
  102251. /**
  102252. * Gets the performance counter for active particles
  102253. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102254. */
  102255. readonly activeParticlesPerfCounter: PerfCounter;
  102256. /**
  102257. * Gets the total number of active bones rendered per frame
  102258. * @returns the total number of active bones rendered per frame
  102259. */
  102260. getActiveBones(): number;
  102261. /**
  102262. * Gets the performance counter for active bones
  102263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102264. */
  102265. readonly activeBonesPerfCounter: PerfCounter;
  102266. /**
  102267. * Gets the array of active meshes
  102268. * @returns an array of AbstractMesh
  102269. */
  102270. getActiveMeshes(): SmartArray<AbstractMesh>;
  102271. /**
  102272. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102273. * @returns a number
  102274. */
  102275. getAnimationRatio(): number;
  102276. /**
  102277. * Gets an unique Id for the current render phase
  102278. * @returns a number
  102279. */
  102280. getRenderId(): number;
  102281. /**
  102282. * Gets an unique Id for the current frame
  102283. * @returns a number
  102284. */
  102285. getFrameId(): number;
  102286. /** Call this function if you want to manually increment the render Id*/
  102287. incrementRenderId(): void;
  102288. private _createUbo;
  102289. /**
  102290. * Use this method to simulate a pointer move on a mesh
  102291. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102292. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102293. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102294. * @returns the current scene
  102295. */
  102296. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102297. /**
  102298. * Use this method to simulate a pointer down on a mesh
  102299. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102300. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102301. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102302. * @returns the current scene
  102303. */
  102304. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102305. /**
  102306. * Use this method to simulate a pointer up on a mesh
  102307. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102308. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102309. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102310. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102311. * @returns the current scene
  102312. */
  102313. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102314. /**
  102315. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102316. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102317. * @returns true if the pointer was captured
  102318. */
  102319. isPointerCaptured(pointerId?: number): boolean;
  102320. /**
  102321. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102322. * @param attachUp defines if you want to attach events to pointerup
  102323. * @param attachDown defines if you want to attach events to pointerdown
  102324. * @param attachMove defines if you want to attach events to pointermove
  102325. */
  102326. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102327. /** Detaches all event handlers*/
  102328. detachControl(): void;
  102329. /**
  102330. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102331. * Delay loaded resources are not taking in account
  102332. * @return true if all required resources are ready
  102333. */
  102334. isReady(): boolean;
  102335. /** Resets all cached information relative to material (including effect and visibility) */
  102336. resetCachedMaterial(): void;
  102337. /**
  102338. * Registers a function to be called before every frame render
  102339. * @param func defines the function to register
  102340. */
  102341. registerBeforeRender(func: () => void): void;
  102342. /**
  102343. * Unregisters a function called before every frame render
  102344. * @param func defines the function to unregister
  102345. */
  102346. unregisterBeforeRender(func: () => void): void;
  102347. /**
  102348. * Registers a function to be called after every frame render
  102349. * @param func defines the function to register
  102350. */
  102351. registerAfterRender(func: () => void): void;
  102352. /**
  102353. * Unregisters a function called after every frame render
  102354. * @param func defines the function to unregister
  102355. */
  102356. unregisterAfterRender(func: () => void): void;
  102357. private _executeOnceBeforeRender;
  102358. /**
  102359. * The provided function will run before render once and will be disposed afterwards.
  102360. * A timeout delay can be provided so that the function will be executed in N ms.
  102361. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102362. * @param func The function to be executed.
  102363. * @param timeout optional delay in ms
  102364. */
  102365. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102366. /** @hidden */
  102367. _addPendingData(data: any): void;
  102368. /** @hidden */
  102369. _removePendingData(data: any): void;
  102370. /**
  102371. * Returns the number of items waiting to be loaded
  102372. * @returns the number of items waiting to be loaded
  102373. */
  102374. getWaitingItemsCount(): number;
  102375. /**
  102376. * Returns a boolean indicating if the scene is still loading data
  102377. */
  102378. readonly isLoading: boolean;
  102379. /**
  102380. * Registers a function to be executed when the scene is ready
  102381. * @param {Function} func - the function to be executed
  102382. */
  102383. executeWhenReady(func: () => void): void;
  102384. /**
  102385. * Returns a promise that resolves when the scene is ready
  102386. * @returns A promise that resolves when the scene is ready
  102387. */
  102388. whenReadyAsync(): Promise<void>;
  102389. /** @hidden */
  102390. _checkIsReady(): void;
  102391. /**
  102392. * Gets all animatable attached to the scene
  102393. */
  102394. readonly animatables: Animatable[];
  102395. /**
  102396. * Resets the last animation time frame.
  102397. * Useful to override when animations start running when loading a scene for the first time.
  102398. */
  102399. resetLastAnimationTimeFrame(): void;
  102400. /**
  102401. * Gets the current view matrix
  102402. * @returns a Matrix
  102403. */
  102404. getViewMatrix(): Matrix;
  102405. /**
  102406. * Gets the current projection matrix
  102407. * @returns a Matrix
  102408. */
  102409. getProjectionMatrix(): Matrix;
  102410. /**
  102411. * Gets the current transform matrix
  102412. * @returns a Matrix made of View * Projection
  102413. */
  102414. getTransformMatrix(): Matrix;
  102415. /**
  102416. * Sets the current transform matrix
  102417. * @param viewL defines the View matrix to use
  102418. * @param projectionL defines the Projection matrix to use
  102419. * @param viewR defines the right View matrix to use (if provided)
  102420. * @param projectionR defines the right Projection matrix to use (if provided)
  102421. */
  102422. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102423. /**
  102424. * Gets the uniform buffer used to store scene data
  102425. * @returns a UniformBuffer
  102426. */
  102427. getSceneUniformBuffer(): UniformBuffer;
  102428. /**
  102429. * Gets an unique (relatively to the current scene) Id
  102430. * @returns an unique number for the scene
  102431. */
  102432. getUniqueId(): number;
  102433. /**
  102434. * Add a mesh to the list of scene's meshes
  102435. * @param newMesh defines the mesh to add
  102436. * @param recursive if all child meshes should also be added to the scene
  102437. */
  102438. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102439. /**
  102440. * Remove a mesh for the list of scene's meshes
  102441. * @param toRemove defines the mesh to remove
  102442. * @param recursive if all child meshes should also be removed from the scene
  102443. * @returns the index where the mesh was in the mesh list
  102444. */
  102445. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102446. /**
  102447. * Add a transform node to the list of scene's transform nodes
  102448. * @param newTransformNode defines the transform node to add
  102449. */
  102450. addTransformNode(newTransformNode: TransformNode): void;
  102451. /**
  102452. * Remove a transform node for the list of scene's transform nodes
  102453. * @param toRemove defines the transform node to remove
  102454. * @returns the index where the transform node was in the transform node list
  102455. */
  102456. removeTransformNode(toRemove: TransformNode): number;
  102457. /**
  102458. * Remove a skeleton for the list of scene's skeletons
  102459. * @param toRemove defines the skeleton to remove
  102460. * @returns the index where the skeleton was in the skeleton list
  102461. */
  102462. removeSkeleton(toRemove: Skeleton): number;
  102463. /**
  102464. * Remove a morph target for the list of scene's morph targets
  102465. * @param toRemove defines the morph target to remove
  102466. * @returns the index where the morph target was in the morph target list
  102467. */
  102468. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102469. /**
  102470. * Remove a light for the list of scene's lights
  102471. * @param toRemove defines the light to remove
  102472. * @returns the index where the light was in the light list
  102473. */
  102474. removeLight(toRemove: Light): number;
  102475. /**
  102476. * Remove a camera for the list of scene's cameras
  102477. * @param toRemove defines the camera to remove
  102478. * @returns the index where the camera was in the camera list
  102479. */
  102480. removeCamera(toRemove: Camera): number;
  102481. /**
  102482. * Remove a particle system for the list of scene's particle systems
  102483. * @param toRemove defines the particle system to remove
  102484. * @returns the index where the particle system was in the particle system list
  102485. */
  102486. removeParticleSystem(toRemove: IParticleSystem): number;
  102487. /**
  102488. * Remove a animation for the list of scene's animations
  102489. * @param toRemove defines the animation to remove
  102490. * @returns the index where the animation was in the animation list
  102491. */
  102492. removeAnimation(toRemove: Animation): number;
  102493. /**
  102494. * Will stop the animation of the given target
  102495. * @param target - the target
  102496. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102497. * @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)
  102498. */
  102499. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102500. /**
  102501. * Removes the given animation group from this scene.
  102502. * @param toRemove The animation group to remove
  102503. * @returns The index of the removed animation group
  102504. */
  102505. removeAnimationGroup(toRemove: AnimationGroup): number;
  102506. /**
  102507. * Removes the given multi-material from this scene.
  102508. * @param toRemove The multi-material to remove
  102509. * @returns The index of the removed multi-material
  102510. */
  102511. removeMultiMaterial(toRemove: MultiMaterial): number;
  102512. /**
  102513. * Removes the given material from this scene.
  102514. * @param toRemove The material to remove
  102515. * @returns The index of the removed material
  102516. */
  102517. removeMaterial(toRemove: Material): number;
  102518. /**
  102519. * Removes the given action manager from this scene.
  102520. * @param toRemove The action manager to remove
  102521. * @returns The index of the removed action manager
  102522. */
  102523. removeActionManager(toRemove: AbstractActionManager): number;
  102524. /**
  102525. * Removes the given texture from this scene.
  102526. * @param toRemove The texture to remove
  102527. * @returns The index of the removed texture
  102528. */
  102529. removeTexture(toRemove: BaseTexture): number;
  102530. /**
  102531. * Adds the given light to this scene
  102532. * @param newLight The light to add
  102533. */
  102534. addLight(newLight: Light): void;
  102535. /**
  102536. * Sorts the list list based on light priorities
  102537. */
  102538. sortLightsByPriority(): void;
  102539. /**
  102540. * Adds the given camera to this scene
  102541. * @param newCamera The camera to add
  102542. */
  102543. addCamera(newCamera: Camera): void;
  102544. /**
  102545. * Adds the given skeleton to this scene
  102546. * @param newSkeleton The skeleton to add
  102547. */
  102548. addSkeleton(newSkeleton: Skeleton): void;
  102549. /**
  102550. * Adds the given particle system to this scene
  102551. * @param newParticleSystem The particle system to add
  102552. */
  102553. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102554. /**
  102555. * Adds the given animation to this scene
  102556. * @param newAnimation The animation to add
  102557. */
  102558. addAnimation(newAnimation: Animation): void;
  102559. /**
  102560. * Adds the given animation group to this scene.
  102561. * @param newAnimationGroup The animation group to add
  102562. */
  102563. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102564. /**
  102565. * Adds the given multi-material to this scene
  102566. * @param newMultiMaterial The multi-material to add
  102567. */
  102568. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102569. /**
  102570. * Adds the given material to this scene
  102571. * @param newMaterial The material to add
  102572. */
  102573. addMaterial(newMaterial: Material): void;
  102574. /**
  102575. * Adds the given morph target to this scene
  102576. * @param newMorphTargetManager The morph target to add
  102577. */
  102578. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102579. /**
  102580. * Adds the given geometry to this scene
  102581. * @param newGeometry The geometry to add
  102582. */
  102583. addGeometry(newGeometry: Geometry): void;
  102584. /**
  102585. * Adds the given action manager to this scene
  102586. * @param newActionManager The action manager to add
  102587. */
  102588. addActionManager(newActionManager: AbstractActionManager): void;
  102589. /**
  102590. * Adds the given texture to this scene.
  102591. * @param newTexture The texture to add
  102592. */
  102593. addTexture(newTexture: BaseTexture): void;
  102594. /**
  102595. * Switch active camera
  102596. * @param newCamera defines the new active camera
  102597. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102598. */
  102599. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102600. /**
  102601. * sets the active camera of the scene using its ID
  102602. * @param id defines the camera's ID
  102603. * @return the new active camera or null if none found.
  102604. */
  102605. setActiveCameraByID(id: string): Nullable<Camera>;
  102606. /**
  102607. * sets the active camera of the scene using its name
  102608. * @param name defines the camera's name
  102609. * @returns the new active camera or null if none found.
  102610. */
  102611. setActiveCameraByName(name: string): Nullable<Camera>;
  102612. /**
  102613. * get an animation group using its name
  102614. * @param name defines the material's name
  102615. * @return the animation group or null if none found.
  102616. */
  102617. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102618. /**
  102619. * Get a material using its unique id
  102620. * @param uniqueId defines the material's unique id
  102621. * @return the material or null if none found.
  102622. */
  102623. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102624. /**
  102625. * get a material using its id
  102626. * @param id defines the material's ID
  102627. * @return the material or null if none found.
  102628. */
  102629. getMaterialByID(id: string): Nullable<Material>;
  102630. /**
  102631. * Gets a the last added material using a given id
  102632. * @param id defines the material's ID
  102633. * @return the last material with the given id or null if none found.
  102634. */
  102635. getLastMaterialByID(id: string): Nullable<Material>;
  102636. /**
  102637. * Gets a material using its name
  102638. * @param name defines the material's name
  102639. * @return the material or null if none found.
  102640. */
  102641. getMaterialByName(name: string): Nullable<Material>;
  102642. /**
  102643. * Get a texture using its unique id
  102644. * @param uniqueId defines the texture's unique id
  102645. * @return the texture or null if none found.
  102646. */
  102647. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102648. /**
  102649. * Gets a camera using its id
  102650. * @param id defines the id to look for
  102651. * @returns the camera or null if not found
  102652. */
  102653. getCameraByID(id: string): Nullable<Camera>;
  102654. /**
  102655. * Gets a camera using its unique id
  102656. * @param uniqueId defines the unique id to look for
  102657. * @returns the camera or null if not found
  102658. */
  102659. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102660. /**
  102661. * Gets a camera using its name
  102662. * @param name defines the camera's name
  102663. * @return the camera or null if none found.
  102664. */
  102665. getCameraByName(name: string): Nullable<Camera>;
  102666. /**
  102667. * Gets a bone using its id
  102668. * @param id defines the bone's id
  102669. * @return the bone or null if not found
  102670. */
  102671. getBoneByID(id: string): Nullable<Bone>;
  102672. /**
  102673. * Gets a bone using its id
  102674. * @param name defines the bone's name
  102675. * @return the bone or null if not found
  102676. */
  102677. getBoneByName(name: string): Nullable<Bone>;
  102678. /**
  102679. * Gets a light node using its name
  102680. * @param name defines the the light's name
  102681. * @return the light or null if none found.
  102682. */
  102683. getLightByName(name: string): Nullable<Light>;
  102684. /**
  102685. * Gets a light node using its id
  102686. * @param id defines the light's id
  102687. * @return the light or null if none found.
  102688. */
  102689. getLightByID(id: string): Nullable<Light>;
  102690. /**
  102691. * Gets a light node using its scene-generated unique ID
  102692. * @param uniqueId defines the light's unique id
  102693. * @return the light or null if none found.
  102694. */
  102695. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102696. /**
  102697. * Gets a particle system by id
  102698. * @param id defines the particle system id
  102699. * @return the corresponding system or null if none found
  102700. */
  102701. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102702. /**
  102703. * Gets a geometry using its ID
  102704. * @param id defines the geometry's id
  102705. * @return the geometry or null if none found.
  102706. */
  102707. getGeometryByID(id: string): Nullable<Geometry>;
  102708. private _getGeometryByUniqueID;
  102709. /**
  102710. * Add a new geometry to this scene
  102711. * @param geometry defines the geometry to be added to the scene.
  102712. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102713. * @return a boolean defining if the geometry was added or not
  102714. */
  102715. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102716. /**
  102717. * Removes an existing geometry
  102718. * @param geometry defines the geometry to be removed from the scene
  102719. * @return a boolean defining if the geometry was removed or not
  102720. */
  102721. removeGeometry(geometry: Geometry): boolean;
  102722. /**
  102723. * Gets the list of geometries attached to the scene
  102724. * @returns an array of Geometry
  102725. */
  102726. getGeometries(): Geometry[];
  102727. /**
  102728. * Gets the first added mesh found of a given ID
  102729. * @param id defines the id to search for
  102730. * @return the mesh found or null if not found at all
  102731. */
  102732. getMeshByID(id: string): Nullable<AbstractMesh>;
  102733. /**
  102734. * Gets a list of meshes using their id
  102735. * @param id defines the id to search for
  102736. * @returns a list of meshes
  102737. */
  102738. getMeshesByID(id: string): Array<AbstractMesh>;
  102739. /**
  102740. * Gets the first added transform node found of a given ID
  102741. * @param id defines the id to search for
  102742. * @return the found transform node or null if not found at all.
  102743. */
  102744. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102745. /**
  102746. * Gets a transform node with its auto-generated unique id
  102747. * @param uniqueId efines the unique id to search for
  102748. * @return the found transform node or null if not found at all.
  102749. */
  102750. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102751. /**
  102752. * Gets a list of transform nodes using their id
  102753. * @param id defines the id to search for
  102754. * @returns a list of transform nodes
  102755. */
  102756. getTransformNodesByID(id: string): Array<TransformNode>;
  102757. /**
  102758. * Gets a mesh with its auto-generated unique id
  102759. * @param uniqueId defines the unique id to search for
  102760. * @return the found mesh or null if not found at all.
  102761. */
  102762. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  102763. /**
  102764. * Gets a the last added mesh using a given id
  102765. * @param id defines the id to search for
  102766. * @return the found mesh or null if not found at all.
  102767. */
  102768. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  102769. /**
  102770. * Gets a the last added node (Mesh, Camera, Light) using a given id
  102771. * @param id defines the id to search for
  102772. * @return the found node or null if not found at all
  102773. */
  102774. getLastEntryByID(id: string): Nullable<Node>;
  102775. /**
  102776. * Gets a node (Mesh, Camera, Light) using a given id
  102777. * @param id defines the id to search for
  102778. * @return the found node or null if not found at all
  102779. */
  102780. getNodeByID(id: string): Nullable<Node>;
  102781. /**
  102782. * Gets a node (Mesh, Camera, Light) using a given name
  102783. * @param name defines the name to search for
  102784. * @return the found node or null if not found at all.
  102785. */
  102786. getNodeByName(name: string): Nullable<Node>;
  102787. /**
  102788. * Gets a mesh using a given name
  102789. * @param name defines the name to search for
  102790. * @return the found mesh or null if not found at all.
  102791. */
  102792. getMeshByName(name: string): Nullable<AbstractMesh>;
  102793. /**
  102794. * Gets a transform node using a given name
  102795. * @param name defines the name to search for
  102796. * @return the found transform node or null if not found at all.
  102797. */
  102798. getTransformNodeByName(name: string): Nullable<TransformNode>;
  102799. /**
  102800. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  102801. * @param id defines the id to search for
  102802. * @return the found skeleton or null if not found at all.
  102803. */
  102804. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  102805. /**
  102806. * Gets a skeleton using a given auto generated unique id
  102807. * @param uniqueId defines the unique id to search for
  102808. * @return the found skeleton or null if not found at all.
  102809. */
  102810. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  102811. /**
  102812. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  102813. * @param id defines the id to search for
  102814. * @return the found skeleton or null if not found at all.
  102815. */
  102816. getSkeletonById(id: string): Nullable<Skeleton>;
  102817. /**
  102818. * Gets a skeleton using a given name
  102819. * @param name defines the name to search for
  102820. * @return the found skeleton or null if not found at all.
  102821. */
  102822. getSkeletonByName(name: string): Nullable<Skeleton>;
  102823. /**
  102824. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  102825. * @param id defines the id to search for
  102826. * @return the found morph target manager or null if not found at all.
  102827. */
  102828. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  102829. /**
  102830. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  102831. * @param id defines the id to search for
  102832. * @return the found morph target or null if not found at all.
  102833. */
  102834. getMorphTargetById(id: string): Nullable<MorphTarget>;
  102835. /**
  102836. * Gets a boolean indicating if the given mesh is active
  102837. * @param mesh defines the mesh to look for
  102838. * @returns true if the mesh is in the active list
  102839. */
  102840. isActiveMesh(mesh: AbstractMesh): boolean;
  102841. /**
  102842. * Return a unique id as a string which can serve as an identifier for the scene
  102843. */
  102844. readonly uid: string;
  102845. /**
  102846. * Add an externaly attached data from its key.
  102847. * This method call will fail and return false, if such key already exists.
  102848. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102849. * @param key the unique key that identifies the data
  102850. * @param data the data object to associate to the key for this Engine instance
  102851. * @return true if no such key were already present and the data was added successfully, false otherwise
  102852. */
  102853. addExternalData<T>(key: string, data: T): boolean;
  102854. /**
  102855. * Get an externaly attached data from its key
  102856. * @param key the unique key that identifies the data
  102857. * @return the associated data, if present (can be null), or undefined if not present
  102858. */
  102859. getExternalData<T>(key: string): Nullable<T>;
  102860. /**
  102861. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102862. * @param key the unique key that identifies the data
  102863. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102864. * @return the associated data, can be null if the factory returned null.
  102865. */
  102866. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102867. /**
  102868. * Remove an externaly attached data from the Engine instance
  102869. * @param key the unique key that identifies the data
  102870. * @return true if the data was successfully removed, false if it doesn't exist
  102871. */
  102872. removeExternalData(key: string): boolean;
  102873. private _evaluateSubMesh;
  102874. /**
  102875. * Clear the processed materials smart array preventing retention point in material dispose.
  102876. */
  102877. freeProcessedMaterials(): void;
  102878. private _preventFreeActiveMeshesAndRenderingGroups;
  102879. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102880. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102881. * when disposing several meshes in a row or a hierarchy of meshes.
  102882. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102883. */
  102884. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102885. /**
  102886. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102887. */
  102888. freeActiveMeshes(): void;
  102889. /**
  102890. * Clear the info related to rendering groups preventing retention points during dispose.
  102891. */
  102892. freeRenderingGroups(): void;
  102893. /** @hidden */
  102894. _isInIntermediateRendering(): boolean;
  102895. /**
  102896. * Lambda returning the list of potentially active meshes.
  102897. */
  102898. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102899. /**
  102900. * Lambda returning the list of potentially active sub meshes.
  102901. */
  102902. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102903. /**
  102904. * Lambda returning the list of potentially intersecting sub meshes.
  102905. */
  102906. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102907. /**
  102908. * Lambda returning the list of potentially colliding sub meshes.
  102909. */
  102910. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102911. private _activeMeshesFrozen;
  102912. /**
  102913. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102914. * @returns the current scene
  102915. */
  102916. freezeActiveMeshes(): Scene;
  102917. /**
  102918. * Use this function to restart evaluating active meshes on every frame
  102919. * @returns the current scene
  102920. */
  102921. unfreezeActiveMeshes(): Scene;
  102922. private _evaluateActiveMeshes;
  102923. private _activeMesh;
  102924. /**
  102925. * Update the transform matrix to update from the current active camera
  102926. * @param force defines a boolean used to force the update even if cache is up to date
  102927. */
  102928. updateTransformMatrix(force?: boolean): void;
  102929. private _bindFrameBuffer;
  102930. /** @hidden */
  102931. _allowPostProcessClearColor: boolean;
  102932. /** @hidden */
  102933. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102934. private _processSubCameras;
  102935. private _checkIntersections;
  102936. /** @hidden */
  102937. _advancePhysicsEngineStep(step: number): void;
  102938. /**
  102939. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102940. */
  102941. getDeterministicFrameTime: () => number;
  102942. /** @hidden */
  102943. _animate(): void;
  102944. /** Execute all animations (for a frame) */
  102945. animate(): void;
  102946. /**
  102947. * Render the scene
  102948. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102949. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102950. */
  102951. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102952. /**
  102953. * Freeze all materials
  102954. * A frozen material will not be updatable but should be faster to render
  102955. */
  102956. freezeMaterials(): void;
  102957. /**
  102958. * Unfreeze all materials
  102959. * A frozen material will not be updatable but should be faster to render
  102960. */
  102961. unfreezeMaterials(): void;
  102962. /**
  102963. * Releases all held ressources
  102964. */
  102965. dispose(): void;
  102966. /**
  102967. * Gets if the scene is already disposed
  102968. */
  102969. readonly isDisposed: boolean;
  102970. /**
  102971. * Call this function to reduce memory footprint of the scene.
  102972. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102973. */
  102974. clearCachedVertexData(): void;
  102975. /**
  102976. * This function will remove the local cached buffer data from texture.
  102977. * It will save memory but will prevent the texture from being rebuilt
  102978. */
  102979. cleanCachedTextureBuffer(): void;
  102980. /**
  102981. * Get the world extend vectors with an optional filter
  102982. *
  102983. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102984. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102985. */
  102986. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102987. min: Vector3;
  102988. max: Vector3;
  102989. };
  102990. /**
  102991. * Creates a ray that can be used to pick in the scene
  102992. * @param x defines the x coordinate of the origin (on-screen)
  102993. * @param y defines the y coordinate of the origin (on-screen)
  102994. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102995. * @param camera defines the camera to use for the picking
  102996. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102997. * @returns a Ray
  102998. */
  102999. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103000. /**
  103001. * Creates a ray that can be used to pick in the scene
  103002. * @param x defines the x coordinate of the origin (on-screen)
  103003. * @param y defines the y coordinate of the origin (on-screen)
  103004. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103005. * @param result defines the ray where to store the picking ray
  103006. * @param camera defines the camera to use for the picking
  103007. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103008. * @returns the current scene
  103009. */
  103010. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103011. /**
  103012. * Creates a ray that can be used to pick in the scene
  103013. * @param x defines the x coordinate of the origin (on-screen)
  103014. * @param y defines the y coordinate of the origin (on-screen)
  103015. * @param camera defines the camera to use for the picking
  103016. * @returns a Ray
  103017. */
  103018. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103019. /**
  103020. * Creates a ray that can be used to pick in the scene
  103021. * @param x defines the x coordinate of the origin (on-screen)
  103022. * @param y defines the y coordinate of the origin (on-screen)
  103023. * @param result defines the ray where to store the picking ray
  103024. * @param camera defines the camera to use for the picking
  103025. * @returns the current scene
  103026. */
  103027. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103028. /** Launch a ray to try to pick a mesh in the scene
  103029. * @param x position on screen
  103030. * @param y position on screen
  103031. * @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
  103032. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103033. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103034. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103035. * @returns a PickingInfo
  103036. */
  103037. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103038. /** Use the given ray to pick a mesh in the scene
  103039. * @param ray The ray to use to pick meshes
  103040. * @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
  103041. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103042. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103043. * @returns a PickingInfo
  103044. */
  103045. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103046. /**
  103047. * Launch a ray to try to pick a mesh in the scene
  103048. * @param x X position on screen
  103049. * @param y Y position on screen
  103050. * @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
  103051. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103052. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103053. * @returns an array of PickingInfo
  103054. */
  103055. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103056. /**
  103057. * Launch a ray to try to pick a mesh in the scene
  103058. * @param ray Ray to use
  103059. * @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
  103060. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103061. * @returns an array of PickingInfo
  103062. */
  103063. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103064. /**
  103065. * Force the value of meshUnderPointer
  103066. * @param mesh defines the mesh to use
  103067. */
  103068. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103069. /**
  103070. * Gets the mesh under the pointer
  103071. * @returns a Mesh or null if no mesh is under the pointer
  103072. */
  103073. getPointerOverMesh(): Nullable<AbstractMesh>;
  103074. /** @hidden */
  103075. _rebuildGeometries(): void;
  103076. /** @hidden */
  103077. _rebuildTextures(): void;
  103078. private _getByTags;
  103079. /**
  103080. * Get a list of meshes by tags
  103081. * @param tagsQuery defines the tags query to use
  103082. * @param forEach defines a predicate used to filter results
  103083. * @returns an array of Mesh
  103084. */
  103085. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103086. /**
  103087. * Get a list of cameras by tags
  103088. * @param tagsQuery defines the tags query to use
  103089. * @param forEach defines a predicate used to filter results
  103090. * @returns an array of Camera
  103091. */
  103092. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103093. /**
  103094. * Get a list of lights by tags
  103095. * @param tagsQuery defines the tags query to use
  103096. * @param forEach defines a predicate used to filter results
  103097. * @returns an array of Light
  103098. */
  103099. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103100. /**
  103101. * Get a list of materials by tags
  103102. * @param tagsQuery defines the tags query to use
  103103. * @param forEach defines a predicate used to filter results
  103104. * @returns an array of Material
  103105. */
  103106. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103107. /**
  103108. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103109. * This allowed control for front to back rendering or reversly depending of the special needs.
  103110. *
  103111. * @param renderingGroupId The rendering group id corresponding to its index
  103112. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103113. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103114. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103115. */
  103116. 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;
  103117. /**
  103118. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103119. *
  103120. * @param renderingGroupId The rendering group id corresponding to its index
  103121. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103122. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103123. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103124. */
  103125. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103126. /**
  103127. * Gets the current auto clear configuration for one rendering group of the rendering
  103128. * manager.
  103129. * @param index the rendering group index to get the information for
  103130. * @returns The auto clear setup for the requested rendering group
  103131. */
  103132. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103133. private _blockMaterialDirtyMechanism;
  103134. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103135. blockMaterialDirtyMechanism: boolean;
  103136. /**
  103137. * Will flag all materials as dirty to trigger new shader compilation
  103138. * @param flag defines the flag used to specify which material part must be marked as dirty
  103139. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103140. */
  103141. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103142. /** @hidden */
  103143. _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;
  103144. /** @hidden */
  103145. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103146. /** @hidden */
  103147. _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;
  103148. /** @hidden */
  103149. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103150. /** @hidden */
  103151. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103152. /** @hidden */
  103153. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103154. }
  103155. }
  103156. declare module BABYLON {
  103157. /**
  103158. * Set of assets to keep when moving a scene into an asset container.
  103159. */
  103160. export class KeepAssets extends AbstractScene {
  103161. }
  103162. /**
  103163. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103164. */
  103165. export class InstantiatedEntries {
  103166. /**
  103167. * List of new root nodes (eg. nodes with no parent)
  103168. */
  103169. rootNodes: TransformNode[];
  103170. /**
  103171. * List of new skeletons
  103172. */
  103173. skeletons: Skeleton[];
  103174. /**
  103175. * List of new animation groups
  103176. */
  103177. animationGroups: AnimationGroup[];
  103178. }
  103179. /**
  103180. * Container with a set of assets that can be added or removed from a scene.
  103181. */
  103182. export class AssetContainer extends AbstractScene {
  103183. /**
  103184. * The scene the AssetContainer belongs to.
  103185. */
  103186. scene: Scene;
  103187. /**
  103188. * Instantiates an AssetContainer.
  103189. * @param scene The scene the AssetContainer belongs to.
  103190. */
  103191. constructor(scene: Scene);
  103192. /**
  103193. * Instantiate or clone all meshes and add the new ones to the scene.
  103194. * Skeletons and animation groups will all be cloned
  103195. * @param nameFunction defines an optional function used to get new names for clones
  103196. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103197. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103198. */
  103199. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103200. /**
  103201. * Adds all the assets from the container to the scene.
  103202. */
  103203. addAllToScene(): void;
  103204. /**
  103205. * Removes all the assets in the container from the scene
  103206. */
  103207. removeAllFromScene(): void;
  103208. /**
  103209. * Disposes all the assets in the container
  103210. */
  103211. dispose(): void;
  103212. private _moveAssets;
  103213. /**
  103214. * Removes all the assets contained in the scene and adds them to the container.
  103215. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103216. */
  103217. moveAllFromScene(keepAssets?: KeepAssets): void;
  103218. /**
  103219. * 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.
  103220. * @returns the root mesh
  103221. */
  103222. createRootMesh(): Mesh;
  103223. }
  103224. }
  103225. declare module BABYLON {
  103226. /**
  103227. * Defines how the parser contract is defined.
  103228. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103229. */
  103230. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103231. /**
  103232. * Defines how the individual parser contract is defined.
  103233. * These parser can parse an individual asset
  103234. */
  103235. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103236. /**
  103237. * Base class of the scene acting as a container for the different elements composing a scene.
  103238. * This class is dynamically extended by the different components of the scene increasing
  103239. * flexibility and reducing coupling
  103240. */
  103241. export abstract class AbstractScene {
  103242. /**
  103243. * Stores the list of available parsers in the application.
  103244. */
  103245. private static _BabylonFileParsers;
  103246. /**
  103247. * Stores the list of available individual parsers in the application.
  103248. */
  103249. private static _IndividualBabylonFileParsers;
  103250. /**
  103251. * Adds a parser in the list of available ones
  103252. * @param name Defines the name of the parser
  103253. * @param parser Defines the parser to add
  103254. */
  103255. static AddParser(name: string, parser: BabylonFileParser): void;
  103256. /**
  103257. * Gets a general parser from the list of avaialble ones
  103258. * @param name Defines the name of the parser
  103259. * @returns the requested parser or null
  103260. */
  103261. static GetParser(name: string): Nullable<BabylonFileParser>;
  103262. /**
  103263. * Adds n individual parser in the list of available ones
  103264. * @param name Defines the name of the parser
  103265. * @param parser Defines the parser to add
  103266. */
  103267. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103268. /**
  103269. * Gets an individual parser from the list of avaialble ones
  103270. * @param name Defines the name of the parser
  103271. * @returns the requested parser or null
  103272. */
  103273. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103274. /**
  103275. * Parser json data and populate both a scene and its associated container object
  103276. * @param jsonData Defines the data to parse
  103277. * @param scene Defines the scene to parse the data for
  103278. * @param container Defines the container attached to the parsing sequence
  103279. * @param rootUrl Defines the root url of the data
  103280. */
  103281. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103282. /**
  103283. * Gets the list of root nodes (ie. nodes with no parent)
  103284. */
  103285. rootNodes: Node[];
  103286. /** All of the cameras added to this scene
  103287. * @see http://doc.babylonjs.com/babylon101/cameras
  103288. */
  103289. cameras: Camera[];
  103290. /**
  103291. * All of the lights added to this scene
  103292. * @see http://doc.babylonjs.com/babylon101/lights
  103293. */
  103294. lights: Light[];
  103295. /**
  103296. * All of the (abstract) meshes added to this scene
  103297. */
  103298. meshes: AbstractMesh[];
  103299. /**
  103300. * The list of skeletons added to the scene
  103301. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103302. */
  103303. skeletons: Skeleton[];
  103304. /**
  103305. * All of the particle systems added to this scene
  103306. * @see http://doc.babylonjs.com/babylon101/particles
  103307. */
  103308. particleSystems: IParticleSystem[];
  103309. /**
  103310. * Gets a list of Animations associated with the scene
  103311. */
  103312. animations: Animation[];
  103313. /**
  103314. * All of the animation groups added to this scene
  103315. * @see http://doc.babylonjs.com/how_to/group
  103316. */
  103317. animationGroups: AnimationGroup[];
  103318. /**
  103319. * All of the multi-materials added to this scene
  103320. * @see http://doc.babylonjs.com/how_to/multi_materials
  103321. */
  103322. multiMaterials: MultiMaterial[];
  103323. /**
  103324. * All of the materials added to this scene
  103325. * In the context of a Scene, it is not supposed to be modified manually.
  103326. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103327. * Note also that the order of the Material within the array is not significant and might change.
  103328. * @see http://doc.babylonjs.com/babylon101/materials
  103329. */
  103330. materials: Material[];
  103331. /**
  103332. * The list of morph target managers added to the scene
  103333. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103334. */
  103335. morphTargetManagers: MorphTargetManager[];
  103336. /**
  103337. * The list of geometries used in the scene.
  103338. */
  103339. geometries: Geometry[];
  103340. /**
  103341. * All of the tranform nodes added to this scene
  103342. * In the context of a Scene, it is not supposed to be modified manually.
  103343. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103344. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103345. * @see http://doc.babylonjs.com/how_to/transformnode
  103346. */
  103347. transformNodes: TransformNode[];
  103348. /**
  103349. * ActionManagers available on the scene.
  103350. */
  103351. actionManagers: AbstractActionManager[];
  103352. /**
  103353. * Textures to keep.
  103354. */
  103355. textures: BaseTexture[];
  103356. /**
  103357. * Environment texture for the scene
  103358. */
  103359. environmentTexture: Nullable<BaseTexture>;
  103360. }
  103361. }
  103362. declare module BABYLON {
  103363. /**
  103364. * Interface used to define options for Sound class
  103365. */
  103366. export interface ISoundOptions {
  103367. /**
  103368. * Does the sound autoplay once loaded.
  103369. */
  103370. autoplay?: boolean;
  103371. /**
  103372. * Does the sound loop after it finishes playing once.
  103373. */
  103374. loop?: boolean;
  103375. /**
  103376. * Sound's volume
  103377. */
  103378. volume?: number;
  103379. /**
  103380. * Is it a spatial sound?
  103381. */
  103382. spatialSound?: boolean;
  103383. /**
  103384. * Maximum distance to hear that sound
  103385. */
  103386. maxDistance?: number;
  103387. /**
  103388. * Uses user defined attenuation function
  103389. */
  103390. useCustomAttenuation?: boolean;
  103391. /**
  103392. * Define the roll off factor of spatial sounds.
  103393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103394. */
  103395. rolloffFactor?: number;
  103396. /**
  103397. * Define the reference distance the sound should be heard perfectly.
  103398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103399. */
  103400. refDistance?: number;
  103401. /**
  103402. * Define the distance attenuation model the sound will follow.
  103403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103404. */
  103405. distanceModel?: string;
  103406. /**
  103407. * Defines the playback speed (1 by default)
  103408. */
  103409. playbackRate?: number;
  103410. /**
  103411. * Defines if the sound is from a streaming source
  103412. */
  103413. streaming?: boolean;
  103414. /**
  103415. * Defines an optional length (in seconds) inside the sound file
  103416. */
  103417. length?: number;
  103418. /**
  103419. * Defines an optional offset (in seconds) inside the sound file
  103420. */
  103421. offset?: number;
  103422. /**
  103423. * If true, URLs will not be required to state the audio file codec to use.
  103424. */
  103425. skipCodecCheck?: boolean;
  103426. }
  103427. /**
  103428. * Defines a sound that can be played in the application.
  103429. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103431. */
  103432. export class Sound {
  103433. /**
  103434. * The name of the sound in the scene.
  103435. */
  103436. name: string;
  103437. /**
  103438. * Does the sound autoplay once loaded.
  103439. */
  103440. autoplay: boolean;
  103441. /**
  103442. * Does the sound loop after it finishes playing once.
  103443. */
  103444. loop: boolean;
  103445. /**
  103446. * Does the sound use a custom attenuation curve to simulate the falloff
  103447. * happening when the source gets further away from the camera.
  103448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103449. */
  103450. useCustomAttenuation: boolean;
  103451. /**
  103452. * The sound track id this sound belongs to.
  103453. */
  103454. soundTrackId: number;
  103455. /**
  103456. * Is this sound currently played.
  103457. */
  103458. isPlaying: boolean;
  103459. /**
  103460. * Is this sound currently paused.
  103461. */
  103462. isPaused: boolean;
  103463. /**
  103464. * Does this sound enables spatial sound.
  103465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103466. */
  103467. spatialSound: boolean;
  103468. /**
  103469. * Define the reference distance the sound should be heard perfectly.
  103470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103471. */
  103472. refDistance: number;
  103473. /**
  103474. * Define the roll off factor of spatial sounds.
  103475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103476. */
  103477. rolloffFactor: number;
  103478. /**
  103479. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103481. */
  103482. maxDistance: number;
  103483. /**
  103484. * Define the distance attenuation model the sound will follow.
  103485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103486. */
  103487. distanceModel: string;
  103488. /**
  103489. * @hidden
  103490. * Back Compat
  103491. **/
  103492. onended: () => any;
  103493. /**
  103494. * Observable event when the current playing sound finishes.
  103495. */
  103496. onEndedObservable: Observable<Sound>;
  103497. private _panningModel;
  103498. private _playbackRate;
  103499. private _streaming;
  103500. private _startTime;
  103501. private _startOffset;
  103502. private _position;
  103503. /** @hidden */
  103504. _positionInEmitterSpace: boolean;
  103505. private _localDirection;
  103506. private _volume;
  103507. private _isReadyToPlay;
  103508. private _isDirectional;
  103509. private _readyToPlayCallback;
  103510. private _audioBuffer;
  103511. private _soundSource;
  103512. private _streamingSource;
  103513. private _soundPanner;
  103514. private _soundGain;
  103515. private _inputAudioNode;
  103516. private _outputAudioNode;
  103517. private _coneInnerAngle;
  103518. private _coneOuterAngle;
  103519. private _coneOuterGain;
  103520. private _scene;
  103521. private _connectedTransformNode;
  103522. private _customAttenuationFunction;
  103523. private _registerFunc;
  103524. private _isOutputConnected;
  103525. private _htmlAudioElement;
  103526. private _urlType;
  103527. private _length?;
  103528. private _offset?;
  103529. /** @hidden */
  103530. static _SceneComponentInitialization: (scene: Scene) => void;
  103531. /**
  103532. * Create a sound and attach it to a scene
  103533. * @param name Name of your sound
  103534. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103535. * @param scene defines the scene the sound belongs to
  103536. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103537. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103538. */
  103539. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103540. /**
  103541. * Release the sound and its associated resources
  103542. */
  103543. dispose(): void;
  103544. /**
  103545. * Gets if the sounds is ready to be played or not.
  103546. * @returns true if ready, otherwise false
  103547. */
  103548. isReady(): boolean;
  103549. private _soundLoaded;
  103550. /**
  103551. * Sets the data of the sound from an audiobuffer
  103552. * @param audioBuffer The audioBuffer containing the data
  103553. */
  103554. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103555. /**
  103556. * Updates the current sounds options such as maxdistance, loop...
  103557. * @param options A JSON object containing values named as the object properties
  103558. */
  103559. updateOptions(options: ISoundOptions): void;
  103560. private _createSpatialParameters;
  103561. private _updateSpatialParameters;
  103562. /**
  103563. * Switch the panning model to HRTF:
  103564. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103566. */
  103567. switchPanningModelToHRTF(): void;
  103568. /**
  103569. * Switch the panning model to Equal Power:
  103570. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103572. */
  103573. switchPanningModelToEqualPower(): void;
  103574. private _switchPanningModel;
  103575. /**
  103576. * Connect this sound to a sound track audio node like gain...
  103577. * @param soundTrackAudioNode the sound track audio node to connect to
  103578. */
  103579. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103580. /**
  103581. * Transform this sound into a directional source
  103582. * @param coneInnerAngle Size of the inner cone in degree
  103583. * @param coneOuterAngle Size of the outer cone in degree
  103584. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103585. */
  103586. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103587. /**
  103588. * Gets or sets the inner angle for the directional cone.
  103589. */
  103590. /**
  103591. * Gets or sets the inner angle for the directional cone.
  103592. */
  103593. directionalConeInnerAngle: number;
  103594. /**
  103595. * Gets or sets the outer angle for the directional cone.
  103596. */
  103597. /**
  103598. * Gets or sets the outer angle for the directional cone.
  103599. */
  103600. directionalConeOuterAngle: number;
  103601. /**
  103602. * Sets the position of the emitter if spatial sound is enabled
  103603. * @param newPosition Defines the new posisiton
  103604. */
  103605. setPosition(newPosition: Vector3): void;
  103606. /**
  103607. * Sets the local direction of the emitter if spatial sound is enabled
  103608. * @param newLocalDirection Defines the new local direction
  103609. */
  103610. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103611. private _updateDirection;
  103612. /** @hidden */
  103613. updateDistanceFromListener(): void;
  103614. /**
  103615. * Sets a new custom attenuation function for the sound.
  103616. * @param callback Defines the function used for the attenuation
  103617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103618. */
  103619. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103620. /**
  103621. * Play the sound
  103622. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103623. * @param offset (optional) Start the sound at a specific time in seconds
  103624. * @param length (optional) Sound duration (in seconds)
  103625. */
  103626. play(time?: number, offset?: number, length?: number): void;
  103627. private _onended;
  103628. /**
  103629. * Stop the sound
  103630. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103631. */
  103632. stop(time?: number): void;
  103633. /**
  103634. * Put the sound in pause
  103635. */
  103636. pause(): void;
  103637. /**
  103638. * Sets a dedicated volume for this sounds
  103639. * @param newVolume Define the new volume of the sound
  103640. * @param time Define time for gradual change to new volume
  103641. */
  103642. setVolume(newVolume: number, time?: number): void;
  103643. /**
  103644. * Set the sound play back rate
  103645. * @param newPlaybackRate Define the playback rate the sound should be played at
  103646. */
  103647. setPlaybackRate(newPlaybackRate: number): void;
  103648. /**
  103649. * Gets the volume of the sound.
  103650. * @returns the volume of the sound
  103651. */
  103652. getVolume(): number;
  103653. /**
  103654. * Attach the sound to a dedicated mesh
  103655. * @param transformNode The transform node to connect the sound with
  103656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103657. */
  103658. attachToMesh(transformNode: TransformNode): void;
  103659. /**
  103660. * Detach the sound from the previously attached mesh
  103661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103662. */
  103663. detachFromMesh(): void;
  103664. private _onRegisterAfterWorldMatrixUpdate;
  103665. /**
  103666. * Clone the current sound in the scene.
  103667. * @returns the new sound clone
  103668. */
  103669. clone(): Nullable<Sound>;
  103670. /**
  103671. * Gets the current underlying audio buffer containing the data
  103672. * @returns the audio buffer
  103673. */
  103674. getAudioBuffer(): Nullable<AudioBuffer>;
  103675. /**
  103676. * Serializes the Sound in a JSON representation
  103677. * @returns the JSON representation of the sound
  103678. */
  103679. serialize(): any;
  103680. /**
  103681. * Parse a JSON representation of a sound to innstantiate in a given scene
  103682. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103683. * @param scene Define the scene the new parsed sound should be created in
  103684. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103685. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103686. * @returns the newly parsed sound
  103687. */
  103688. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103689. }
  103690. }
  103691. declare module BABYLON {
  103692. /**
  103693. * This defines an action helpful to play a defined sound on a triggered action.
  103694. */
  103695. export class PlaySoundAction extends Action {
  103696. private _sound;
  103697. /**
  103698. * Instantiate the action
  103699. * @param triggerOptions defines the trigger options
  103700. * @param sound defines the sound to play
  103701. * @param condition defines the trigger related conditions
  103702. */
  103703. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103704. /** @hidden */
  103705. _prepare(): void;
  103706. /**
  103707. * Execute the action and play the sound.
  103708. */
  103709. execute(): void;
  103710. /**
  103711. * Serializes the actions and its related information.
  103712. * @param parent defines the object to serialize in
  103713. * @returns the serialized object
  103714. */
  103715. serialize(parent: any): any;
  103716. }
  103717. /**
  103718. * This defines an action helpful to stop a defined sound on a triggered action.
  103719. */
  103720. export class StopSoundAction extends Action {
  103721. private _sound;
  103722. /**
  103723. * Instantiate the action
  103724. * @param triggerOptions defines the trigger options
  103725. * @param sound defines the sound to stop
  103726. * @param condition defines the trigger related conditions
  103727. */
  103728. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103729. /** @hidden */
  103730. _prepare(): void;
  103731. /**
  103732. * Execute the action and stop the sound.
  103733. */
  103734. execute(): void;
  103735. /**
  103736. * Serializes the actions and its related information.
  103737. * @param parent defines the object to serialize in
  103738. * @returns the serialized object
  103739. */
  103740. serialize(parent: any): any;
  103741. }
  103742. }
  103743. declare module BABYLON {
  103744. /**
  103745. * This defines an action responsible to change the value of a property
  103746. * by interpolating between its current value and the newly set one once triggered.
  103747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103748. */
  103749. export class InterpolateValueAction extends Action {
  103750. /**
  103751. * Defines the path of the property where the value should be interpolated
  103752. */
  103753. propertyPath: string;
  103754. /**
  103755. * Defines the target value at the end of the interpolation.
  103756. */
  103757. value: any;
  103758. /**
  103759. * Defines the time it will take for the property to interpolate to the value.
  103760. */
  103761. duration: number;
  103762. /**
  103763. * Defines if the other scene animations should be stopped when the action has been triggered
  103764. */
  103765. stopOtherAnimations?: boolean;
  103766. /**
  103767. * Defines a callback raised once the interpolation animation has been done.
  103768. */
  103769. onInterpolationDone?: () => void;
  103770. /**
  103771. * Observable triggered once the interpolation animation has been done.
  103772. */
  103773. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  103774. private _target;
  103775. private _effectiveTarget;
  103776. private _property;
  103777. /**
  103778. * Instantiate the action
  103779. * @param triggerOptions defines the trigger options
  103780. * @param target defines the object containing the value to interpolate
  103781. * @param propertyPath defines the path to the property in the target object
  103782. * @param value defines the target value at the end of the interpolation
  103783. * @param duration deines the time it will take for the property to interpolate to the value.
  103784. * @param condition defines the trigger related conditions
  103785. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  103786. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  103787. */
  103788. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  103789. /** @hidden */
  103790. _prepare(): void;
  103791. /**
  103792. * Execute the action starts the value interpolation.
  103793. */
  103794. execute(): void;
  103795. /**
  103796. * Serializes the actions and its related information.
  103797. * @param parent defines the object to serialize in
  103798. * @returns the serialized object
  103799. */
  103800. serialize(parent: any): any;
  103801. }
  103802. }
  103803. declare module BABYLON {
  103804. /**
  103805. * Options allowed during the creation of a sound track.
  103806. */
  103807. export interface ISoundTrackOptions {
  103808. /**
  103809. * The volume the sound track should take during creation
  103810. */
  103811. volume?: number;
  103812. /**
  103813. * Define if the sound track is the main sound track of the scene
  103814. */
  103815. mainTrack?: boolean;
  103816. }
  103817. /**
  103818. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  103819. * It will be also used in a future release to apply effects on a specific track.
  103820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103821. */
  103822. export class SoundTrack {
  103823. /**
  103824. * The unique identifier of the sound track in the scene.
  103825. */
  103826. id: number;
  103827. /**
  103828. * The list of sounds included in the sound track.
  103829. */
  103830. soundCollection: Array<Sound>;
  103831. private _outputAudioNode;
  103832. private _scene;
  103833. private _connectedAnalyser;
  103834. private _options;
  103835. private _isInitialized;
  103836. /**
  103837. * Creates a new sound track.
  103838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103839. * @param scene Define the scene the sound track belongs to
  103840. * @param options
  103841. */
  103842. constructor(scene: Scene, options?: ISoundTrackOptions);
  103843. private _initializeSoundTrackAudioGraph;
  103844. /**
  103845. * Release the sound track and its associated resources
  103846. */
  103847. dispose(): void;
  103848. /**
  103849. * Adds a sound to this sound track
  103850. * @param sound define the cound to add
  103851. * @ignoreNaming
  103852. */
  103853. AddSound(sound: Sound): void;
  103854. /**
  103855. * Removes a sound to this sound track
  103856. * @param sound define the cound to remove
  103857. * @ignoreNaming
  103858. */
  103859. RemoveSound(sound: Sound): void;
  103860. /**
  103861. * Set a global volume for the full sound track.
  103862. * @param newVolume Define the new volume of the sound track
  103863. */
  103864. setVolume(newVolume: number): void;
  103865. /**
  103866. * Switch the panning model to HRTF:
  103867. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103869. */
  103870. switchPanningModelToHRTF(): void;
  103871. /**
  103872. * Switch the panning model to Equal Power:
  103873. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103875. */
  103876. switchPanningModelToEqualPower(): void;
  103877. /**
  103878. * Connect the sound track to an audio analyser allowing some amazing
  103879. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103881. * @param analyser The analyser to connect to the engine
  103882. */
  103883. connectToAnalyser(analyser: Analyser): void;
  103884. }
  103885. }
  103886. declare module BABYLON {
  103887. interface AbstractScene {
  103888. /**
  103889. * The list of sounds used in the scene.
  103890. */
  103891. sounds: Nullable<Array<Sound>>;
  103892. }
  103893. interface Scene {
  103894. /**
  103895. * @hidden
  103896. * Backing field
  103897. */
  103898. _mainSoundTrack: SoundTrack;
  103899. /**
  103900. * The main sound track played by the scene.
  103901. * It cotains your primary collection of sounds.
  103902. */
  103903. mainSoundTrack: SoundTrack;
  103904. /**
  103905. * The list of sound tracks added to the scene
  103906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103907. */
  103908. soundTracks: Nullable<Array<SoundTrack>>;
  103909. /**
  103910. * Gets a sound using a given name
  103911. * @param name defines the name to search for
  103912. * @return the found sound or null if not found at all.
  103913. */
  103914. getSoundByName(name: string): Nullable<Sound>;
  103915. /**
  103916. * Gets or sets if audio support is enabled
  103917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103918. */
  103919. audioEnabled: boolean;
  103920. /**
  103921. * Gets or sets if audio will be output to headphones
  103922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103923. */
  103924. headphone: boolean;
  103925. /**
  103926. * Gets or sets custom audio listener position provider
  103927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103928. */
  103929. audioListenerPositionProvider: Nullable<() => Vector3>;
  103930. /**
  103931. * Gets or sets a refresh rate when using 3D audio positioning
  103932. */
  103933. audioPositioningRefreshRate: number;
  103934. }
  103935. /**
  103936. * Defines the sound scene component responsible to manage any sounds
  103937. * in a given scene.
  103938. */
  103939. export class AudioSceneComponent implements ISceneSerializableComponent {
  103940. /**
  103941. * The component name helpfull to identify the component in the list of scene components.
  103942. */
  103943. readonly name: string;
  103944. /**
  103945. * The scene the component belongs to.
  103946. */
  103947. scene: Scene;
  103948. private _audioEnabled;
  103949. /**
  103950. * Gets whether audio is enabled or not.
  103951. * Please use related enable/disable method to switch state.
  103952. */
  103953. readonly audioEnabled: boolean;
  103954. private _headphone;
  103955. /**
  103956. * Gets whether audio is outputing to headphone or not.
  103957. * Please use the according Switch methods to change output.
  103958. */
  103959. readonly headphone: boolean;
  103960. /**
  103961. * Gets or sets a refresh rate when using 3D audio positioning
  103962. */
  103963. audioPositioningRefreshRate: number;
  103964. private _audioListenerPositionProvider;
  103965. /**
  103966. * Gets the current audio listener position provider
  103967. */
  103968. /**
  103969. * Sets a custom listener position for all sounds in the scene
  103970. * By default, this is the position of the first active camera
  103971. */
  103972. audioListenerPositionProvider: Nullable<() => Vector3>;
  103973. /**
  103974. * Creates a new instance of the component for the given scene
  103975. * @param scene Defines the scene to register the component in
  103976. */
  103977. constructor(scene: Scene);
  103978. /**
  103979. * Registers the component in a given scene
  103980. */
  103981. register(): void;
  103982. /**
  103983. * Rebuilds the elements related to this component in case of
  103984. * context lost for instance.
  103985. */
  103986. rebuild(): void;
  103987. /**
  103988. * Serializes the component data to the specified json object
  103989. * @param serializationObject The object to serialize to
  103990. */
  103991. serialize(serializationObject: any): void;
  103992. /**
  103993. * Adds all the elements from the container to the scene
  103994. * @param container the container holding the elements
  103995. */
  103996. addFromContainer(container: AbstractScene): void;
  103997. /**
  103998. * Removes all the elements in the container from the scene
  103999. * @param container contains the elements to remove
  104000. * @param dispose if the removed element should be disposed (default: false)
  104001. */
  104002. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104003. /**
  104004. * Disposes the component and the associated ressources.
  104005. */
  104006. dispose(): void;
  104007. /**
  104008. * Disables audio in the associated scene.
  104009. */
  104010. disableAudio(): void;
  104011. /**
  104012. * Enables audio in the associated scene.
  104013. */
  104014. enableAudio(): void;
  104015. /**
  104016. * Switch audio to headphone output.
  104017. */
  104018. switchAudioModeForHeadphones(): void;
  104019. /**
  104020. * Switch audio to normal speakers.
  104021. */
  104022. switchAudioModeForNormalSpeakers(): void;
  104023. private _cachedCameraDirection;
  104024. private _cachedCameraPosition;
  104025. private _lastCheck;
  104026. private _afterRender;
  104027. }
  104028. }
  104029. declare module BABYLON {
  104030. /**
  104031. * Wraps one or more Sound objects and selects one with random weight for playback.
  104032. */
  104033. export class WeightedSound {
  104034. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104035. loop: boolean;
  104036. private _coneInnerAngle;
  104037. private _coneOuterAngle;
  104038. private _volume;
  104039. /** A Sound is currently playing. */
  104040. isPlaying: boolean;
  104041. /** A Sound is currently paused. */
  104042. isPaused: boolean;
  104043. private _sounds;
  104044. private _weights;
  104045. private _currentIndex?;
  104046. /**
  104047. * Creates a new WeightedSound from the list of sounds given.
  104048. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104049. * @param sounds Array of Sounds that will be selected from.
  104050. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104051. */
  104052. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104053. /**
  104054. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104055. */
  104056. /**
  104057. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104058. */
  104059. directionalConeInnerAngle: number;
  104060. /**
  104061. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104062. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104063. */
  104064. /**
  104065. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104066. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104067. */
  104068. directionalConeOuterAngle: number;
  104069. /**
  104070. * Playback volume.
  104071. */
  104072. /**
  104073. * Playback volume.
  104074. */
  104075. volume: number;
  104076. private _onended;
  104077. /**
  104078. * Suspend playback
  104079. */
  104080. pause(): void;
  104081. /**
  104082. * Stop playback
  104083. */
  104084. stop(): void;
  104085. /**
  104086. * Start playback.
  104087. * @param startOffset Position the clip head at a specific time in seconds.
  104088. */
  104089. play(startOffset?: number): void;
  104090. }
  104091. }
  104092. declare module BABYLON {
  104093. /**
  104094. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104095. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104096. */
  104097. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104098. /**
  104099. * Gets the name of the behavior.
  104100. */
  104101. readonly name: string;
  104102. /**
  104103. * The easing function used by animations
  104104. */
  104105. static EasingFunction: BackEase;
  104106. /**
  104107. * The easing mode used by animations
  104108. */
  104109. static EasingMode: number;
  104110. /**
  104111. * The duration of the animation, in milliseconds
  104112. */
  104113. transitionDuration: number;
  104114. /**
  104115. * Length of the distance animated by the transition when lower radius is reached
  104116. */
  104117. lowerRadiusTransitionRange: number;
  104118. /**
  104119. * Length of the distance animated by the transition when upper radius is reached
  104120. */
  104121. upperRadiusTransitionRange: number;
  104122. private _autoTransitionRange;
  104123. /**
  104124. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104125. */
  104126. /**
  104127. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104128. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104129. */
  104130. autoTransitionRange: boolean;
  104131. private _attachedCamera;
  104132. private _onAfterCheckInputsObserver;
  104133. private _onMeshTargetChangedObserver;
  104134. /**
  104135. * Initializes the behavior.
  104136. */
  104137. init(): void;
  104138. /**
  104139. * Attaches the behavior to its arc rotate camera.
  104140. * @param camera Defines the camera to attach the behavior to
  104141. */
  104142. attach(camera: ArcRotateCamera): void;
  104143. /**
  104144. * Detaches the behavior from its current arc rotate camera.
  104145. */
  104146. detach(): void;
  104147. private _radiusIsAnimating;
  104148. private _radiusBounceTransition;
  104149. private _animatables;
  104150. private _cachedWheelPrecision;
  104151. /**
  104152. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104153. * @param radiusLimit The limit to check against.
  104154. * @return Bool to indicate if at limit.
  104155. */
  104156. private _isRadiusAtLimit;
  104157. /**
  104158. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104159. * @param radiusDelta The delta by which to animate to. Can be negative.
  104160. */
  104161. private _applyBoundRadiusAnimation;
  104162. /**
  104163. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104164. */
  104165. protected _clearAnimationLocks(): void;
  104166. /**
  104167. * Stops and removes all animations that have been applied to the camera
  104168. */
  104169. stopAllAnimations(): void;
  104170. }
  104171. }
  104172. declare module BABYLON {
  104173. /**
  104174. * 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.
  104175. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104176. */
  104177. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104178. /**
  104179. * Gets the name of the behavior.
  104180. */
  104181. readonly name: string;
  104182. private _mode;
  104183. private _radiusScale;
  104184. private _positionScale;
  104185. private _defaultElevation;
  104186. private _elevationReturnTime;
  104187. private _elevationReturnWaitTime;
  104188. private _zoomStopsAnimation;
  104189. private _framingTime;
  104190. /**
  104191. * The easing function used by animations
  104192. */
  104193. static EasingFunction: ExponentialEase;
  104194. /**
  104195. * The easing mode used by animations
  104196. */
  104197. static EasingMode: number;
  104198. /**
  104199. * Sets the current mode used by the behavior
  104200. */
  104201. /**
  104202. * Gets current mode used by the behavior.
  104203. */
  104204. mode: number;
  104205. /**
  104206. * Sets the scale applied to the radius (1 by default)
  104207. */
  104208. /**
  104209. * Gets the scale applied to the radius
  104210. */
  104211. radiusScale: number;
  104212. /**
  104213. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104214. */
  104215. /**
  104216. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104217. */
  104218. positionScale: number;
  104219. /**
  104220. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104221. * behaviour is triggered, in radians.
  104222. */
  104223. /**
  104224. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104225. * behaviour is triggered, in radians.
  104226. */
  104227. defaultElevation: number;
  104228. /**
  104229. * Sets the time (in milliseconds) taken to return to the default beta position.
  104230. * Negative value indicates camera should not return to default.
  104231. */
  104232. /**
  104233. * Gets the time (in milliseconds) taken to return to the default beta position.
  104234. * Negative value indicates camera should not return to default.
  104235. */
  104236. elevationReturnTime: number;
  104237. /**
  104238. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104239. */
  104240. /**
  104241. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104242. */
  104243. elevationReturnWaitTime: number;
  104244. /**
  104245. * Sets the flag that indicates if user zooming should stop animation.
  104246. */
  104247. /**
  104248. * Gets the flag that indicates if user zooming should stop animation.
  104249. */
  104250. zoomStopsAnimation: boolean;
  104251. /**
  104252. * Sets the transition time when framing the mesh, in milliseconds
  104253. */
  104254. /**
  104255. * Gets the transition time when framing the mesh, in milliseconds
  104256. */
  104257. framingTime: number;
  104258. /**
  104259. * Define if the behavior should automatically change the configured
  104260. * camera limits and sensibilities.
  104261. */
  104262. autoCorrectCameraLimitsAndSensibility: boolean;
  104263. private _onPrePointerObservableObserver;
  104264. private _onAfterCheckInputsObserver;
  104265. private _onMeshTargetChangedObserver;
  104266. private _attachedCamera;
  104267. private _isPointerDown;
  104268. private _lastInteractionTime;
  104269. /**
  104270. * Initializes the behavior.
  104271. */
  104272. init(): void;
  104273. /**
  104274. * Attaches the behavior to its arc rotate camera.
  104275. * @param camera Defines the camera to attach the behavior to
  104276. */
  104277. attach(camera: ArcRotateCamera): void;
  104278. /**
  104279. * Detaches the behavior from its current arc rotate camera.
  104280. */
  104281. detach(): void;
  104282. private _animatables;
  104283. private _betaIsAnimating;
  104284. private _betaTransition;
  104285. private _radiusTransition;
  104286. private _vectorTransition;
  104287. /**
  104288. * Targets the given mesh and updates zoom level accordingly.
  104289. * @param mesh The mesh to target.
  104290. * @param radius Optional. If a cached radius position already exists, overrides default.
  104291. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104292. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104293. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104294. */
  104295. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104296. /**
  104297. * Targets the given mesh with its children and updates zoom level accordingly.
  104298. * @param mesh The mesh to target.
  104299. * @param radius Optional. If a cached radius position already exists, overrides default.
  104300. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104301. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104302. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104303. */
  104304. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104305. /**
  104306. * Targets the given meshes with their children and updates zoom level accordingly.
  104307. * @param meshes The mesh to target.
  104308. * @param radius Optional. If a cached radius position already exists, overrides default.
  104309. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104310. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104311. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104312. */
  104313. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104314. /**
  104315. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104316. * @param minimumWorld Determines the smaller position of the bounding box extend
  104317. * @param maximumWorld Determines the bigger position of the bounding box extend
  104318. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104319. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104320. */
  104321. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104322. /**
  104323. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104324. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104325. * frustum width.
  104326. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104327. * to fully enclose the mesh in the viewing frustum.
  104328. */
  104329. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104330. /**
  104331. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104332. * is automatically returned to its default position (expected to be above ground plane).
  104333. */
  104334. private _maintainCameraAboveGround;
  104335. /**
  104336. * Returns the frustum slope based on the canvas ratio and camera FOV
  104337. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104338. */
  104339. private _getFrustumSlope;
  104340. /**
  104341. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104342. */
  104343. private _clearAnimationLocks;
  104344. /**
  104345. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104346. */
  104347. private _applyUserInteraction;
  104348. /**
  104349. * Stops and removes all animations that have been applied to the camera
  104350. */
  104351. stopAllAnimations(): void;
  104352. /**
  104353. * Gets a value indicating if the user is moving the camera
  104354. */
  104355. readonly isUserIsMoving: boolean;
  104356. /**
  104357. * The camera can move all the way towards the mesh.
  104358. */
  104359. static IgnoreBoundsSizeMode: number;
  104360. /**
  104361. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104362. */
  104363. static FitFrustumSidesMode: number;
  104364. }
  104365. }
  104366. declare module BABYLON {
  104367. /**
  104368. * Base class for Camera Pointer Inputs.
  104369. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104370. * for example usage.
  104371. */
  104372. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104373. /**
  104374. * Defines the camera the input is attached to.
  104375. */
  104376. abstract camera: Camera;
  104377. /**
  104378. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104379. */
  104380. protected _altKey: boolean;
  104381. protected _ctrlKey: boolean;
  104382. protected _metaKey: boolean;
  104383. protected _shiftKey: boolean;
  104384. /**
  104385. * Which mouse buttons were pressed at time of last mouse event.
  104386. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104387. */
  104388. protected _buttonsPressed: number;
  104389. /**
  104390. * Defines the buttons associated with the input to handle camera move.
  104391. */
  104392. buttons: number[];
  104393. /**
  104394. * Attach the input controls to a specific dom element to get the input from.
  104395. * @param element Defines the element the controls should be listened from
  104396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104397. */
  104398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104399. /**
  104400. * Detach the current controls from the specified dom element.
  104401. * @param element Defines the element to stop listening the inputs from
  104402. */
  104403. detachControl(element: Nullable<HTMLElement>): void;
  104404. /**
  104405. * Gets the class name of the current input.
  104406. * @returns the class name
  104407. */
  104408. getClassName(): string;
  104409. /**
  104410. * Get the friendly name associated with the input class.
  104411. * @returns the input friendly name
  104412. */
  104413. getSimpleName(): string;
  104414. /**
  104415. * Called on pointer POINTERDOUBLETAP event.
  104416. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104417. */
  104418. protected onDoubleTap(type: string): void;
  104419. /**
  104420. * Called on pointer POINTERMOVE event if only a single touch is active.
  104421. * Override this method to provide functionality.
  104422. */
  104423. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104424. /**
  104425. * Called on pointer POINTERMOVE event if multiple touches are active.
  104426. * Override this method to provide functionality.
  104427. */
  104428. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104429. /**
  104430. * Called on JS contextmenu event.
  104431. * Override this method to provide functionality.
  104432. */
  104433. protected onContextMenu(evt: PointerEvent): void;
  104434. /**
  104435. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104436. * press.
  104437. * Override this method to provide functionality.
  104438. */
  104439. protected onButtonDown(evt: PointerEvent): void;
  104440. /**
  104441. * Called each time a new POINTERUP event occurs. Ie, for each button
  104442. * release.
  104443. * Override this method to provide functionality.
  104444. */
  104445. protected onButtonUp(evt: PointerEvent): void;
  104446. /**
  104447. * Called when window becomes inactive.
  104448. * Override this method to provide functionality.
  104449. */
  104450. protected onLostFocus(): void;
  104451. private _pointerInput;
  104452. private _observer;
  104453. private _onLostFocus;
  104454. private pointA;
  104455. private pointB;
  104456. }
  104457. }
  104458. declare module BABYLON {
  104459. /**
  104460. * Manage the pointers inputs to control an arc rotate camera.
  104461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104462. */
  104463. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104464. /**
  104465. * Defines the camera the input is attached to.
  104466. */
  104467. camera: ArcRotateCamera;
  104468. /**
  104469. * Gets the class name of the current input.
  104470. * @returns the class name
  104471. */
  104472. getClassName(): string;
  104473. /**
  104474. * Defines the buttons associated with the input to handle camera move.
  104475. */
  104476. buttons: number[];
  104477. /**
  104478. * Defines the pointer angular sensibility along the X axis or how fast is
  104479. * the camera rotating.
  104480. */
  104481. angularSensibilityX: number;
  104482. /**
  104483. * Defines the pointer angular sensibility along the Y axis or how fast is
  104484. * the camera rotating.
  104485. */
  104486. angularSensibilityY: number;
  104487. /**
  104488. * Defines the pointer pinch precision or how fast is the camera zooming.
  104489. */
  104490. pinchPrecision: number;
  104491. /**
  104492. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104493. * from 0.
  104494. * It defines the percentage of current camera.radius to use as delta when
  104495. * pinch zoom is used.
  104496. */
  104497. pinchDeltaPercentage: number;
  104498. /**
  104499. * Defines the pointer panning sensibility or how fast is the camera moving.
  104500. */
  104501. panningSensibility: number;
  104502. /**
  104503. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104504. */
  104505. multiTouchPanning: boolean;
  104506. /**
  104507. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104508. * zoom (pinch) through multitouch.
  104509. */
  104510. multiTouchPanAndZoom: boolean;
  104511. /**
  104512. * Revers pinch action direction.
  104513. */
  104514. pinchInwards: boolean;
  104515. private _isPanClick;
  104516. private _twoFingerActivityCount;
  104517. private _isPinching;
  104518. /**
  104519. * Called on pointer POINTERMOVE event if only a single touch is active.
  104520. */
  104521. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104522. /**
  104523. * Called on pointer POINTERDOUBLETAP event.
  104524. */
  104525. protected onDoubleTap(type: string): void;
  104526. /**
  104527. * Called on pointer POINTERMOVE event if multiple touches are active.
  104528. */
  104529. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104530. /**
  104531. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104532. * press.
  104533. */
  104534. protected onButtonDown(evt: PointerEvent): void;
  104535. /**
  104536. * Called each time a new POINTERUP event occurs. Ie, for each button
  104537. * release.
  104538. */
  104539. protected onButtonUp(evt: PointerEvent): void;
  104540. /**
  104541. * Called when window becomes inactive.
  104542. */
  104543. protected onLostFocus(): void;
  104544. }
  104545. }
  104546. declare module BABYLON {
  104547. /**
  104548. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104550. */
  104551. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104552. /**
  104553. * Defines the camera the input is attached to.
  104554. */
  104555. camera: ArcRotateCamera;
  104556. /**
  104557. * Defines the list of key codes associated with the up action (increase alpha)
  104558. */
  104559. keysUp: number[];
  104560. /**
  104561. * Defines the list of key codes associated with the down action (decrease alpha)
  104562. */
  104563. keysDown: number[];
  104564. /**
  104565. * Defines the list of key codes associated with the left action (increase beta)
  104566. */
  104567. keysLeft: number[];
  104568. /**
  104569. * Defines the list of key codes associated with the right action (decrease beta)
  104570. */
  104571. keysRight: number[];
  104572. /**
  104573. * Defines the list of key codes associated with the reset action.
  104574. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104575. */
  104576. keysReset: number[];
  104577. /**
  104578. * Defines the panning sensibility of the inputs.
  104579. * (How fast is the camera paning)
  104580. */
  104581. panningSensibility: number;
  104582. /**
  104583. * Defines the zooming sensibility of the inputs.
  104584. * (How fast is the camera zooming)
  104585. */
  104586. zoomingSensibility: number;
  104587. /**
  104588. * Defines wether maintaining the alt key down switch the movement mode from
  104589. * orientation to zoom.
  104590. */
  104591. useAltToZoom: boolean;
  104592. /**
  104593. * Rotation speed of the camera
  104594. */
  104595. angularSpeed: number;
  104596. private _keys;
  104597. private _ctrlPressed;
  104598. private _altPressed;
  104599. private _onCanvasBlurObserver;
  104600. private _onKeyboardObserver;
  104601. private _engine;
  104602. private _scene;
  104603. /**
  104604. * Attach the input controls to a specific dom element to get the input from.
  104605. * @param element Defines the element the controls should be listened from
  104606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104607. */
  104608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104609. /**
  104610. * Detach the current controls from the specified dom element.
  104611. * @param element Defines the element to stop listening the inputs from
  104612. */
  104613. detachControl(element: Nullable<HTMLElement>): void;
  104614. /**
  104615. * Update the current camera state depending on the inputs that have been used this frame.
  104616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104617. */
  104618. checkInputs(): void;
  104619. /**
  104620. * Gets the class name of the current intput.
  104621. * @returns the class name
  104622. */
  104623. getClassName(): string;
  104624. /**
  104625. * Get the friendly name associated with the input class.
  104626. * @returns the input friendly name
  104627. */
  104628. getSimpleName(): string;
  104629. }
  104630. }
  104631. declare module BABYLON {
  104632. /**
  104633. * Manage the mouse wheel inputs to control an arc rotate camera.
  104634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104635. */
  104636. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104637. /**
  104638. * Defines the camera the input is attached to.
  104639. */
  104640. camera: ArcRotateCamera;
  104641. /**
  104642. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104643. */
  104644. wheelPrecision: number;
  104645. /**
  104646. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104647. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104648. */
  104649. wheelDeltaPercentage: number;
  104650. private _wheel;
  104651. private _observer;
  104652. private computeDeltaFromMouseWheelLegacyEvent;
  104653. /**
  104654. * Attach the input controls to a specific dom element to get the input from.
  104655. * @param element Defines the element the controls should be listened from
  104656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104657. */
  104658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104659. /**
  104660. * Detach the current controls from the specified dom element.
  104661. * @param element Defines the element to stop listening the inputs from
  104662. */
  104663. detachControl(element: Nullable<HTMLElement>): void;
  104664. /**
  104665. * Gets the class name of the current intput.
  104666. * @returns the class name
  104667. */
  104668. getClassName(): string;
  104669. /**
  104670. * Get the friendly name associated with the input class.
  104671. * @returns the input friendly name
  104672. */
  104673. getSimpleName(): string;
  104674. }
  104675. }
  104676. declare module BABYLON {
  104677. /**
  104678. * Default Inputs manager for the ArcRotateCamera.
  104679. * It groups all the default supported inputs for ease of use.
  104680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104681. */
  104682. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104683. /**
  104684. * Instantiates a new ArcRotateCameraInputsManager.
  104685. * @param camera Defines the camera the inputs belong to
  104686. */
  104687. constructor(camera: ArcRotateCamera);
  104688. /**
  104689. * Add mouse wheel input support to the input manager.
  104690. * @returns the current input manager
  104691. */
  104692. addMouseWheel(): ArcRotateCameraInputsManager;
  104693. /**
  104694. * Add pointers input support to the input manager.
  104695. * @returns the current input manager
  104696. */
  104697. addPointers(): ArcRotateCameraInputsManager;
  104698. /**
  104699. * Add keyboard input support to the input manager.
  104700. * @returns the current input manager
  104701. */
  104702. addKeyboard(): ArcRotateCameraInputsManager;
  104703. }
  104704. }
  104705. declare module BABYLON {
  104706. /**
  104707. * This represents an orbital type of camera.
  104708. *
  104709. * 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.
  104710. * 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.
  104711. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104712. */
  104713. export class ArcRotateCamera extends TargetCamera {
  104714. /**
  104715. * Defines the rotation angle of the camera along the longitudinal axis.
  104716. */
  104717. alpha: number;
  104718. /**
  104719. * Defines the rotation angle of the camera along the latitudinal axis.
  104720. */
  104721. beta: number;
  104722. /**
  104723. * Defines the radius of the camera from it s target point.
  104724. */
  104725. radius: number;
  104726. protected _target: Vector3;
  104727. protected _targetHost: Nullable<AbstractMesh>;
  104728. /**
  104729. * Defines the target point of the camera.
  104730. * The camera looks towards it form the radius distance.
  104731. */
  104732. target: Vector3;
  104733. /**
  104734. * Define the current local position of the camera in the scene
  104735. */
  104736. position: Vector3;
  104737. protected _upVector: Vector3;
  104738. protected _upToYMatrix: Matrix;
  104739. protected _YToUpMatrix: Matrix;
  104740. /**
  104741. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104742. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104743. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104744. */
  104745. upVector: Vector3;
  104746. /**
  104747. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104748. */
  104749. setMatUp(): void;
  104750. /**
  104751. * Current inertia value on the longitudinal axis.
  104752. * The bigger this number the longer it will take for the camera to stop.
  104753. */
  104754. inertialAlphaOffset: number;
  104755. /**
  104756. * Current inertia value on the latitudinal axis.
  104757. * The bigger this number the longer it will take for the camera to stop.
  104758. */
  104759. inertialBetaOffset: number;
  104760. /**
  104761. * Current inertia value on the radius axis.
  104762. * The bigger this number the longer it will take for the camera to stop.
  104763. */
  104764. inertialRadiusOffset: number;
  104765. /**
  104766. * Minimum allowed angle on the longitudinal axis.
  104767. * This can help limiting how the Camera is able to move in the scene.
  104768. */
  104769. lowerAlphaLimit: Nullable<number>;
  104770. /**
  104771. * Maximum allowed angle on the longitudinal axis.
  104772. * This can help limiting how the Camera is able to move in the scene.
  104773. */
  104774. upperAlphaLimit: Nullable<number>;
  104775. /**
  104776. * Minimum allowed angle on the latitudinal axis.
  104777. * This can help limiting how the Camera is able to move in the scene.
  104778. */
  104779. lowerBetaLimit: number;
  104780. /**
  104781. * Maximum allowed angle on the latitudinal axis.
  104782. * This can help limiting how the Camera is able to move in the scene.
  104783. */
  104784. upperBetaLimit: number;
  104785. /**
  104786. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  104787. * This can help limiting how the Camera is able to move in the scene.
  104788. */
  104789. lowerRadiusLimit: Nullable<number>;
  104790. /**
  104791. * Maximum allowed distance of the camera to the target (The camera can not get further).
  104792. * This can help limiting how the Camera is able to move in the scene.
  104793. */
  104794. upperRadiusLimit: Nullable<number>;
  104795. /**
  104796. * Defines the current inertia value used during panning of the camera along the X axis.
  104797. */
  104798. inertialPanningX: number;
  104799. /**
  104800. * Defines the current inertia value used during panning of the camera along the Y axis.
  104801. */
  104802. inertialPanningY: number;
  104803. /**
  104804. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  104805. * Basically if your fingers moves away from more than this distance you will be considered
  104806. * in pinch mode.
  104807. */
  104808. pinchToPanMaxDistance: number;
  104809. /**
  104810. * Defines the maximum distance the camera can pan.
  104811. * This could help keeping the cammera always in your scene.
  104812. */
  104813. panningDistanceLimit: Nullable<number>;
  104814. /**
  104815. * Defines the target of the camera before paning.
  104816. */
  104817. panningOriginTarget: Vector3;
  104818. /**
  104819. * Defines the value of the inertia used during panning.
  104820. * 0 would mean stop inertia and one would mean no decelleration at all.
  104821. */
  104822. panningInertia: number;
  104823. /**
  104824. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  104825. */
  104826. angularSensibilityX: number;
  104827. /**
  104828. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  104829. */
  104830. angularSensibilityY: number;
  104831. /**
  104832. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  104833. */
  104834. pinchPrecision: number;
  104835. /**
  104836. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  104837. * It will be used instead of pinchDeltaPrecision if different from 0.
  104838. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104839. */
  104840. pinchDeltaPercentage: number;
  104841. /**
  104842. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  104843. */
  104844. panningSensibility: number;
  104845. /**
  104846. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  104847. */
  104848. keysUp: number[];
  104849. /**
  104850. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  104851. */
  104852. keysDown: number[];
  104853. /**
  104854. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  104855. */
  104856. keysLeft: number[];
  104857. /**
  104858. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  104859. */
  104860. keysRight: number[];
  104861. /**
  104862. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104863. */
  104864. wheelPrecision: number;
  104865. /**
  104866. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  104867. * It will be used instead of pinchDeltaPrecision if different from 0.
  104868. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104869. */
  104870. wheelDeltaPercentage: number;
  104871. /**
  104872. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  104873. */
  104874. zoomOnFactor: number;
  104875. /**
  104876. * Defines a screen offset for the camera position.
  104877. */
  104878. targetScreenOffset: Vector2;
  104879. /**
  104880. * Allows the camera to be completely reversed.
  104881. * If false the camera can not arrive upside down.
  104882. */
  104883. allowUpsideDown: boolean;
  104884. /**
  104885. * Define if double tap/click is used to restore the previously saved state of the camera.
  104886. */
  104887. useInputToRestoreState: boolean;
  104888. /** @hidden */
  104889. _viewMatrix: Matrix;
  104890. /** @hidden */
  104891. _useCtrlForPanning: boolean;
  104892. /** @hidden */
  104893. _panningMouseButton: number;
  104894. /**
  104895. * Defines the input associated to the camera.
  104896. */
  104897. inputs: ArcRotateCameraInputsManager;
  104898. /** @hidden */
  104899. _reset: () => void;
  104900. /**
  104901. * Defines the allowed panning axis.
  104902. */
  104903. panningAxis: Vector3;
  104904. protected _localDirection: Vector3;
  104905. protected _transformedDirection: Vector3;
  104906. private _bouncingBehavior;
  104907. /**
  104908. * Gets the bouncing behavior of the camera if it has been enabled.
  104909. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104910. */
  104911. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104912. /**
  104913. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104914. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104915. */
  104916. useBouncingBehavior: boolean;
  104917. private _framingBehavior;
  104918. /**
  104919. * Gets the framing behavior of the camera if it has been enabled.
  104920. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104921. */
  104922. readonly framingBehavior: Nullable<FramingBehavior>;
  104923. /**
  104924. * Defines if the framing behavior of the camera is enabled on the camera.
  104925. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104926. */
  104927. useFramingBehavior: boolean;
  104928. private _autoRotationBehavior;
  104929. /**
  104930. * Gets the auto rotation behavior of the camera if it has been enabled.
  104931. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104932. */
  104933. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104934. /**
  104935. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104936. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104937. */
  104938. useAutoRotationBehavior: boolean;
  104939. /**
  104940. * Observable triggered when the mesh target has been changed on the camera.
  104941. */
  104942. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104943. /**
  104944. * Event raised when the camera is colliding with a mesh.
  104945. */
  104946. onCollide: (collidedMesh: AbstractMesh) => void;
  104947. /**
  104948. * Defines whether the camera should check collision with the objects oh the scene.
  104949. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104950. */
  104951. checkCollisions: boolean;
  104952. /**
  104953. * Defines the collision radius of the camera.
  104954. * This simulates a sphere around the camera.
  104955. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104956. */
  104957. collisionRadius: Vector3;
  104958. protected _collider: Collider;
  104959. protected _previousPosition: Vector3;
  104960. protected _collisionVelocity: Vector3;
  104961. protected _newPosition: Vector3;
  104962. protected _previousAlpha: number;
  104963. protected _previousBeta: number;
  104964. protected _previousRadius: number;
  104965. protected _collisionTriggered: boolean;
  104966. protected _targetBoundingCenter: Nullable<Vector3>;
  104967. private _computationVector;
  104968. /**
  104969. * Instantiates a new ArcRotateCamera in a given scene
  104970. * @param name Defines the name of the camera
  104971. * @param alpha Defines the camera rotation along the logitudinal axis
  104972. * @param beta Defines the camera rotation along the latitudinal axis
  104973. * @param radius Defines the camera distance from its target
  104974. * @param target Defines the camera target
  104975. * @param scene Defines the scene the camera belongs to
  104976. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104977. */
  104978. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104979. /** @hidden */
  104980. _initCache(): void;
  104981. /** @hidden */
  104982. _updateCache(ignoreParentClass?: boolean): void;
  104983. protected _getTargetPosition(): Vector3;
  104984. private _storedAlpha;
  104985. private _storedBeta;
  104986. private _storedRadius;
  104987. private _storedTarget;
  104988. private _storedTargetScreenOffset;
  104989. /**
  104990. * Stores the current state of the camera (alpha, beta, radius and target)
  104991. * @returns the camera itself
  104992. */
  104993. storeState(): Camera;
  104994. /**
  104995. * @hidden
  104996. * Restored camera state. You must call storeState() first
  104997. */
  104998. _restoreStateValues(): boolean;
  104999. /** @hidden */
  105000. _isSynchronizedViewMatrix(): boolean;
  105001. /**
  105002. * Attached controls to the current camera.
  105003. * @param element Defines the element the controls should be listened from
  105004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105005. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105006. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105007. */
  105008. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105009. /**
  105010. * Detach the current controls from the camera.
  105011. * The camera will stop reacting to inputs.
  105012. * @param element Defines the element to stop listening the inputs from
  105013. */
  105014. detachControl(element: HTMLElement): void;
  105015. /** @hidden */
  105016. _checkInputs(): void;
  105017. protected _checkLimits(): void;
  105018. /**
  105019. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105020. */
  105021. rebuildAnglesAndRadius(): void;
  105022. /**
  105023. * Use a position to define the current camera related information like alpha, beta and radius
  105024. * @param position Defines the position to set the camera at
  105025. */
  105026. setPosition(position: Vector3): void;
  105027. /**
  105028. * Defines the target the camera should look at.
  105029. * This will automatically adapt alpha beta and radius to fit within the new target.
  105030. * @param target Defines the new target as a Vector or a mesh
  105031. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105032. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105033. */
  105034. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105035. /** @hidden */
  105036. _getViewMatrix(): Matrix;
  105037. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105038. /**
  105039. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105040. * @param meshes Defines the mesh to zoom on
  105041. * @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)
  105042. */
  105043. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105044. /**
  105045. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105046. * The target will be changed but the radius
  105047. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105048. * @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)
  105049. */
  105050. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105051. min: Vector3;
  105052. max: Vector3;
  105053. distance: number;
  105054. }, doNotUpdateMaxZ?: boolean): void;
  105055. /**
  105056. * @override
  105057. * Override Camera.createRigCamera
  105058. */
  105059. createRigCamera(name: string, cameraIndex: number): Camera;
  105060. /**
  105061. * @hidden
  105062. * @override
  105063. * Override Camera._updateRigCameras
  105064. */
  105065. _updateRigCameras(): void;
  105066. /**
  105067. * Destroy the camera and release the current resources hold by it.
  105068. */
  105069. dispose(): void;
  105070. /**
  105071. * Gets the current object class name.
  105072. * @return the class name
  105073. */
  105074. getClassName(): string;
  105075. }
  105076. }
  105077. declare module BABYLON {
  105078. /**
  105079. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105080. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105081. */
  105082. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105083. /**
  105084. * Gets the name of the behavior.
  105085. */
  105086. readonly name: string;
  105087. private _zoomStopsAnimation;
  105088. private _idleRotationSpeed;
  105089. private _idleRotationWaitTime;
  105090. private _idleRotationSpinupTime;
  105091. /**
  105092. * Sets the flag that indicates if user zooming should stop animation.
  105093. */
  105094. /**
  105095. * Gets the flag that indicates if user zooming should stop animation.
  105096. */
  105097. zoomStopsAnimation: boolean;
  105098. /**
  105099. * Sets the default speed at which the camera rotates around the model.
  105100. */
  105101. /**
  105102. * Gets the default speed at which the camera rotates around the model.
  105103. */
  105104. idleRotationSpeed: number;
  105105. /**
  105106. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105107. */
  105108. /**
  105109. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105110. */
  105111. idleRotationWaitTime: number;
  105112. /**
  105113. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105114. */
  105115. /**
  105116. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105117. */
  105118. idleRotationSpinupTime: number;
  105119. /**
  105120. * Gets a value indicating if the camera is currently rotating because of this behavior
  105121. */
  105122. readonly rotationInProgress: boolean;
  105123. private _onPrePointerObservableObserver;
  105124. private _onAfterCheckInputsObserver;
  105125. private _attachedCamera;
  105126. private _isPointerDown;
  105127. private _lastFrameTime;
  105128. private _lastInteractionTime;
  105129. private _cameraRotationSpeed;
  105130. /**
  105131. * Initializes the behavior.
  105132. */
  105133. init(): void;
  105134. /**
  105135. * Attaches the behavior to its arc rotate camera.
  105136. * @param camera Defines the camera to attach the behavior to
  105137. */
  105138. attach(camera: ArcRotateCamera): void;
  105139. /**
  105140. * Detaches the behavior from its current arc rotate camera.
  105141. */
  105142. detach(): void;
  105143. /**
  105144. * Returns true if user is scrolling.
  105145. * @return true if user is scrolling.
  105146. */
  105147. private _userIsZooming;
  105148. private _lastFrameRadius;
  105149. private _shouldAnimationStopForInteraction;
  105150. /**
  105151. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105152. */
  105153. private _applyUserInteraction;
  105154. private _userIsMoving;
  105155. }
  105156. }
  105157. declare module BABYLON {
  105158. /**
  105159. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105160. */
  105161. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105162. private ui;
  105163. /**
  105164. * The name of the behavior
  105165. */
  105166. name: string;
  105167. /**
  105168. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105169. */
  105170. distanceAwayFromFace: number;
  105171. /**
  105172. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105173. */
  105174. distanceAwayFromBottomOfFace: number;
  105175. private _faceVectors;
  105176. private _target;
  105177. private _scene;
  105178. private _onRenderObserver;
  105179. private _tmpMatrix;
  105180. private _tmpVector;
  105181. /**
  105182. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105183. * @param ui The transform node that should be attched to the mesh
  105184. */
  105185. constructor(ui: TransformNode);
  105186. /**
  105187. * Initializes the behavior
  105188. */
  105189. init(): void;
  105190. private _closestFace;
  105191. private _zeroVector;
  105192. private _lookAtTmpMatrix;
  105193. private _lookAtToRef;
  105194. /**
  105195. * Attaches the AttachToBoxBehavior to the passed in mesh
  105196. * @param target The mesh that the specified node will be attached to
  105197. */
  105198. attach(target: Mesh): void;
  105199. /**
  105200. * Detaches the behavior from the mesh
  105201. */
  105202. detach(): void;
  105203. }
  105204. }
  105205. declare module BABYLON {
  105206. /**
  105207. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105208. */
  105209. export class FadeInOutBehavior implements Behavior<Mesh> {
  105210. /**
  105211. * Time in milliseconds to delay before fading in (Default: 0)
  105212. */
  105213. delay: number;
  105214. /**
  105215. * Time in milliseconds for the mesh to fade in (Default: 300)
  105216. */
  105217. fadeInTime: number;
  105218. private _millisecondsPerFrame;
  105219. private _hovered;
  105220. private _hoverValue;
  105221. private _ownerNode;
  105222. /**
  105223. * Instatiates the FadeInOutBehavior
  105224. */
  105225. constructor();
  105226. /**
  105227. * The name of the behavior
  105228. */
  105229. readonly name: string;
  105230. /**
  105231. * Initializes the behavior
  105232. */
  105233. init(): void;
  105234. /**
  105235. * Attaches the fade behavior on the passed in mesh
  105236. * @param ownerNode The mesh that will be faded in/out once attached
  105237. */
  105238. attach(ownerNode: Mesh): void;
  105239. /**
  105240. * Detaches the behavior from the mesh
  105241. */
  105242. detach(): void;
  105243. /**
  105244. * Triggers the mesh to begin fading in or out
  105245. * @param value if the object should fade in or out (true to fade in)
  105246. */
  105247. fadeIn(value: boolean): void;
  105248. private _update;
  105249. private _setAllVisibility;
  105250. }
  105251. }
  105252. declare module BABYLON {
  105253. /**
  105254. * Class containing a set of static utilities functions for managing Pivots
  105255. * @hidden
  105256. */
  105257. export class PivotTools {
  105258. private static _PivotCached;
  105259. private static _OldPivotPoint;
  105260. private static _PivotTranslation;
  105261. private static _PivotTmpVector;
  105262. /** @hidden */
  105263. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105264. /** @hidden */
  105265. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105266. }
  105267. }
  105268. declare module BABYLON {
  105269. /**
  105270. * Class containing static functions to help procedurally build meshes
  105271. */
  105272. export class PlaneBuilder {
  105273. /**
  105274. * Creates a plane mesh
  105275. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105276. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105277. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105281. * @param name defines the name of the mesh
  105282. * @param options defines the options used to create the mesh
  105283. * @param scene defines the hosting scene
  105284. * @returns the plane mesh
  105285. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105286. */
  105287. static CreatePlane(name: string, options: {
  105288. size?: number;
  105289. width?: number;
  105290. height?: number;
  105291. sideOrientation?: number;
  105292. frontUVs?: Vector4;
  105293. backUVs?: Vector4;
  105294. updatable?: boolean;
  105295. sourcePlane?: Plane;
  105296. }, scene?: Nullable<Scene>): Mesh;
  105297. }
  105298. }
  105299. declare module BABYLON {
  105300. /**
  105301. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105302. */
  105303. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105304. private static _AnyMouseID;
  105305. /**
  105306. * Abstract mesh the behavior is set on
  105307. */
  105308. attachedNode: AbstractMesh;
  105309. private _dragPlane;
  105310. private _scene;
  105311. private _pointerObserver;
  105312. private _beforeRenderObserver;
  105313. private static _planeScene;
  105314. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105315. /**
  105316. * 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)
  105317. */
  105318. maxDragAngle: number;
  105319. /**
  105320. * @hidden
  105321. */
  105322. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105323. /**
  105324. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105325. */
  105326. currentDraggingPointerID: number;
  105327. /**
  105328. * The last position where the pointer hit the drag plane in world space
  105329. */
  105330. lastDragPosition: Vector3;
  105331. /**
  105332. * If the behavior is currently in a dragging state
  105333. */
  105334. dragging: boolean;
  105335. /**
  105336. * 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)
  105337. */
  105338. dragDeltaRatio: number;
  105339. /**
  105340. * If the drag plane orientation should be updated during the dragging (Default: true)
  105341. */
  105342. updateDragPlane: boolean;
  105343. private _debugMode;
  105344. private _moving;
  105345. /**
  105346. * Fires each time the attached mesh is dragged with the pointer
  105347. * * delta between last drag position and current drag position in world space
  105348. * * dragDistance along the drag axis
  105349. * * dragPlaneNormal normal of the current drag plane used during the drag
  105350. * * dragPlanePoint in world space where the drag intersects the drag plane
  105351. */
  105352. onDragObservable: Observable<{
  105353. delta: Vector3;
  105354. dragPlanePoint: Vector3;
  105355. dragPlaneNormal: Vector3;
  105356. dragDistance: number;
  105357. pointerId: number;
  105358. }>;
  105359. /**
  105360. * Fires each time a drag begins (eg. mouse down on mesh)
  105361. */
  105362. onDragStartObservable: Observable<{
  105363. dragPlanePoint: Vector3;
  105364. pointerId: number;
  105365. }>;
  105366. /**
  105367. * Fires each time a drag ends (eg. mouse release after drag)
  105368. */
  105369. onDragEndObservable: Observable<{
  105370. dragPlanePoint: Vector3;
  105371. pointerId: number;
  105372. }>;
  105373. /**
  105374. * If the attached mesh should be moved when dragged
  105375. */
  105376. moveAttached: boolean;
  105377. /**
  105378. * If the drag behavior will react to drag events (Default: true)
  105379. */
  105380. enabled: boolean;
  105381. /**
  105382. * If pointer events should start and release the drag (Default: true)
  105383. */
  105384. startAndReleaseDragOnPointerEvents: boolean;
  105385. /**
  105386. * If camera controls should be detached during the drag
  105387. */
  105388. detachCameraControls: boolean;
  105389. /**
  105390. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105391. */
  105392. useObjectOrienationForDragging: boolean;
  105393. private _options;
  105394. /**
  105395. * Creates a pointer drag behavior that can be attached to a mesh
  105396. * @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)
  105397. */
  105398. constructor(options?: {
  105399. dragAxis?: Vector3;
  105400. dragPlaneNormal?: Vector3;
  105401. });
  105402. /**
  105403. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105404. */
  105405. validateDrag: (targetPosition: Vector3) => boolean;
  105406. /**
  105407. * The name of the behavior
  105408. */
  105409. readonly name: string;
  105410. /**
  105411. * Initializes the behavior
  105412. */
  105413. init(): void;
  105414. private _tmpVector;
  105415. private _alternatePickedPoint;
  105416. private _worldDragAxis;
  105417. private _targetPosition;
  105418. private _attachedElement;
  105419. /**
  105420. * Attaches the drag behavior the passed in mesh
  105421. * @param ownerNode The mesh that will be dragged around once attached
  105422. * @param predicate Predicate to use for pick filtering
  105423. */
  105424. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105425. /**
  105426. * Force relase the drag action by code.
  105427. */
  105428. releaseDrag(): void;
  105429. private _startDragRay;
  105430. private _lastPointerRay;
  105431. /**
  105432. * Simulates the start of a pointer drag event on the behavior
  105433. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105434. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105435. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105436. */
  105437. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105438. private _startDrag;
  105439. private _dragDelta;
  105440. private _moveDrag;
  105441. private _pickWithRayOnDragPlane;
  105442. private _pointA;
  105443. private _pointB;
  105444. private _pointC;
  105445. private _lineA;
  105446. private _lineB;
  105447. private _localAxis;
  105448. private _lookAt;
  105449. private _updateDragPlanePosition;
  105450. /**
  105451. * Detaches the behavior from the mesh
  105452. */
  105453. detach(): void;
  105454. }
  105455. }
  105456. declare module BABYLON {
  105457. /**
  105458. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105459. */
  105460. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105461. private _dragBehaviorA;
  105462. private _dragBehaviorB;
  105463. private _startDistance;
  105464. private _initialScale;
  105465. private _targetScale;
  105466. private _ownerNode;
  105467. private _sceneRenderObserver;
  105468. /**
  105469. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105470. */
  105471. constructor();
  105472. /**
  105473. * The name of the behavior
  105474. */
  105475. readonly name: string;
  105476. /**
  105477. * Initializes the behavior
  105478. */
  105479. init(): void;
  105480. private _getCurrentDistance;
  105481. /**
  105482. * Attaches the scale behavior the passed in mesh
  105483. * @param ownerNode The mesh that will be scaled around once attached
  105484. */
  105485. attach(ownerNode: Mesh): void;
  105486. /**
  105487. * Detaches the behavior from the mesh
  105488. */
  105489. detach(): void;
  105490. }
  105491. }
  105492. declare module BABYLON {
  105493. /**
  105494. * 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
  105495. */
  105496. export class SixDofDragBehavior implements Behavior<Mesh> {
  105497. private static _virtualScene;
  105498. private _ownerNode;
  105499. private _sceneRenderObserver;
  105500. private _scene;
  105501. private _targetPosition;
  105502. private _virtualOriginMesh;
  105503. private _virtualDragMesh;
  105504. private _pointerObserver;
  105505. private _moving;
  105506. private _startingOrientation;
  105507. /**
  105508. * 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)
  105509. */
  105510. private zDragFactor;
  105511. /**
  105512. * If the object should rotate to face the drag origin
  105513. */
  105514. rotateDraggedObject: boolean;
  105515. /**
  105516. * If the behavior is currently in a dragging state
  105517. */
  105518. dragging: boolean;
  105519. /**
  105520. * 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)
  105521. */
  105522. dragDeltaRatio: number;
  105523. /**
  105524. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105525. */
  105526. currentDraggingPointerID: number;
  105527. /**
  105528. * If camera controls should be detached during the drag
  105529. */
  105530. detachCameraControls: boolean;
  105531. /**
  105532. * Fires each time a drag starts
  105533. */
  105534. onDragStartObservable: Observable<{}>;
  105535. /**
  105536. * Fires each time a drag ends (eg. mouse release after drag)
  105537. */
  105538. onDragEndObservable: Observable<{}>;
  105539. /**
  105540. * 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
  105541. */
  105542. constructor();
  105543. /**
  105544. * The name of the behavior
  105545. */
  105546. readonly name: string;
  105547. /**
  105548. * Initializes the behavior
  105549. */
  105550. init(): void;
  105551. /**
  105552. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105553. */
  105554. private readonly _pointerCamera;
  105555. /**
  105556. * Attaches the scale behavior the passed in mesh
  105557. * @param ownerNode The mesh that will be scaled around once attached
  105558. */
  105559. attach(ownerNode: Mesh): void;
  105560. /**
  105561. * Detaches the behavior from the mesh
  105562. */
  105563. detach(): void;
  105564. }
  105565. }
  105566. declare module BABYLON {
  105567. /**
  105568. * Class used to apply inverse kinematics to bones
  105569. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105570. */
  105571. export class BoneIKController {
  105572. private static _tmpVecs;
  105573. private static _tmpQuat;
  105574. private static _tmpMats;
  105575. /**
  105576. * Gets or sets the target mesh
  105577. */
  105578. targetMesh: AbstractMesh;
  105579. /** Gets or sets the mesh used as pole */
  105580. poleTargetMesh: AbstractMesh;
  105581. /**
  105582. * Gets or sets the bone used as pole
  105583. */
  105584. poleTargetBone: Nullable<Bone>;
  105585. /**
  105586. * Gets or sets the target position
  105587. */
  105588. targetPosition: Vector3;
  105589. /**
  105590. * Gets or sets the pole target position
  105591. */
  105592. poleTargetPosition: Vector3;
  105593. /**
  105594. * Gets or sets the pole target local offset
  105595. */
  105596. poleTargetLocalOffset: Vector3;
  105597. /**
  105598. * Gets or sets the pole angle
  105599. */
  105600. poleAngle: number;
  105601. /**
  105602. * Gets or sets the mesh associated with the controller
  105603. */
  105604. mesh: AbstractMesh;
  105605. /**
  105606. * 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)
  105607. */
  105608. slerpAmount: number;
  105609. private _bone1Quat;
  105610. private _bone1Mat;
  105611. private _bone2Ang;
  105612. private _bone1;
  105613. private _bone2;
  105614. private _bone1Length;
  105615. private _bone2Length;
  105616. private _maxAngle;
  105617. private _maxReach;
  105618. private _rightHandedSystem;
  105619. private _bendAxis;
  105620. private _slerping;
  105621. private _adjustRoll;
  105622. /**
  105623. * Gets or sets maximum allowed angle
  105624. */
  105625. maxAngle: number;
  105626. /**
  105627. * Creates a new BoneIKController
  105628. * @param mesh defines the mesh to control
  105629. * @param bone defines the bone to control
  105630. * @param options defines options to set up the controller
  105631. */
  105632. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105633. targetMesh?: AbstractMesh;
  105634. poleTargetMesh?: AbstractMesh;
  105635. poleTargetBone?: Bone;
  105636. poleTargetLocalOffset?: Vector3;
  105637. poleAngle?: number;
  105638. bendAxis?: Vector3;
  105639. maxAngle?: number;
  105640. slerpAmount?: number;
  105641. });
  105642. private _setMaxAngle;
  105643. /**
  105644. * Force the controller to update the bones
  105645. */
  105646. update(): void;
  105647. }
  105648. }
  105649. declare module BABYLON {
  105650. /**
  105651. * Class used to make a bone look toward a point in space
  105652. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105653. */
  105654. export class BoneLookController {
  105655. private static _tmpVecs;
  105656. private static _tmpQuat;
  105657. private static _tmpMats;
  105658. /**
  105659. * The target Vector3 that the bone will look at
  105660. */
  105661. target: Vector3;
  105662. /**
  105663. * The mesh that the bone is attached to
  105664. */
  105665. mesh: AbstractMesh;
  105666. /**
  105667. * The bone that will be looking to the target
  105668. */
  105669. bone: Bone;
  105670. /**
  105671. * The up axis of the coordinate system that is used when the bone is rotated
  105672. */
  105673. upAxis: Vector3;
  105674. /**
  105675. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105676. */
  105677. upAxisSpace: Space;
  105678. /**
  105679. * Used to make an adjustment to the yaw of the bone
  105680. */
  105681. adjustYaw: number;
  105682. /**
  105683. * Used to make an adjustment to the pitch of the bone
  105684. */
  105685. adjustPitch: number;
  105686. /**
  105687. * Used to make an adjustment to the roll of the bone
  105688. */
  105689. adjustRoll: number;
  105690. /**
  105691. * 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)
  105692. */
  105693. slerpAmount: number;
  105694. private _minYaw;
  105695. private _maxYaw;
  105696. private _minPitch;
  105697. private _maxPitch;
  105698. private _minYawSin;
  105699. private _minYawCos;
  105700. private _maxYawSin;
  105701. private _maxYawCos;
  105702. private _midYawConstraint;
  105703. private _minPitchTan;
  105704. private _maxPitchTan;
  105705. private _boneQuat;
  105706. private _slerping;
  105707. private _transformYawPitch;
  105708. private _transformYawPitchInv;
  105709. private _firstFrameSkipped;
  105710. private _yawRange;
  105711. private _fowardAxis;
  105712. /**
  105713. * Gets or sets the minimum yaw angle that the bone can look to
  105714. */
  105715. minYaw: number;
  105716. /**
  105717. * Gets or sets the maximum yaw angle that the bone can look to
  105718. */
  105719. maxYaw: number;
  105720. /**
  105721. * Gets or sets the minimum pitch angle that the bone can look to
  105722. */
  105723. minPitch: number;
  105724. /**
  105725. * Gets or sets the maximum pitch angle that the bone can look to
  105726. */
  105727. maxPitch: number;
  105728. /**
  105729. * Create a BoneLookController
  105730. * @param mesh the mesh that the bone belongs to
  105731. * @param bone the bone that will be looking to the target
  105732. * @param target the target Vector3 to look at
  105733. * @param options optional settings:
  105734. * * maxYaw: the maximum angle the bone will yaw to
  105735. * * minYaw: the minimum angle the bone will yaw to
  105736. * * maxPitch: the maximum angle the bone will pitch to
  105737. * * minPitch: the minimum angle the bone will yaw to
  105738. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105739. * * upAxis: the up axis of the coordinate system
  105740. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105741. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105742. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105743. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105744. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105745. * * adjustRoll: used to make an adjustment to the roll of the bone
  105746. **/
  105747. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105748. maxYaw?: number;
  105749. minYaw?: number;
  105750. maxPitch?: number;
  105751. minPitch?: number;
  105752. slerpAmount?: number;
  105753. upAxis?: Vector3;
  105754. upAxisSpace?: Space;
  105755. yawAxis?: Vector3;
  105756. pitchAxis?: Vector3;
  105757. adjustYaw?: number;
  105758. adjustPitch?: number;
  105759. adjustRoll?: number;
  105760. });
  105761. /**
  105762. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  105763. */
  105764. update(): void;
  105765. private _getAngleDiff;
  105766. private _getAngleBetween;
  105767. private _isAngleBetween;
  105768. }
  105769. }
  105770. declare module BABYLON {
  105771. /**
  105772. * Manage the gamepad inputs to control an arc rotate camera.
  105773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105774. */
  105775. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  105776. /**
  105777. * Defines the camera the input is attached to.
  105778. */
  105779. camera: ArcRotateCamera;
  105780. /**
  105781. * Defines the gamepad the input is gathering event from.
  105782. */
  105783. gamepad: Nullable<Gamepad>;
  105784. /**
  105785. * Defines the gamepad rotation sensiblity.
  105786. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105787. */
  105788. gamepadRotationSensibility: number;
  105789. /**
  105790. * Defines the gamepad move sensiblity.
  105791. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105792. */
  105793. gamepadMoveSensibility: number;
  105794. private _yAxisScale;
  105795. /**
  105796. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105797. */
  105798. invertYAxis: boolean;
  105799. private _onGamepadConnectedObserver;
  105800. private _onGamepadDisconnectedObserver;
  105801. /**
  105802. * Attach the input controls to a specific dom element to get the input from.
  105803. * @param element Defines the element the controls should be listened from
  105804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105805. */
  105806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105807. /**
  105808. * Detach the current controls from the specified dom element.
  105809. * @param element Defines the element to stop listening the inputs from
  105810. */
  105811. detachControl(element: Nullable<HTMLElement>): void;
  105812. /**
  105813. * Update the current camera state depending on the inputs that have been used this frame.
  105814. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105815. */
  105816. checkInputs(): void;
  105817. /**
  105818. * Gets the class name of the current intput.
  105819. * @returns the class name
  105820. */
  105821. getClassName(): string;
  105822. /**
  105823. * Get the friendly name associated with the input class.
  105824. * @returns the input friendly name
  105825. */
  105826. getSimpleName(): string;
  105827. }
  105828. }
  105829. declare module BABYLON {
  105830. interface ArcRotateCameraInputsManager {
  105831. /**
  105832. * Add orientation input support to the input manager.
  105833. * @returns the current input manager
  105834. */
  105835. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  105836. }
  105837. /**
  105838. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  105839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105840. */
  105841. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  105842. /**
  105843. * Defines the camera the input is attached to.
  105844. */
  105845. camera: ArcRotateCamera;
  105846. /**
  105847. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  105848. */
  105849. alphaCorrection: number;
  105850. /**
  105851. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  105852. */
  105853. gammaCorrection: number;
  105854. private _alpha;
  105855. private _gamma;
  105856. private _dirty;
  105857. private _deviceOrientationHandler;
  105858. /**
  105859. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  105860. */
  105861. constructor();
  105862. /**
  105863. * Attach the input controls to a specific dom element to get the input from.
  105864. * @param element Defines the element the controls should be listened from
  105865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105866. */
  105867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105868. /** @hidden */
  105869. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  105870. /**
  105871. * Update the current camera state depending on the inputs that have been used this frame.
  105872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105873. */
  105874. checkInputs(): void;
  105875. /**
  105876. * Detach the current controls from the specified dom element.
  105877. * @param element Defines the element to stop listening the inputs from
  105878. */
  105879. detachControl(element: Nullable<HTMLElement>): void;
  105880. /**
  105881. * Gets the class name of the current intput.
  105882. * @returns the class name
  105883. */
  105884. getClassName(): string;
  105885. /**
  105886. * Get the friendly name associated with the input class.
  105887. * @returns the input friendly name
  105888. */
  105889. getSimpleName(): string;
  105890. }
  105891. }
  105892. declare module BABYLON {
  105893. /**
  105894. * Listen to mouse events to control the camera.
  105895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105896. */
  105897. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105898. /**
  105899. * Defines the camera the input is attached to.
  105900. */
  105901. camera: FlyCamera;
  105902. /**
  105903. * Defines if touch is enabled. (Default is true.)
  105904. */
  105905. touchEnabled: boolean;
  105906. /**
  105907. * Defines the buttons associated with the input to handle camera rotation.
  105908. */
  105909. buttons: number[];
  105910. /**
  105911. * Assign buttons for Yaw control.
  105912. */
  105913. buttonsYaw: number[];
  105914. /**
  105915. * Assign buttons for Pitch control.
  105916. */
  105917. buttonsPitch: number[];
  105918. /**
  105919. * Assign buttons for Roll control.
  105920. */
  105921. buttonsRoll: number[];
  105922. /**
  105923. * Detect if any button is being pressed while mouse is moved.
  105924. * -1 = Mouse locked.
  105925. * 0 = Left button.
  105926. * 1 = Middle Button.
  105927. * 2 = Right Button.
  105928. */
  105929. activeButton: number;
  105930. /**
  105931. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105932. * Higher values reduce its sensitivity.
  105933. */
  105934. angularSensibility: number;
  105935. private _mousemoveCallback;
  105936. private _observer;
  105937. private _rollObserver;
  105938. private previousPosition;
  105939. private noPreventDefault;
  105940. private element;
  105941. /**
  105942. * Listen to mouse events to control the camera.
  105943. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105945. */
  105946. constructor(touchEnabled?: boolean);
  105947. /**
  105948. * Attach the mouse control to the HTML DOM element.
  105949. * @param element Defines the element that listens to the input events.
  105950. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105951. */
  105952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105953. /**
  105954. * Detach the current controls from the specified dom element.
  105955. * @param element Defines the element to stop listening the inputs from
  105956. */
  105957. detachControl(element: Nullable<HTMLElement>): void;
  105958. /**
  105959. * Gets the class name of the current input.
  105960. * @returns the class name.
  105961. */
  105962. getClassName(): string;
  105963. /**
  105964. * Get the friendly name associated with the input class.
  105965. * @returns the input's friendly name.
  105966. */
  105967. getSimpleName(): string;
  105968. private _pointerInput;
  105969. private _onMouseMove;
  105970. /**
  105971. * Rotate camera by mouse offset.
  105972. */
  105973. private rotateCamera;
  105974. }
  105975. }
  105976. declare module BABYLON {
  105977. /**
  105978. * Default Inputs manager for the FlyCamera.
  105979. * It groups all the default supported inputs for ease of use.
  105980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105981. */
  105982. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105983. /**
  105984. * Instantiates a new FlyCameraInputsManager.
  105985. * @param camera Defines the camera the inputs belong to.
  105986. */
  105987. constructor(camera: FlyCamera);
  105988. /**
  105989. * Add keyboard input support to the input manager.
  105990. * @returns the new FlyCameraKeyboardMoveInput().
  105991. */
  105992. addKeyboard(): FlyCameraInputsManager;
  105993. /**
  105994. * Add mouse input support to the input manager.
  105995. * @param touchEnabled Enable touch screen support.
  105996. * @returns the new FlyCameraMouseInput().
  105997. */
  105998. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105999. }
  106000. }
  106001. declare module BABYLON {
  106002. /**
  106003. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106004. * such as in a 3D Space Shooter or a Flight Simulator.
  106005. */
  106006. export class FlyCamera extends TargetCamera {
  106007. /**
  106008. * Define the collision ellipsoid of the camera.
  106009. * This is helpful for simulating a camera body, like a player's body.
  106010. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106011. */
  106012. ellipsoid: Vector3;
  106013. /**
  106014. * Define an offset for the position of the ellipsoid around the camera.
  106015. * This can be helpful if the camera is attached away from the player's body center,
  106016. * such as at its head.
  106017. */
  106018. ellipsoidOffset: Vector3;
  106019. /**
  106020. * Enable or disable collisions of the camera with the rest of the scene objects.
  106021. */
  106022. checkCollisions: boolean;
  106023. /**
  106024. * Enable or disable gravity on the camera.
  106025. */
  106026. applyGravity: boolean;
  106027. /**
  106028. * Define the current direction the camera is moving to.
  106029. */
  106030. cameraDirection: Vector3;
  106031. /**
  106032. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106033. * This overrides and empties cameraRotation.
  106034. */
  106035. rotationQuaternion: Quaternion;
  106036. /**
  106037. * Track Roll to maintain the wanted Rolling when looking around.
  106038. */
  106039. _trackRoll: number;
  106040. /**
  106041. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106042. */
  106043. rollCorrect: number;
  106044. /**
  106045. * Mimic a banked turn, Rolling the camera when Yawing.
  106046. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106047. */
  106048. bankedTurn: boolean;
  106049. /**
  106050. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106051. */
  106052. bankedTurnLimit: number;
  106053. /**
  106054. * Value of 0 disables the banked Roll.
  106055. * Value of 1 is equal to the Yaw angle in radians.
  106056. */
  106057. bankedTurnMultiplier: number;
  106058. /**
  106059. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106060. */
  106061. inputs: FlyCameraInputsManager;
  106062. /**
  106063. * Gets the input sensibility for mouse input.
  106064. * Higher values reduce sensitivity.
  106065. */
  106066. /**
  106067. * Sets the input sensibility for a mouse input.
  106068. * Higher values reduce sensitivity.
  106069. */
  106070. angularSensibility: number;
  106071. /**
  106072. * Get the keys for camera movement forward.
  106073. */
  106074. /**
  106075. * Set the keys for camera movement forward.
  106076. */
  106077. keysForward: number[];
  106078. /**
  106079. * Get the keys for camera movement backward.
  106080. */
  106081. keysBackward: number[];
  106082. /**
  106083. * Get the keys for camera movement up.
  106084. */
  106085. /**
  106086. * Set the keys for camera movement up.
  106087. */
  106088. keysUp: number[];
  106089. /**
  106090. * Get the keys for camera movement down.
  106091. */
  106092. /**
  106093. * Set the keys for camera movement down.
  106094. */
  106095. keysDown: number[];
  106096. /**
  106097. * Get the keys for camera movement left.
  106098. */
  106099. /**
  106100. * Set the keys for camera movement left.
  106101. */
  106102. keysLeft: number[];
  106103. /**
  106104. * Set the keys for camera movement right.
  106105. */
  106106. /**
  106107. * Set the keys for camera movement right.
  106108. */
  106109. keysRight: number[];
  106110. /**
  106111. * Event raised when the camera collides with a mesh in the scene.
  106112. */
  106113. onCollide: (collidedMesh: AbstractMesh) => void;
  106114. private _collider;
  106115. private _needMoveForGravity;
  106116. private _oldPosition;
  106117. private _diffPosition;
  106118. private _newPosition;
  106119. /** @hidden */
  106120. _localDirection: Vector3;
  106121. /** @hidden */
  106122. _transformedDirection: Vector3;
  106123. /**
  106124. * Instantiates a FlyCamera.
  106125. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106126. * such as in a 3D Space Shooter or a Flight Simulator.
  106127. * @param name Define the name of the camera in the scene.
  106128. * @param position Define the starting position of the camera in the scene.
  106129. * @param scene Define the scene the camera belongs to.
  106130. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106131. */
  106132. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106133. /**
  106134. * Attach a control to the HTML DOM element.
  106135. * @param element Defines the element that listens to the input events.
  106136. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106137. */
  106138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106139. /**
  106140. * Detach a control from the HTML DOM element.
  106141. * The camera will stop reacting to that input.
  106142. * @param element Defines the element that listens to the input events.
  106143. */
  106144. detachControl(element: HTMLElement): void;
  106145. private _collisionMask;
  106146. /**
  106147. * Get the mask that the camera ignores in collision events.
  106148. */
  106149. /**
  106150. * Set the mask that the camera ignores in collision events.
  106151. */
  106152. collisionMask: number;
  106153. /** @hidden */
  106154. _collideWithWorld(displacement: Vector3): void;
  106155. /** @hidden */
  106156. private _onCollisionPositionChange;
  106157. /** @hidden */
  106158. _checkInputs(): void;
  106159. /** @hidden */
  106160. _decideIfNeedsToMove(): boolean;
  106161. /** @hidden */
  106162. _updatePosition(): void;
  106163. /**
  106164. * Restore the Roll to its target value at the rate specified.
  106165. * @param rate - Higher means slower restoring.
  106166. * @hidden
  106167. */
  106168. restoreRoll(rate: number): void;
  106169. /**
  106170. * Destroy the camera and release the current resources held by it.
  106171. */
  106172. dispose(): void;
  106173. /**
  106174. * Get the current object class name.
  106175. * @returns the class name.
  106176. */
  106177. getClassName(): string;
  106178. }
  106179. }
  106180. declare module BABYLON {
  106181. /**
  106182. * Listen to keyboard events to control the camera.
  106183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106184. */
  106185. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106186. /**
  106187. * Defines the camera the input is attached to.
  106188. */
  106189. camera: FlyCamera;
  106190. /**
  106191. * The list of keyboard keys used to control the forward move of the camera.
  106192. */
  106193. keysForward: number[];
  106194. /**
  106195. * The list of keyboard keys used to control the backward move of the camera.
  106196. */
  106197. keysBackward: number[];
  106198. /**
  106199. * The list of keyboard keys used to control the forward move of the camera.
  106200. */
  106201. keysUp: number[];
  106202. /**
  106203. * The list of keyboard keys used to control the backward move of the camera.
  106204. */
  106205. keysDown: number[];
  106206. /**
  106207. * The list of keyboard keys used to control the right strafe move of the camera.
  106208. */
  106209. keysRight: number[];
  106210. /**
  106211. * The list of keyboard keys used to control the left strafe move of the camera.
  106212. */
  106213. keysLeft: number[];
  106214. private _keys;
  106215. private _onCanvasBlurObserver;
  106216. private _onKeyboardObserver;
  106217. private _engine;
  106218. private _scene;
  106219. /**
  106220. * Attach the input controls to a specific dom element to get the input from.
  106221. * @param element Defines the element the controls should be listened from
  106222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106223. */
  106224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106225. /**
  106226. * Detach the current controls from the specified dom element.
  106227. * @param element Defines the element to stop listening the inputs from
  106228. */
  106229. detachControl(element: Nullable<HTMLElement>): void;
  106230. /**
  106231. * Gets the class name of the current intput.
  106232. * @returns the class name
  106233. */
  106234. getClassName(): string;
  106235. /** @hidden */
  106236. _onLostFocus(e: FocusEvent): void;
  106237. /**
  106238. * Get the friendly name associated with the input class.
  106239. * @returns the input friendly name
  106240. */
  106241. getSimpleName(): string;
  106242. /**
  106243. * Update the current camera state depending on the inputs that have been used this frame.
  106244. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106245. */
  106246. checkInputs(): void;
  106247. }
  106248. }
  106249. declare module BABYLON {
  106250. /**
  106251. * Manage the mouse wheel inputs to control a follow camera.
  106252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106253. */
  106254. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106255. /**
  106256. * Defines the camera the input is attached to.
  106257. */
  106258. camera: FollowCamera;
  106259. /**
  106260. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106261. */
  106262. axisControlRadius: boolean;
  106263. /**
  106264. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106265. */
  106266. axisControlHeight: boolean;
  106267. /**
  106268. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106269. */
  106270. axisControlRotation: boolean;
  106271. /**
  106272. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106273. * relation to mouseWheel events.
  106274. */
  106275. wheelPrecision: number;
  106276. /**
  106277. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106278. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106279. */
  106280. wheelDeltaPercentage: number;
  106281. private _wheel;
  106282. private _observer;
  106283. /**
  106284. * Attach the input controls to a specific dom element to get the input from.
  106285. * @param element Defines the element the controls should be listened from
  106286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106287. */
  106288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106289. /**
  106290. * Detach the current controls from the specified dom element.
  106291. * @param element Defines the element to stop listening the inputs from
  106292. */
  106293. detachControl(element: Nullable<HTMLElement>): void;
  106294. /**
  106295. * Gets the class name of the current intput.
  106296. * @returns the class name
  106297. */
  106298. getClassName(): string;
  106299. /**
  106300. * Get the friendly name associated with the input class.
  106301. * @returns the input friendly name
  106302. */
  106303. getSimpleName(): string;
  106304. }
  106305. }
  106306. declare module BABYLON {
  106307. /**
  106308. * Manage the pointers inputs to control an follow camera.
  106309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106310. */
  106311. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106312. /**
  106313. * Defines the camera the input is attached to.
  106314. */
  106315. camera: FollowCamera;
  106316. /**
  106317. * Gets the class name of the current input.
  106318. * @returns the class name
  106319. */
  106320. getClassName(): string;
  106321. /**
  106322. * Defines the pointer angular sensibility along the X axis or how fast is
  106323. * the camera rotating.
  106324. * A negative number will reverse the axis direction.
  106325. */
  106326. angularSensibilityX: number;
  106327. /**
  106328. * Defines the pointer angular sensibility along the Y axis or how fast is
  106329. * the camera rotating.
  106330. * A negative number will reverse the axis direction.
  106331. */
  106332. angularSensibilityY: number;
  106333. /**
  106334. * Defines the pointer pinch precision or how fast is the camera zooming.
  106335. * A negative number will reverse the axis direction.
  106336. */
  106337. pinchPrecision: number;
  106338. /**
  106339. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106340. * from 0.
  106341. * It defines the percentage of current camera.radius to use as delta when
  106342. * pinch zoom is used.
  106343. */
  106344. pinchDeltaPercentage: number;
  106345. /**
  106346. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106347. */
  106348. axisXControlRadius: boolean;
  106349. /**
  106350. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106351. */
  106352. axisXControlHeight: boolean;
  106353. /**
  106354. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106355. */
  106356. axisXControlRotation: boolean;
  106357. /**
  106358. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106359. */
  106360. axisYControlRadius: boolean;
  106361. /**
  106362. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106363. */
  106364. axisYControlHeight: boolean;
  106365. /**
  106366. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106367. */
  106368. axisYControlRotation: boolean;
  106369. /**
  106370. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106371. */
  106372. axisPinchControlRadius: boolean;
  106373. /**
  106374. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106375. */
  106376. axisPinchControlHeight: boolean;
  106377. /**
  106378. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106379. */
  106380. axisPinchControlRotation: boolean;
  106381. /**
  106382. * Log error messages if basic misconfiguration has occurred.
  106383. */
  106384. warningEnable: boolean;
  106385. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106386. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106387. private _warningCounter;
  106388. private _warning;
  106389. }
  106390. }
  106391. declare module BABYLON {
  106392. /**
  106393. * Default Inputs manager for the FollowCamera.
  106394. * It groups all the default supported inputs for ease of use.
  106395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106396. */
  106397. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106398. /**
  106399. * Instantiates a new FollowCameraInputsManager.
  106400. * @param camera Defines the camera the inputs belong to
  106401. */
  106402. constructor(camera: FollowCamera);
  106403. /**
  106404. * Add keyboard input support to the input manager.
  106405. * @returns the current input manager
  106406. */
  106407. addKeyboard(): FollowCameraInputsManager;
  106408. /**
  106409. * Add mouse wheel input support to the input manager.
  106410. * @returns the current input manager
  106411. */
  106412. addMouseWheel(): FollowCameraInputsManager;
  106413. /**
  106414. * Add pointers input support to the input manager.
  106415. * @returns the current input manager
  106416. */
  106417. addPointers(): FollowCameraInputsManager;
  106418. /**
  106419. * Add orientation input support to the input manager.
  106420. * @returns the current input manager
  106421. */
  106422. addVRDeviceOrientation(): FollowCameraInputsManager;
  106423. }
  106424. }
  106425. declare module BABYLON {
  106426. /**
  106427. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106428. * an arc rotate version arcFollowCamera are available.
  106429. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106430. */
  106431. export class FollowCamera extends TargetCamera {
  106432. /**
  106433. * Distance the follow camera should follow an object at
  106434. */
  106435. radius: number;
  106436. /**
  106437. * Minimum allowed distance of the camera to the axis of rotation
  106438. * (The camera can not get closer).
  106439. * This can help limiting how the Camera is able to move in the scene.
  106440. */
  106441. lowerRadiusLimit: Nullable<number>;
  106442. /**
  106443. * Maximum allowed distance of the camera to the axis of rotation
  106444. * (The camera can not get further).
  106445. * This can help limiting how the Camera is able to move in the scene.
  106446. */
  106447. upperRadiusLimit: Nullable<number>;
  106448. /**
  106449. * Define a rotation offset between the camera and the object it follows
  106450. */
  106451. rotationOffset: number;
  106452. /**
  106453. * Minimum allowed angle to camera position relative to target object.
  106454. * This can help limiting how the Camera is able to move in the scene.
  106455. */
  106456. lowerRotationOffsetLimit: Nullable<number>;
  106457. /**
  106458. * Maximum allowed angle to camera position relative to target object.
  106459. * This can help limiting how the Camera is able to move in the scene.
  106460. */
  106461. upperRotationOffsetLimit: Nullable<number>;
  106462. /**
  106463. * Define a height offset between the camera and the object it follows.
  106464. * It can help following an object from the top (like a car chaing a plane)
  106465. */
  106466. heightOffset: number;
  106467. /**
  106468. * Minimum allowed height of camera position relative to target object.
  106469. * This can help limiting how the Camera is able to move in the scene.
  106470. */
  106471. lowerHeightOffsetLimit: Nullable<number>;
  106472. /**
  106473. * Maximum allowed height of camera position relative to target object.
  106474. * This can help limiting how the Camera is able to move in the scene.
  106475. */
  106476. upperHeightOffsetLimit: Nullable<number>;
  106477. /**
  106478. * Define how fast the camera can accelerate to follow it s target.
  106479. */
  106480. cameraAcceleration: number;
  106481. /**
  106482. * Define the speed limit of the camera following an object.
  106483. */
  106484. maxCameraSpeed: number;
  106485. /**
  106486. * Define the target of the camera.
  106487. */
  106488. lockedTarget: Nullable<AbstractMesh>;
  106489. /**
  106490. * Defines the input associated with the camera.
  106491. */
  106492. inputs: FollowCameraInputsManager;
  106493. /**
  106494. * Instantiates the follow camera.
  106495. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106496. * @param name Define the name of the camera in the scene
  106497. * @param position Define the position of the camera
  106498. * @param scene Define the scene the camera belong to
  106499. * @param lockedTarget Define the target of the camera
  106500. */
  106501. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106502. private _follow;
  106503. /**
  106504. * Attached controls to the current camera.
  106505. * @param element Defines the element the controls should be listened from
  106506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106507. */
  106508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106509. /**
  106510. * Detach the current controls from the camera.
  106511. * The camera will stop reacting to inputs.
  106512. * @param element Defines the element to stop listening the inputs from
  106513. */
  106514. detachControl(element: HTMLElement): void;
  106515. /** @hidden */
  106516. _checkInputs(): void;
  106517. private _checkLimits;
  106518. /**
  106519. * Gets the camera class name.
  106520. * @returns the class name
  106521. */
  106522. getClassName(): string;
  106523. }
  106524. /**
  106525. * Arc Rotate version of the follow camera.
  106526. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106527. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106528. */
  106529. export class ArcFollowCamera extends TargetCamera {
  106530. /** The longitudinal angle of the camera */
  106531. alpha: number;
  106532. /** The latitudinal angle of the camera */
  106533. beta: number;
  106534. /** The radius of the camera from its target */
  106535. radius: number;
  106536. /** Define the camera target (the messh it should follow) */
  106537. target: Nullable<AbstractMesh>;
  106538. private _cartesianCoordinates;
  106539. /**
  106540. * Instantiates a new ArcFollowCamera
  106541. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106542. * @param name Define the name of the camera
  106543. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106544. * @param beta Define the rotation angle of the camera around the elevation axis
  106545. * @param radius Define the radius of the camera from its target point
  106546. * @param target Define the target of the camera
  106547. * @param scene Define the scene the camera belongs to
  106548. */
  106549. constructor(name: string,
  106550. /** The longitudinal angle of the camera */
  106551. alpha: number,
  106552. /** The latitudinal angle of the camera */
  106553. beta: number,
  106554. /** The radius of the camera from its target */
  106555. radius: number,
  106556. /** Define the camera target (the messh it should follow) */
  106557. target: Nullable<AbstractMesh>, scene: Scene);
  106558. private _follow;
  106559. /** @hidden */
  106560. _checkInputs(): void;
  106561. /**
  106562. * Returns the class name of the object.
  106563. * It is mostly used internally for serialization purposes.
  106564. */
  106565. getClassName(): string;
  106566. }
  106567. }
  106568. declare module BABYLON {
  106569. /**
  106570. * Manage the keyboard inputs to control the movement of a follow camera.
  106571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106572. */
  106573. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106574. /**
  106575. * Defines the camera the input is attached to.
  106576. */
  106577. camera: FollowCamera;
  106578. /**
  106579. * Defines the list of key codes associated with the up action (increase heightOffset)
  106580. */
  106581. keysHeightOffsetIncr: number[];
  106582. /**
  106583. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106584. */
  106585. keysHeightOffsetDecr: number[];
  106586. /**
  106587. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106588. */
  106589. keysHeightOffsetModifierAlt: boolean;
  106590. /**
  106591. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106592. */
  106593. keysHeightOffsetModifierCtrl: boolean;
  106594. /**
  106595. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106596. */
  106597. keysHeightOffsetModifierShift: boolean;
  106598. /**
  106599. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106600. */
  106601. keysRotationOffsetIncr: number[];
  106602. /**
  106603. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106604. */
  106605. keysRotationOffsetDecr: number[];
  106606. /**
  106607. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106608. */
  106609. keysRotationOffsetModifierAlt: boolean;
  106610. /**
  106611. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106612. */
  106613. keysRotationOffsetModifierCtrl: boolean;
  106614. /**
  106615. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106616. */
  106617. keysRotationOffsetModifierShift: boolean;
  106618. /**
  106619. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106620. */
  106621. keysRadiusIncr: number[];
  106622. /**
  106623. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106624. */
  106625. keysRadiusDecr: number[];
  106626. /**
  106627. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106628. */
  106629. keysRadiusModifierAlt: boolean;
  106630. /**
  106631. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106632. */
  106633. keysRadiusModifierCtrl: boolean;
  106634. /**
  106635. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106636. */
  106637. keysRadiusModifierShift: boolean;
  106638. /**
  106639. * Defines the rate of change of heightOffset.
  106640. */
  106641. heightSensibility: number;
  106642. /**
  106643. * Defines the rate of change of rotationOffset.
  106644. */
  106645. rotationSensibility: number;
  106646. /**
  106647. * Defines the rate of change of radius.
  106648. */
  106649. radiusSensibility: number;
  106650. private _keys;
  106651. private _ctrlPressed;
  106652. private _altPressed;
  106653. private _shiftPressed;
  106654. private _onCanvasBlurObserver;
  106655. private _onKeyboardObserver;
  106656. private _engine;
  106657. private _scene;
  106658. /**
  106659. * Attach the input controls to a specific dom element to get the input from.
  106660. * @param element Defines the element the controls should be listened from
  106661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106662. */
  106663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106664. /**
  106665. * Detach the current controls from the specified dom element.
  106666. * @param element Defines the element to stop listening the inputs from
  106667. */
  106668. detachControl(element: Nullable<HTMLElement>): void;
  106669. /**
  106670. * Update the current camera state depending on the inputs that have been used this frame.
  106671. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106672. */
  106673. checkInputs(): void;
  106674. /**
  106675. * Gets the class name of the current input.
  106676. * @returns the class name
  106677. */
  106678. getClassName(): string;
  106679. /**
  106680. * Get the friendly name associated with the input class.
  106681. * @returns the input friendly name
  106682. */
  106683. getSimpleName(): string;
  106684. /**
  106685. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106686. * allow modification of the heightOffset value.
  106687. */
  106688. private _modifierHeightOffset;
  106689. /**
  106690. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106691. * allow modification of the rotationOffset value.
  106692. */
  106693. private _modifierRotationOffset;
  106694. /**
  106695. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106696. * allow modification of the radius value.
  106697. */
  106698. private _modifierRadius;
  106699. }
  106700. }
  106701. declare module BABYLON {
  106702. interface FreeCameraInputsManager {
  106703. /**
  106704. * @hidden
  106705. */
  106706. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106707. /**
  106708. * Add orientation input support to the input manager.
  106709. * @returns the current input manager
  106710. */
  106711. addDeviceOrientation(): FreeCameraInputsManager;
  106712. }
  106713. /**
  106714. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106715. * Screen rotation is taken into account.
  106716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106717. */
  106718. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106719. private _camera;
  106720. private _screenOrientationAngle;
  106721. private _constantTranform;
  106722. private _screenQuaternion;
  106723. private _alpha;
  106724. private _beta;
  106725. private _gamma;
  106726. /**
  106727. * Can be used to detect if a device orientation sensor is availible on a device
  106728. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106729. * @returns a promise that will resolve on orientation change
  106730. */
  106731. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106732. /**
  106733. * @hidden
  106734. */
  106735. _onDeviceOrientationChangedObservable: Observable<void>;
  106736. /**
  106737. * Instantiates a new input
  106738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106739. */
  106740. constructor();
  106741. /**
  106742. * Define the camera controlled by the input.
  106743. */
  106744. camera: FreeCamera;
  106745. /**
  106746. * Attach the input controls to a specific dom element to get the input from.
  106747. * @param element Defines the element the controls should be listened from
  106748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106749. */
  106750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106751. private _orientationChanged;
  106752. private _deviceOrientation;
  106753. /**
  106754. * Detach the current controls from the specified dom element.
  106755. * @param element Defines the element to stop listening the inputs from
  106756. */
  106757. detachControl(element: Nullable<HTMLElement>): void;
  106758. /**
  106759. * Update the current camera state depending on the inputs that have been used this frame.
  106760. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106761. */
  106762. checkInputs(): void;
  106763. /**
  106764. * Gets the class name of the current intput.
  106765. * @returns the class name
  106766. */
  106767. getClassName(): string;
  106768. /**
  106769. * Get the friendly name associated with the input class.
  106770. * @returns the input friendly name
  106771. */
  106772. getSimpleName(): string;
  106773. }
  106774. }
  106775. declare module BABYLON {
  106776. /**
  106777. * Manage the gamepad inputs to control a free camera.
  106778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106779. */
  106780. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  106781. /**
  106782. * Define the camera the input is attached to.
  106783. */
  106784. camera: FreeCamera;
  106785. /**
  106786. * Define the Gamepad controlling the input
  106787. */
  106788. gamepad: Nullable<Gamepad>;
  106789. /**
  106790. * Defines the gamepad rotation sensiblity.
  106791. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106792. */
  106793. gamepadAngularSensibility: number;
  106794. /**
  106795. * Defines the gamepad move sensiblity.
  106796. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106797. */
  106798. gamepadMoveSensibility: number;
  106799. private _yAxisScale;
  106800. /**
  106801. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106802. */
  106803. invertYAxis: boolean;
  106804. private _onGamepadConnectedObserver;
  106805. private _onGamepadDisconnectedObserver;
  106806. private _cameraTransform;
  106807. private _deltaTransform;
  106808. private _vector3;
  106809. private _vector2;
  106810. /**
  106811. * Attach the input controls to a specific dom element to get the input from.
  106812. * @param element Defines the element the controls should be listened from
  106813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106814. */
  106815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106816. /**
  106817. * Detach the current controls from the specified dom element.
  106818. * @param element Defines the element to stop listening the inputs from
  106819. */
  106820. detachControl(element: Nullable<HTMLElement>): void;
  106821. /**
  106822. * Update the current camera state depending on the inputs that have been used this frame.
  106823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106824. */
  106825. checkInputs(): void;
  106826. /**
  106827. * Gets the class name of the current intput.
  106828. * @returns the class name
  106829. */
  106830. getClassName(): string;
  106831. /**
  106832. * Get the friendly name associated with the input class.
  106833. * @returns the input friendly name
  106834. */
  106835. getSimpleName(): string;
  106836. }
  106837. }
  106838. declare module BABYLON {
  106839. /**
  106840. * Defines the potential axis of a Joystick
  106841. */
  106842. export enum JoystickAxis {
  106843. /** X axis */
  106844. X = 0,
  106845. /** Y axis */
  106846. Y = 1,
  106847. /** Z axis */
  106848. Z = 2
  106849. }
  106850. /**
  106851. * Class used to define virtual joystick (used in touch mode)
  106852. */
  106853. export class VirtualJoystick {
  106854. /**
  106855. * Gets or sets a boolean indicating that left and right values must be inverted
  106856. */
  106857. reverseLeftRight: boolean;
  106858. /**
  106859. * Gets or sets a boolean indicating that up and down values must be inverted
  106860. */
  106861. reverseUpDown: boolean;
  106862. /**
  106863. * Gets the offset value for the position (ie. the change of the position value)
  106864. */
  106865. deltaPosition: Vector3;
  106866. /**
  106867. * Gets a boolean indicating if the virtual joystick was pressed
  106868. */
  106869. pressed: boolean;
  106870. /**
  106871. * Canvas the virtual joystick will render onto, default z-index of this is 5
  106872. */
  106873. static Canvas: Nullable<HTMLCanvasElement>;
  106874. private static _globalJoystickIndex;
  106875. private static vjCanvasContext;
  106876. private static vjCanvasWidth;
  106877. private static vjCanvasHeight;
  106878. private static halfWidth;
  106879. private _action;
  106880. private _axisTargetedByLeftAndRight;
  106881. private _axisTargetedByUpAndDown;
  106882. private _joystickSensibility;
  106883. private _inversedSensibility;
  106884. private _joystickPointerID;
  106885. private _joystickColor;
  106886. private _joystickPointerPos;
  106887. private _joystickPreviousPointerPos;
  106888. private _joystickPointerStartPos;
  106889. private _deltaJoystickVector;
  106890. private _leftJoystick;
  106891. private _touches;
  106892. private _onPointerDownHandlerRef;
  106893. private _onPointerMoveHandlerRef;
  106894. private _onPointerUpHandlerRef;
  106895. private _onResize;
  106896. /**
  106897. * Creates a new virtual joystick
  106898. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106899. */
  106900. constructor(leftJoystick?: boolean);
  106901. /**
  106902. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106903. * @param newJoystickSensibility defines the new sensibility
  106904. */
  106905. setJoystickSensibility(newJoystickSensibility: number): void;
  106906. private _onPointerDown;
  106907. private _onPointerMove;
  106908. private _onPointerUp;
  106909. /**
  106910. * Change the color of the virtual joystick
  106911. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106912. */
  106913. setJoystickColor(newColor: string): void;
  106914. /**
  106915. * Defines a callback to call when the joystick is touched
  106916. * @param action defines the callback
  106917. */
  106918. setActionOnTouch(action: () => any): void;
  106919. /**
  106920. * Defines which axis you'd like to control for left & right
  106921. * @param axis defines the axis to use
  106922. */
  106923. setAxisForLeftRight(axis: JoystickAxis): void;
  106924. /**
  106925. * Defines which axis you'd like to control for up & down
  106926. * @param axis defines the axis to use
  106927. */
  106928. setAxisForUpDown(axis: JoystickAxis): void;
  106929. private _drawVirtualJoystick;
  106930. /**
  106931. * Release internal HTML canvas
  106932. */
  106933. releaseCanvas(): void;
  106934. }
  106935. }
  106936. declare module BABYLON {
  106937. interface FreeCameraInputsManager {
  106938. /**
  106939. * Add virtual joystick input support to the input manager.
  106940. * @returns the current input manager
  106941. */
  106942. addVirtualJoystick(): FreeCameraInputsManager;
  106943. }
  106944. /**
  106945. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106947. */
  106948. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106949. /**
  106950. * Defines the camera the input is attached to.
  106951. */
  106952. camera: FreeCamera;
  106953. private _leftjoystick;
  106954. private _rightjoystick;
  106955. /**
  106956. * Gets the left stick of the virtual joystick.
  106957. * @returns The virtual Joystick
  106958. */
  106959. getLeftJoystick(): VirtualJoystick;
  106960. /**
  106961. * Gets the right stick of the virtual joystick.
  106962. * @returns The virtual Joystick
  106963. */
  106964. getRightJoystick(): VirtualJoystick;
  106965. /**
  106966. * Update the current camera state depending on the inputs that have been used this frame.
  106967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106968. */
  106969. checkInputs(): void;
  106970. /**
  106971. * Attach the input controls to a specific dom element to get the input from.
  106972. * @param element Defines the element the controls should be listened from
  106973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106974. */
  106975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106976. /**
  106977. * Detach the current controls from the specified dom element.
  106978. * @param element Defines the element to stop listening the inputs from
  106979. */
  106980. detachControl(element: Nullable<HTMLElement>): void;
  106981. /**
  106982. * Gets the class name of the current intput.
  106983. * @returns the class name
  106984. */
  106985. getClassName(): string;
  106986. /**
  106987. * Get the friendly name associated with the input class.
  106988. * @returns the input friendly name
  106989. */
  106990. getSimpleName(): string;
  106991. }
  106992. }
  106993. declare module BABYLON {
  106994. /**
  106995. * This represents a FPS type of camera controlled by touch.
  106996. * This is like a universal camera minus the Gamepad controls.
  106997. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106998. */
  106999. export class TouchCamera extends FreeCamera {
  107000. /**
  107001. * Defines the touch sensibility for rotation.
  107002. * The higher the faster.
  107003. */
  107004. touchAngularSensibility: number;
  107005. /**
  107006. * Defines the touch sensibility for move.
  107007. * The higher the faster.
  107008. */
  107009. touchMoveSensibility: number;
  107010. /**
  107011. * Instantiates a new touch camera.
  107012. * This represents a FPS type of camera controlled by touch.
  107013. * This is like a universal camera minus the Gamepad controls.
  107014. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107015. * @param name Define the name of the camera in the scene
  107016. * @param position Define the start position of the camera in the scene
  107017. * @param scene Define the scene the camera belongs to
  107018. */
  107019. constructor(name: string, position: Vector3, scene: Scene);
  107020. /**
  107021. * Gets the current object class name.
  107022. * @return the class name
  107023. */
  107024. getClassName(): string;
  107025. /** @hidden */
  107026. _setupInputs(): void;
  107027. }
  107028. }
  107029. declare module BABYLON {
  107030. /**
  107031. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107032. * being tilted forward or back and left or right.
  107033. */
  107034. export class DeviceOrientationCamera extends FreeCamera {
  107035. private _initialQuaternion;
  107036. private _quaternionCache;
  107037. private _tmpDragQuaternion;
  107038. private _disablePointerInputWhenUsingDeviceOrientation;
  107039. /**
  107040. * Creates a new device orientation camera
  107041. * @param name The name of the camera
  107042. * @param position The start position camera
  107043. * @param scene The scene the camera belongs to
  107044. */
  107045. constructor(name: string, position: Vector3, scene: Scene);
  107046. /**
  107047. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107048. */
  107049. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107050. private _dragFactor;
  107051. /**
  107052. * Enabled turning on the y axis when the orientation sensor is active
  107053. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107054. */
  107055. enableHorizontalDragging(dragFactor?: number): void;
  107056. /**
  107057. * Gets the current instance class name ("DeviceOrientationCamera").
  107058. * This helps avoiding instanceof at run time.
  107059. * @returns the class name
  107060. */
  107061. getClassName(): string;
  107062. /**
  107063. * @hidden
  107064. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107065. */
  107066. _checkInputs(): void;
  107067. /**
  107068. * Reset the camera to its default orientation on the specified axis only.
  107069. * @param axis The axis to reset
  107070. */
  107071. resetToCurrentRotation(axis?: Axis): void;
  107072. }
  107073. }
  107074. declare module BABYLON {
  107075. /**
  107076. * Defines supported buttons for XBox360 compatible gamepads
  107077. */
  107078. export enum Xbox360Button {
  107079. /** A */
  107080. A = 0,
  107081. /** B */
  107082. B = 1,
  107083. /** X */
  107084. X = 2,
  107085. /** Y */
  107086. Y = 3,
  107087. /** Start */
  107088. Start = 4,
  107089. /** Back */
  107090. Back = 5,
  107091. /** Left button */
  107092. LB = 6,
  107093. /** Right button */
  107094. RB = 7,
  107095. /** Left stick */
  107096. LeftStick = 8,
  107097. /** Right stick */
  107098. RightStick = 9
  107099. }
  107100. /** Defines values for XBox360 DPad */
  107101. export enum Xbox360Dpad {
  107102. /** Up */
  107103. Up = 0,
  107104. /** Down */
  107105. Down = 1,
  107106. /** Left */
  107107. Left = 2,
  107108. /** Right */
  107109. Right = 3
  107110. }
  107111. /**
  107112. * Defines a XBox360 gamepad
  107113. */
  107114. export class Xbox360Pad extends Gamepad {
  107115. private _leftTrigger;
  107116. private _rightTrigger;
  107117. private _onlefttriggerchanged;
  107118. private _onrighttriggerchanged;
  107119. private _onbuttondown;
  107120. private _onbuttonup;
  107121. private _ondpaddown;
  107122. private _ondpadup;
  107123. /** Observable raised when a button is pressed */
  107124. onButtonDownObservable: Observable<Xbox360Button>;
  107125. /** Observable raised when a button is released */
  107126. onButtonUpObservable: Observable<Xbox360Button>;
  107127. /** Observable raised when a pad is pressed */
  107128. onPadDownObservable: Observable<Xbox360Dpad>;
  107129. /** Observable raised when a pad is released */
  107130. onPadUpObservable: Observable<Xbox360Dpad>;
  107131. private _buttonA;
  107132. private _buttonB;
  107133. private _buttonX;
  107134. private _buttonY;
  107135. private _buttonBack;
  107136. private _buttonStart;
  107137. private _buttonLB;
  107138. private _buttonRB;
  107139. private _buttonLeftStick;
  107140. private _buttonRightStick;
  107141. private _dPadUp;
  107142. private _dPadDown;
  107143. private _dPadLeft;
  107144. private _dPadRight;
  107145. private _isXboxOnePad;
  107146. /**
  107147. * Creates a new XBox360 gamepad object
  107148. * @param id defines the id of this gamepad
  107149. * @param index defines its index
  107150. * @param gamepad defines the internal HTML gamepad object
  107151. * @param xboxOne defines if it is a XBox One gamepad
  107152. */
  107153. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107154. /**
  107155. * Defines the callback to call when left trigger is pressed
  107156. * @param callback defines the callback to use
  107157. */
  107158. onlefttriggerchanged(callback: (value: number) => void): void;
  107159. /**
  107160. * Defines the callback to call when right trigger is pressed
  107161. * @param callback defines the callback to use
  107162. */
  107163. onrighttriggerchanged(callback: (value: number) => void): void;
  107164. /**
  107165. * Gets the left trigger value
  107166. */
  107167. /**
  107168. * Sets the left trigger value
  107169. */
  107170. leftTrigger: number;
  107171. /**
  107172. * Gets the right trigger value
  107173. */
  107174. /**
  107175. * Sets the right trigger value
  107176. */
  107177. rightTrigger: number;
  107178. /**
  107179. * Defines the callback to call when a button is pressed
  107180. * @param callback defines the callback to use
  107181. */
  107182. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107183. /**
  107184. * Defines the callback to call when a button is released
  107185. * @param callback defines the callback to use
  107186. */
  107187. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107188. /**
  107189. * Defines the callback to call when a pad is pressed
  107190. * @param callback defines the callback to use
  107191. */
  107192. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107193. /**
  107194. * Defines the callback to call when a pad is released
  107195. * @param callback defines the callback to use
  107196. */
  107197. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107198. private _setButtonValue;
  107199. private _setDPadValue;
  107200. /**
  107201. * Gets the value of the `A` button
  107202. */
  107203. /**
  107204. * Sets the value of the `A` button
  107205. */
  107206. buttonA: number;
  107207. /**
  107208. * Gets the value of the `B` button
  107209. */
  107210. /**
  107211. * Sets the value of the `B` button
  107212. */
  107213. buttonB: number;
  107214. /**
  107215. * Gets the value of the `X` button
  107216. */
  107217. /**
  107218. * Sets the value of the `X` button
  107219. */
  107220. buttonX: number;
  107221. /**
  107222. * Gets the value of the `Y` button
  107223. */
  107224. /**
  107225. * Sets the value of the `Y` button
  107226. */
  107227. buttonY: number;
  107228. /**
  107229. * Gets the value of the `Start` button
  107230. */
  107231. /**
  107232. * Sets the value of the `Start` button
  107233. */
  107234. buttonStart: number;
  107235. /**
  107236. * Gets the value of the `Back` button
  107237. */
  107238. /**
  107239. * Sets the value of the `Back` button
  107240. */
  107241. buttonBack: number;
  107242. /**
  107243. * Gets the value of the `Left` button
  107244. */
  107245. /**
  107246. * Sets the value of the `Left` button
  107247. */
  107248. buttonLB: number;
  107249. /**
  107250. * Gets the value of the `Right` button
  107251. */
  107252. /**
  107253. * Sets the value of the `Right` button
  107254. */
  107255. buttonRB: number;
  107256. /**
  107257. * Gets the value of the Left joystick
  107258. */
  107259. /**
  107260. * Sets the value of the Left joystick
  107261. */
  107262. buttonLeftStick: number;
  107263. /**
  107264. * Gets the value of the Right joystick
  107265. */
  107266. /**
  107267. * Sets the value of the Right joystick
  107268. */
  107269. buttonRightStick: number;
  107270. /**
  107271. * Gets the value of D-pad up
  107272. */
  107273. /**
  107274. * Sets the value of D-pad up
  107275. */
  107276. dPadUp: number;
  107277. /**
  107278. * Gets the value of D-pad down
  107279. */
  107280. /**
  107281. * Sets the value of D-pad down
  107282. */
  107283. dPadDown: number;
  107284. /**
  107285. * Gets the value of D-pad left
  107286. */
  107287. /**
  107288. * Sets the value of D-pad left
  107289. */
  107290. dPadLeft: number;
  107291. /**
  107292. * Gets the value of D-pad right
  107293. */
  107294. /**
  107295. * Sets the value of D-pad right
  107296. */
  107297. dPadRight: number;
  107298. /**
  107299. * Force the gamepad to synchronize with device values
  107300. */
  107301. update(): void;
  107302. /**
  107303. * Disposes the gamepad
  107304. */
  107305. dispose(): void;
  107306. }
  107307. }
  107308. declare module BABYLON {
  107309. /**
  107310. * Defines supported buttons for DualShock compatible gamepads
  107311. */
  107312. export enum DualShockButton {
  107313. /** Cross */
  107314. Cross = 0,
  107315. /** Circle */
  107316. Circle = 1,
  107317. /** Square */
  107318. Square = 2,
  107319. /** Triangle */
  107320. Triangle = 3,
  107321. /** Options */
  107322. Options = 4,
  107323. /** Share */
  107324. Share = 5,
  107325. /** L1 */
  107326. L1 = 6,
  107327. /** R1 */
  107328. R1 = 7,
  107329. /** Left stick */
  107330. LeftStick = 8,
  107331. /** Right stick */
  107332. RightStick = 9
  107333. }
  107334. /** Defines values for DualShock DPad */
  107335. export enum DualShockDpad {
  107336. /** Up */
  107337. Up = 0,
  107338. /** Down */
  107339. Down = 1,
  107340. /** Left */
  107341. Left = 2,
  107342. /** Right */
  107343. Right = 3
  107344. }
  107345. /**
  107346. * Defines a DualShock gamepad
  107347. */
  107348. export class DualShockPad extends Gamepad {
  107349. private _leftTrigger;
  107350. private _rightTrigger;
  107351. private _onlefttriggerchanged;
  107352. private _onrighttriggerchanged;
  107353. private _onbuttondown;
  107354. private _onbuttonup;
  107355. private _ondpaddown;
  107356. private _ondpadup;
  107357. /** Observable raised when a button is pressed */
  107358. onButtonDownObservable: Observable<DualShockButton>;
  107359. /** Observable raised when a button is released */
  107360. onButtonUpObservable: Observable<DualShockButton>;
  107361. /** Observable raised when a pad is pressed */
  107362. onPadDownObservable: Observable<DualShockDpad>;
  107363. /** Observable raised when a pad is released */
  107364. onPadUpObservable: Observable<DualShockDpad>;
  107365. private _buttonCross;
  107366. private _buttonCircle;
  107367. private _buttonSquare;
  107368. private _buttonTriangle;
  107369. private _buttonShare;
  107370. private _buttonOptions;
  107371. private _buttonL1;
  107372. private _buttonR1;
  107373. private _buttonLeftStick;
  107374. private _buttonRightStick;
  107375. private _dPadUp;
  107376. private _dPadDown;
  107377. private _dPadLeft;
  107378. private _dPadRight;
  107379. /**
  107380. * Creates a new DualShock gamepad object
  107381. * @param id defines the id of this gamepad
  107382. * @param index defines its index
  107383. * @param gamepad defines the internal HTML gamepad object
  107384. */
  107385. constructor(id: string, index: number, gamepad: any);
  107386. /**
  107387. * Defines the callback to call when left trigger is pressed
  107388. * @param callback defines the callback to use
  107389. */
  107390. onlefttriggerchanged(callback: (value: number) => void): void;
  107391. /**
  107392. * Defines the callback to call when right trigger is pressed
  107393. * @param callback defines the callback to use
  107394. */
  107395. onrighttriggerchanged(callback: (value: number) => void): void;
  107396. /**
  107397. * Gets the left trigger value
  107398. */
  107399. /**
  107400. * Sets the left trigger value
  107401. */
  107402. leftTrigger: number;
  107403. /**
  107404. * Gets the right trigger value
  107405. */
  107406. /**
  107407. * Sets the right trigger value
  107408. */
  107409. rightTrigger: number;
  107410. /**
  107411. * Defines the callback to call when a button is pressed
  107412. * @param callback defines the callback to use
  107413. */
  107414. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107415. /**
  107416. * Defines the callback to call when a button is released
  107417. * @param callback defines the callback to use
  107418. */
  107419. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107420. /**
  107421. * Defines the callback to call when a pad is pressed
  107422. * @param callback defines the callback to use
  107423. */
  107424. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107425. /**
  107426. * Defines the callback to call when a pad is released
  107427. * @param callback defines the callback to use
  107428. */
  107429. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107430. private _setButtonValue;
  107431. private _setDPadValue;
  107432. /**
  107433. * Gets the value of the `Cross` button
  107434. */
  107435. /**
  107436. * Sets the value of the `Cross` button
  107437. */
  107438. buttonCross: number;
  107439. /**
  107440. * Gets the value of the `Circle` button
  107441. */
  107442. /**
  107443. * Sets the value of the `Circle` button
  107444. */
  107445. buttonCircle: number;
  107446. /**
  107447. * Gets the value of the `Square` button
  107448. */
  107449. /**
  107450. * Sets the value of the `Square` button
  107451. */
  107452. buttonSquare: number;
  107453. /**
  107454. * Gets the value of the `Triangle` button
  107455. */
  107456. /**
  107457. * Sets the value of the `Triangle` button
  107458. */
  107459. buttonTriangle: number;
  107460. /**
  107461. * Gets the value of the `Options` button
  107462. */
  107463. /**
  107464. * Sets the value of the `Options` button
  107465. */
  107466. buttonOptions: number;
  107467. /**
  107468. * Gets the value of the `Share` button
  107469. */
  107470. /**
  107471. * Sets the value of the `Share` button
  107472. */
  107473. buttonShare: number;
  107474. /**
  107475. * Gets the value of the `L1` button
  107476. */
  107477. /**
  107478. * Sets the value of the `L1` button
  107479. */
  107480. buttonL1: number;
  107481. /**
  107482. * Gets the value of the `R1` button
  107483. */
  107484. /**
  107485. * Sets the value of the `R1` button
  107486. */
  107487. buttonR1: number;
  107488. /**
  107489. * Gets the value of the Left joystick
  107490. */
  107491. /**
  107492. * Sets the value of the Left joystick
  107493. */
  107494. buttonLeftStick: number;
  107495. /**
  107496. * Gets the value of the Right joystick
  107497. */
  107498. /**
  107499. * Sets the value of the Right joystick
  107500. */
  107501. buttonRightStick: number;
  107502. /**
  107503. * Gets the value of D-pad up
  107504. */
  107505. /**
  107506. * Sets the value of D-pad up
  107507. */
  107508. dPadUp: number;
  107509. /**
  107510. * Gets the value of D-pad down
  107511. */
  107512. /**
  107513. * Sets the value of D-pad down
  107514. */
  107515. dPadDown: number;
  107516. /**
  107517. * Gets the value of D-pad left
  107518. */
  107519. /**
  107520. * Sets the value of D-pad left
  107521. */
  107522. dPadLeft: number;
  107523. /**
  107524. * Gets the value of D-pad right
  107525. */
  107526. /**
  107527. * Sets the value of D-pad right
  107528. */
  107529. dPadRight: number;
  107530. /**
  107531. * Force the gamepad to synchronize with device values
  107532. */
  107533. update(): void;
  107534. /**
  107535. * Disposes the gamepad
  107536. */
  107537. dispose(): void;
  107538. }
  107539. }
  107540. declare module BABYLON {
  107541. /**
  107542. * Manager for handling gamepads
  107543. */
  107544. export class GamepadManager {
  107545. private _scene?;
  107546. private _babylonGamepads;
  107547. private _oneGamepadConnected;
  107548. /** @hidden */
  107549. _isMonitoring: boolean;
  107550. private _gamepadEventSupported;
  107551. private _gamepadSupport;
  107552. /**
  107553. * observable to be triggered when the gamepad controller has been connected
  107554. */
  107555. onGamepadConnectedObservable: Observable<Gamepad>;
  107556. /**
  107557. * observable to be triggered when the gamepad controller has been disconnected
  107558. */
  107559. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107560. private _onGamepadConnectedEvent;
  107561. private _onGamepadDisconnectedEvent;
  107562. /**
  107563. * Initializes the gamepad manager
  107564. * @param _scene BabylonJS scene
  107565. */
  107566. constructor(_scene?: Scene | undefined);
  107567. /**
  107568. * The gamepads in the game pad manager
  107569. */
  107570. readonly gamepads: Gamepad[];
  107571. /**
  107572. * Get the gamepad controllers based on type
  107573. * @param type The type of gamepad controller
  107574. * @returns Nullable gamepad
  107575. */
  107576. getGamepadByType(type?: number): Nullable<Gamepad>;
  107577. /**
  107578. * Disposes the gamepad manager
  107579. */
  107580. dispose(): void;
  107581. private _addNewGamepad;
  107582. private _startMonitoringGamepads;
  107583. private _stopMonitoringGamepads;
  107584. /** @hidden */
  107585. _checkGamepadsStatus(): void;
  107586. private _updateGamepadObjects;
  107587. }
  107588. }
  107589. declare module BABYLON {
  107590. interface Scene {
  107591. /** @hidden */
  107592. _gamepadManager: Nullable<GamepadManager>;
  107593. /**
  107594. * Gets the gamepad manager associated with the scene
  107595. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107596. */
  107597. gamepadManager: GamepadManager;
  107598. }
  107599. /**
  107600. * Interface representing a free camera inputs manager
  107601. */
  107602. interface FreeCameraInputsManager {
  107603. /**
  107604. * Adds gamepad input support to the FreeCameraInputsManager.
  107605. * @returns the FreeCameraInputsManager
  107606. */
  107607. addGamepad(): FreeCameraInputsManager;
  107608. }
  107609. /**
  107610. * Interface representing an arc rotate camera inputs manager
  107611. */
  107612. interface ArcRotateCameraInputsManager {
  107613. /**
  107614. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107615. * @returns the camera inputs manager
  107616. */
  107617. addGamepad(): ArcRotateCameraInputsManager;
  107618. }
  107619. /**
  107620. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107621. */
  107622. export class GamepadSystemSceneComponent implements ISceneComponent {
  107623. /**
  107624. * The component name helpfull to identify the component in the list of scene components.
  107625. */
  107626. readonly name: string;
  107627. /**
  107628. * The scene the component belongs to.
  107629. */
  107630. scene: Scene;
  107631. /**
  107632. * Creates a new instance of the component for the given scene
  107633. * @param scene Defines the scene to register the component in
  107634. */
  107635. constructor(scene: Scene);
  107636. /**
  107637. * Registers the component in a given scene
  107638. */
  107639. register(): void;
  107640. /**
  107641. * Rebuilds the elements related to this component in case of
  107642. * context lost for instance.
  107643. */
  107644. rebuild(): void;
  107645. /**
  107646. * Disposes the component and the associated ressources
  107647. */
  107648. dispose(): void;
  107649. private _beforeCameraUpdate;
  107650. }
  107651. }
  107652. declare module BABYLON {
  107653. /**
  107654. * 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,
  107655. * which still works and will still be found in many Playgrounds.
  107656. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107657. */
  107658. export class UniversalCamera extends TouchCamera {
  107659. /**
  107660. * Defines the gamepad rotation sensiblity.
  107661. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107662. */
  107663. gamepadAngularSensibility: number;
  107664. /**
  107665. * Defines the gamepad move sensiblity.
  107666. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107667. */
  107668. gamepadMoveSensibility: number;
  107669. /**
  107670. * 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,
  107671. * which still works and will still be found in many Playgrounds.
  107672. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107673. * @param name Define the name of the camera in the scene
  107674. * @param position Define the start position of the camera in the scene
  107675. * @param scene Define the scene the camera belongs to
  107676. */
  107677. constructor(name: string, position: Vector3, scene: Scene);
  107678. /**
  107679. * Gets the current object class name.
  107680. * @return the class name
  107681. */
  107682. getClassName(): string;
  107683. }
  107684. }
  107685. declare module BABYLON {
  107686. /**
  107687. * This represents a FPS type of camera. This is only here for back compat purpose.
  107688. * Please use the UniversalCamera instead as both are identical.
  107689. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107690. */
  107691. export class GamepadCamera extends UniversalCamera {
  107692. /**
  107693. * Instantiates a new Gamepad Camera
  107694. * This represents a FPS type of camera. This is only here for back compat purpose.
  107695. * Please use the UniversalCamera instead as both are identical.
  107696. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107697. * @param name Define the name of the camera in the scene
  107698. * @param position Define the start position of the camera in the scene
  107699. * @param scene Define the scene the camera belongs to
  107700. */
  107701. constructor(name: string, position: Vector3, scene: Scene);
  107702. /**
  107703. * Gets the current object class name.
  107704. * @return the class name
  107705. */
  107706. getClassName(): string;
  107707. }
  107708. }
  107709. declare module BABYLON {
  107710. /** @hidden */
  107711. export var passPixelShader: {
  107712. name: string;
  107713. shader: string;
  107714. };
  107715. }
  107716. declare module BABYLON {
  107717. /** @hidden */
  107718. export var passCubePixelShader: {
  107719. name: string;
  107720. shader: string;
  107721. };
  107722. }
  107723. declare module BABYLON {
  107724. /**
  107725. * PassPostProcess which produces an output the same as it's input
  107726. */
  107727. export class PassPostProcess extends PostProcess {
  107728. /**
  107729. * Creates the PassPostProcess
  107730. * @param name The name of the effect.
  107731. * @param options The required width/height ratio to downsize to before computing the render pass.
  107732. * @param camera The camera to apply the render pass to.
  107733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107734. * @param engine The engine which the post process will be applied. (default: current engine)
  107735. * @param reusable If the post process can be reused on the same frame. (default: false)
  107736. * @param textureType The type of texture to be used when performing the post processing.
  107737. * @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)
  107738. */
  107739. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107740. }
  107741. /**
  107742. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107743. */
  107744. export class PassCubePostProcess extends PostProcess {
  107745. private _face;
  107746. /**
  107747. * Gets or sets the cube face to display.
  107748. * * 0 is +X
  107749. * * 1 is -X
  107750. * * 2 is +Y
  107751. * * 3 is -Y
  107752. * * 4 is +Z
  107753. * * 5 is -Z
  107754. */
  107755. face: number;
  107756. /**
  107757. * Creates the PassCubePostProcess
  107758. * @param name The name of the effect.
  107759. * @param options The required width/height ratio to downsize to before computing the render pass.
  107760. * @param camera The camera to apply the render pass to.
  107761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107762. * @param engine The engine which the post process will be applied. (default: current engine)
  107763. * @param reusable If the post process can be reused on the same frame. (default: false)
  107764. * @param textureType The type of texture to be used when performing the post processing.
  107765. * @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)
  107766. */
  107767. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107768. }
  107769. }
  107770. declare module BABYLON {
  107771. /** @hidden */
  107772. export var anaglyphPixelShader: {
  107773. name: string;
  107774. shader: string;
  107775. };
  107776. }
  107777. declare module BABYLON {
  107778. /**
  107779. * Postprocess used to generate anaglyphic rendering
  107780. */
  107781. export class AnaglyphPostProcess extends PostProcess {
  107782. private _passedProcess;
  107783. /**
  107784. * Creates a new AnaglyphPostProcess
  107785. * @param name defines postprocess name
  107786. * @param options defines creation options or target ratio scale
  107787. * @param rigCameras defines cameras using this postprocess
  107788. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  107789. * @param engine defines hosting engine
  107790. * @param reusable defines if the postprocess will be reused multiple times per frame
  107791. */
  107792. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  107793. }
  107794. }
  107795. declare module BABYLON {
  107796. /**
  107797. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  107798. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107799. */
  107800. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  107801. /**
  107802. * Creates a new AnaglyphArcRotateCamera
  107803. * @param name defines camera name
  107804. * @param alpha defines alpha angle (in radians)
  107805. * @param beta defines beta angle (in radians)
  107806. * @param radius defines radius
  107807. * @param target defines camera target
  107808. * @param interaxialDistance defines distance between each color axis
  107809. * @param scene defines the hosting scene
  107810. */
  107811. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  107812. /**
  107813. * Gets camera class name
  107814. * @returns AnaglyphArcRotateCamera
  107815. */
  107816. getClassName(): string;
  107817. }
  107818. }
  107819. declare module BABYLON {
  107820. /**
  107821. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  107822. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107823. */
  107824. export class AnaglyphFreeCamera extends FreeCamera {
  107825. /**
  107826. * Creates a new AnaglyphFreeCamera
  107827. * @param name defines camera name
  107828. * @param position defines initial position
  107829. * @param interaxialDistance defines distance between each color axis
  107830. * @param scene defines the hosting scene
  107831. */
  107832. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107833. /**
  107834. * Gets camera class name
  107835. * @returns AnaglyphFreeCamera
  107836. */
  107837. getClassName(): string;
  107838. }
  107839. }
  107840. declare module BABYLON {
  107841. /**
  107842. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  107843. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107844. */
  107845. export class AnaglyphGamepadCamera extends GamepadCamera {
  107846. /**
  107847. * Creates a new AnaglyphGamepadCamera
  107848. * @param name defines camera name
  107849. * @param position defines initial position
  107850. * @param interaxialDistance defines distance between each color axis
  107851. * @param scene defines the hosting scene
  107852. */
  107853. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107854. /**
  107855. * Gets camera class name
  107856. * @returns AnaglyphGamepadCamera
  107857. */
  107858. getClassName(): string;
  107859. }
  107860. }
  107861. declare module BABYLON {
  107862. /**
  107863. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  107864. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107865. */
  107866. export class AnaglyphUniversalCamera extends UniversalCamera {
  107867. /**
  107868. * Creates a new AnaglyphUniversalCamera
  107869. * @param name defines camera name
  107870. * @param position defines initial position
  107871. * @param interaxialDistance defines distance between each color axis
  107872. * @param scene defines the hosting scene
  107873. */
  107874. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107875. /**
  107876. * Gets camera class name
  107877. * @returns AnaglyphUniversalCamera
  107878. */
  107879. getClassName(): string;
  107880. }
  107881. }
  107882. declare module BABYLON {
  107883. /** @hidden */
  107884. export var stereoscopicInterlacePixelShader: {
  107885. name: string;
  107886. shader: string;
  107887. };
  107888. }
  107889. declare module BABYLON {
  107890. /**
  107891. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107892. */
  107893. export class StereoscopicInterlacePostProcess extends PostProcess {
  107894. private _stepSize;
  107895. private _passedProcess;
  107896. /**
  107897. * Initializes a StereoscopicInterlacePostProcess
  107898. * @param name The name of the effect.
  107899. * @param rigCameras The rig cameras to be appled to the post process
  107900. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107902. * @param engine The engine which the post process will be applied. (default: current engine)
  107903. * @param reusable If the post process can be reused on the same frame. (default: false)
  107904. */
  107905. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107906. }
  107907. }
  107908. declare module BABYLON {
  107909. /**
  107910. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107911. * @see http://doc.babylonjs.com/features/cameras
  107912. */
  107913. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107914. /**
  107915. * Creates a new StereoscopicArcRotateCamera
  107916. * @param name defines camera name
  107917. * @param alpha defines alpha angle (in radians)
  107918. * @param beta defines beta angle (in radians)
  107919. * @param radius defines radius
  107920. * @param target defines camera target
  107921. * @param interaxialDistance defines distance between each color axis
  107922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107923. * @param scene defines the hosting scene
  107924. */
  107925. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107926. /**
  107927. * Gets camera class name
  107928. * @returns StereoscopicArcRotateCamera
  107929. */
  107930. getClassName(): string;
  107931. }
  107932. }
  107933. declare module BABYLON {
  107934. /**
  107935. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107936. * @see http://doc.babylonjs.com/features/cameras
  107937. */
  107938. export class StereoscopicFreeCamera extends FreeCamera {
  107939. /**
  107940. * Creates a new StereoscopicFreeCamera
  107941. * @param name defines camera name
  107942. * @param position defines initial position
  107943. * @param interaxialDistance defines distance between each color axis
  107944. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107945. * @param scene defines the hosting scene
  107946. */
  107947. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107948. /**
  107949. * Gets camera class name
  107950. * @returns StereoscopicFreeCamera
  107951. */
  107952. getClassName(): string;
  107953. }
  107954. }
  107955. declare module BABYLON {
  107956. /**
  107957. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107958. * @see http://doc.babylonjs.com/features/cameras
  107959. */
  107960. export class StereoscopicGamepadCamera extends GamepadCamera {
  107961. /**
  107962. * Creates a new StereoscopicGamepadCamera
  107963. * @param name defines camera name
  107964. * @param position defines initial position
  107965. * @param interaxialDistance defines distance between each color axis
  107966. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107967. * @param scene defines the hosting scene
  107968. */
  107969. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107970. /**
  107971. * Gets camera class name
  107972. * @returns StereoscopicGamepadCamera
  107973. */
  107974. getClassName(): string;
  107975. }
  107976. }
  107977. declare module BABYLON {
  107978. /**
  107979. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107980. * @see http://doc.babylonjs.com/features/cameras
  107981. */
  107982. export class StereoscopicUniversalCamera extends UniversalCamera {
  107983. /**
  107984. * Creates a new StereoscopicUniversalCamera
  107985. * @param name defines camera name
  107986. * @param position defines initial position
  107987. * @param interaxialDistance defines distance between each color axis
  107988. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107989. * @param scene defines the hosting scene
  107990. */
  107991. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107992. /**
  107993. * Gets camera class name
  107994. * @returns StereoscopicUniversalCamera
  107995. */
  107996. getClassName(): string;
  107997. }
  107998. }
  107999. declare module BABYLON {
  108000. /**
  108001. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108002. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108003. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108004. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108005. */
  108006. export class VirtualJoysticksCamera extends FreeCamera {
  108007. /**
  108008. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108009. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108010. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108011. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108012. * @param name Define the name of the camera in the scene
  108013. * @param position Define the start position of the camera in the scene
  108014. * @param scene Define the scene the camera belongs to
  108015. */
  108016. constructor(name: string, position: Vector3, scene: Scene);
  108017. /**
  108018. * Gets the current object class name.
  108019. * @return the class name
  108020. */
  108021. getClassName(): string;
  108022. }
  108023. }
  108024. declare module BABYLON {
  108025. /**
  108026. * This represents all the required metrics to create a VR camera.
  108027. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108028. */
  108029. export class VRCameraMetrics {
  108030. /**
  108031. * Define the horizontal resolution off the screen.
  108032. */
  108033. hResolution: number;
  108034. /**
  108035. * Define the vertical resolution off the screen.
  108036. */
  108037. vResolution: number;
  108038. /**
  108039. * Define the horizontal screen size.
  108040. */
  108041. hScreenSize: number;
  108042. /**
  108043. * Define the vertical screen size.
  108044. */
  108045. vScreenSize: number;
  108046. /**
  108047. * Define the vertical screen center position.
  108048. */
  108049. vScreenCenter: number;
  108050. /**
  108051. * Define the distance of the eyes to the screen.
  108052. */
  108053. eyeToScreenDistance: number;
  108054. /**
  108055. * Define the distance between both lenses
  108056. */
  108057. lensSeparationDistance: number;
  108058. /**
  108059. * Define the distance between both viewer's eyes.
  108060. */
  108061. interpupillaryDistance: number;
  108062. /**
  108063. * Define the distortion factor of the VR postprocess.
  108064. * Please, touch with care.
  108065. */
  108066. distortionK: number[];
  108067. /**
  108068. * Define the chromatic aberration correction factors for the VR post process.
  108069. */
  108070. chromaAbCorrection: number[];
  108071. /**
  108072. * Define the scale factor of the post process.
  108073. * The smaller the better but the slower.
  108074. */
  108075. postProcessScaleFactor: number;
  108076. /**
  108077. * Define an offset for the lens center.
  108078. */
  108079. lensCenterOffset: number;
  108080. /**
  108081. * Define if the current vr camera should compensate the distortion of the lense or not.
  108082. */
  108083. compensateDistortion: boolean;
  108084. /**
  108085. * Defines if multiview should be enabled when rendering (Default: false)
  108086. */
  108087. multiviewEnabled: boolean;
  108088. /**
  108089. * Gets the rendering aspect ratio based on the provided resolutions.
  108090. */
  108091. readonly aspectRatio: number;
  108092. /**
  108093. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108094. */
  108095. readonly aspectRatioFov: number;
  108096. /**
  108097. * @hidden
  108098. */
  108099. readonly leftHMatrix: Matrix;
  108100. /**
  108101. * @hidden
  108102. */
  108103. readonly rightHMatrix: Matrix;
  108104. /**
  108105. * @hidden
  108106. */
  108107. readonly leftPreViewMatrix: Matrix;
  108108. /**
  108109. * @hidden
  108110. */
  108111. readonly rightPreViewMatrix: Matrix;
  108112. /**
  108113. * Get the default VRMetrics based on the most generic setup.
  108114. * @returns the default vr metrics
  108115. */
  108116. static GetDefault(): VRCameraMetrics;
  108117. }
  108118. }
  108119. declare module BABYLON {
  108120. /** @hidden */
  108121. export var vrDistortionCorrectionPixelShader: {
  108122. name: string;
  108123. shader: string;
  108124. };
  108125. }
  108126. declare module BABYLON {
  108127. /**
  108128. * VRDistortionCorrectionPostProcess used for mobile VR
  108129. */
  108130. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108131. private _isRightEye;
  108132. private _distortionFactors;
  108133. private _postProcessScaleFactor;
  108134. private _lensCenterOffset;
  108135. private _scaleIn;
  108136. private _scaleFactor;
  108137. private _lensCenter;
  108138. /**
  108139. * Initializes the VRDistortionCorrectionPostProcess
  108140. * @param name The name of the effect.
  108141. * @param camera The camera to apply the render pass to.
  108142. * @param isRightEye If this is for the right eye distortion
  108143. * @param vrMetrics All the required metrics for the VR camera
  108144. */
  108145. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108146. }
  108147. }
  108148. declare module BABYLON {
  108149. /**
  108150. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108151. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108152. */
  108153. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108154. /**
  108155. * Creates a new VRDeviceOrientationArcRotateCamera
  108156. * @param name defines camera name
  108157. * @param alpha defines the camera rotation along the logitudinal axis
  108158. * @param beta defines the camera rotation along the latitudinal axis
  108159. * @param radius defines the camera distance from its target
  108160. * @param target defines the camera target
  108161. * @param scene defines the scene the camera belongs to
  108162. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108163. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108164. */
  108165. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108166. /**
  108167. * Gets camera class name
  108168. * @returns VRDeviceOrientationArcRotateCamera
  108169. */
  108170. getClassName(): string;
  108171. }
  108172. }
  108173. declare module BABYLON {
  108174. /**
  108175. * Camera used to simulate VR rendering (based on FreeCamera)
  108176. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108177. */
  108178. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108179. /**
  108180. * Creates a new VRDeviceOrientationFreeCamera
  108181. * @param name defines camera name
  108182. * @param position defines the start position of the camera
  108183. * @param scene defines the scene the camera belongs to
  108184. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108185. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108186. */
  108187. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108188. /**
  108189. * Gets camera class name
  108190. * @returns VRDeviceOrientationFreeCamera
  108191. */
  108192. getClassName(): string;
  108193. }
  108194. }
  108195. declare module BABYLON {
  108196. /**
  108197. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108198. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108199. */
  108200. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108201. /**
  108202. * Creates a new VRDeviceOrientationGamepadCamera
  108203. * @param name defines camera name
  108204. * @param position defines the start position of the camera
  108205. * @param scene defines the scene the camera belongs to
  108206. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108207. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108208. */
  108209. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108210. /**
  108211. * Gets camera class name
  108212. * @returns VRDeviceOrientationGamepadCamera
  108213. */
  108214. getClassName(): string;
  108215. }
  108216. }
  108217. declare module BABYLON {
  108218. /**
  108219. * Base class of materials working in push mode in babylon JS
  108220. * @hidden
  108221. */
  108222. export class PushMaterial extends Material {
  108223. protected _activeEffect: Effect;
  108224. protected _normalMatrix: Matrix;
  108225. /**
  108226. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108227. * This means that the material can keep using a previous shader while a new one is being compiled.
  108228. * This is mostly used when shader parallel compilation is supported (true by default)
  108229. */
  108230. allowShaderHotSwapping: boolean;
  108231. constructor(name: string, scene: Scene);
  108232. getEffect(): Effect;
  108233. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108234. /**
  108235. * Binds the given world matrix to the active effect
  108236. *
  108237. * @param world the matrix to bind
  108238. */
  108239. bindOnlyWorldMatrix(world: Matrix): void;
  108240. /**
  108241. * Binds the given normal matrix to the active effect
  108242. *
  108243. * @param normalMatrix the matrix to bind
  108244. */
  108245. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108246. bind(world: Matrix, mesh?: Mesh): void;
  108247. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108248. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108249. }
  108250. }
  108251. declare module BABYLON {
  108252. /**
  108253. * This groups all the flags used to control the materials channel.
  108254. */
  108255. export class MaterialFlags {
  108256. private static _DiffuseTextureEnabled;
  108257. /**
  108258. * Are diffuse textures enabled in the application.
  108259. */
  108260. static DiffuseTextureEnabled: boolean;
  108261. private static _AmbientTextureEnabled;
  108262. /**
  108263. * Are ambient textures enabled in the application.
  108264. */
  108265. static AmbientTextureEnabled: boolean;
  108266. private static _OpacityTextureEnabled;
  108267. /**
  108268. * Are opacity textures enabled in the application.
  108269. */
  108270. static OpacityTextureEnabled: boolean;
  108271. private static _ReflectionTextureEnabled;
  108272. /**
  108273. * Are reflection textures enabled in the application.
  108274. */
  108275. static ReflectionTextureEnabled: boolean;
  108276. private static _EmissiveTextureEnabled;
  108277. /**
  108278. * Are emissive textures enabled in the application.
  108279. */
  108280. static EmissiveTextureEnabled: boolean;
  108281. private static _SpecularTextureEnabled;
  108282. /**
  108283. * Are specular textures enabled in the application.
  108284. */
  108285. static SpecularTextureEnabled: boolean;
  108286. private static _BumpTextureEnabled;
  108287. /**
  108288. * Are bump textures enabled in the application.
  108289. */
  108290. static BumpTextureEnabled: boolean;
  108291. private static _LightmapTextureEnabled;
  108292. /**
  108293. * Are lightmap textures enabled in the application.
  108294. */
  108295. static LightmapTextureEnabled: boolean;
  108296. private static _RefractionTextureEnabled;
  108297. /**
  108298. * Are refraction textures enabled in the application.
  108299. */
  108300. static RefractionTextureEnabled: boolean;
  108301. private static _ColorGradingTextureEnabled;
  108302. /**
  108303. * Are color grading textures enabled in the application.
  108304. */
  108305. static ColorGradingTextureEnabled: boolean;
  108306. private static _FresnelEnabled;
  108307. /**
  108308. * Are fresnels enabled in the application.
  108309. */
  108310. static FresnelEnabled: boolean;
  108311. private static _ClearCoatTextureEnabled;
  108312. /**
  108313. * Are clear coat textures enabled in the application.
  108314. */
  108315. static ClearCoatTextureEnabled: boolean;
  108316. private static _ClearCoatBumpTextureEnabled;
  108317. /**
  108318. * Are clear coat bump textures enabled in the application.
  108319. */
  108320. static ClearCoatBumpTextureEnabled: boolean;
  108321. private static _ClearCoatTintTextureEnabled;
  108322. /**
  108323. * Are clear coat tint textures enabled in the application.
  108324. */
  108325. static ClearCoatTintTextureEnabled: boolean;
  108326. private static _SheenTextureEnabled;
  108327. /**
  108328. * Are sheen textures enabled in the application.
  108329. */
  108330. static SheenTextureEnabled: boolean;
  108331. private static _AnisotropicTextureEnabled;
  108332. /**
  108333. * Are anisotropic textures enabled in the application.
  108334. */
  108335. static AnisotropicTextureEnabled: boolean;
  108336. private static _ThicknessTextureEnabled;
  108337. /**
  108338. * Are thickness textures enabled in the application.
  108339. */
  108340. static ThicknessTextureEnabled: boolean;
  108341. }
  108342. }
  108343. declare module BABYLON {
  108344. /** @hidden */
  108345. export var defaultFragmentDeclaration: {
  108346. name: string;
  108347. shader: string;
  108348. };
  108349. }
  108350. declare module BABYLON {
  108351. /** @hidden */
  108352. export var defaultUboDeclaration: {
  108353. name: string;
  108354. shader: string;
  108355. };
  108356. }
  108357. declare module BABYLON {
  108358. /** @hidden */
  108359. export var lightFragmentDeclaration: {
  108360. name: string;
  108361. shader: string;
  108362. };
  108363. }
  108364. declare module BABYLON {
  108365. /** @hidden */
  108366. export var lightUboDeclaration: {
  108367. name: string;
  108368. shader: string;
  108369. };
  108370. }
  108371. declare module BABYLON {
  108372. /** @hidden */
  108373. export var lightsFragmentFunctions: {
  108374. name: string;
  108375. shader: string;
  108376. };
  108377. }
  108378. declare module BABYLON {
  108379. /** @hidden */
  108380. export var shadowsFragmentFunctions: {
  108381. name: string;
  108382. shader: string;
  108383. };
  108384. }
  108385. declare module BABYLON {
  108386. /** @hidden */
  108387. export var fresnelFunction: {
  108388. name: string;
  108389. shader: string;
  108390. };
  108391. }
  108392. declare module BABYLON {
  108393. /** @hidden */
  108394. export var reflectionFunction: {
  108395. name: string;
  108396. shader: string;
  108397. };
  108398. }
  108399. declare module BABYLON {
  108400. /** @hidden */
  108401. export var bumpFragmentFunctions: {
  108402. name: string;
  108403. shader: string;
  108404. };
  108405. }
  108406. declare module BABYLON {
  108407. /** @hidden */
  108408. export var logDepthDeclaration: {
  108409. name: string;
  108410. shader: string;
  108411. };
  108412. }
  108413. declare module BABYLON {
  108414. /** @hidden */
  108415. export var bumpFragment: {
  108416. name: string;
  108417. shader: string;
  108418. };
  108419. }
  108420. declare module BABYLON {
  108421. /** @hidden */
  108422. export var depthPrePass: {
  108423. name: string;
  108424. shader: string;
  108425. };
  108426. }
  108427. declare module BABYLON {
  108428. /** @hidden */
  108429. export var lightFragment: {
  108430. name: string;
  108431. shader: string;
  108432. };
  108433. }
  108434. declare module BABYLON {
  108435. /** @hidden */
  108436. export var logDepthFragment: {
  108437. name: string;
  108438. shader: string;
  108439. };
  108440. }
  108441. declare module BABYLON {
  108442. /** @hidden */
  108443. export var defaultPixelShader: {
  108444. name: string;
  108445. shader: string;
  108446. };
  108447. }
  108448. declare module BABYLON {
  108449. /** @hidden */
  108450. export var defaultVertexDeclaration: {
  108451. name: string;
  108452. shader: string;
  108453. };
  108454. }
  108455. declare module BABYLON {
  108456. /** @hidden */
  108457. export var bumpVertexDeclaration: {
  108458. name: string;
  108459. shader: string;
  108460. };
  108461. }
  108462. declare module BABYLON {
  108463. /** @hidden */
  108464. export var bumpVertex: {
  108465. name: string;
  108466. shader: string;
  108467. };
  108468. }
  108469. declare module BABYLON {
  108470. /** @hidden */
  108471. export var fogVertex: {
  108472. name: string;
  108473. shader: string;
  108474. };
  108475. }
  108476. declare module BABYLON {
  108477. /** @hidden */
  108478. export var shadowsVertex: {
  108479. name: string;
  108480. shader: string;
  108481. };
  108482. }
  108483. declare module BABYLON {
  108484. /** @hidden */
  108485. export var pointCloudVertex: {
  108486. name: string;
  108487. shader: string;
  108488. };
  108489. }
  108490. declare module BABYLON {
  108491. /** @hidden */
  108492. export var logDepthVertex: {
  108493. name: string;
  108494. shader: string;
  108495. };
  108496. }
  108497. declare module BABYLON {
  108498. /** @hidden */
  108499. export var defaultVertexShader: {
  108500. name: string;
  108501. shader: string;
  108502. };
  108503. }
  108504. declare module BABYLON {
  108505. /** @hidden */
  108506. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108507. MAINUV1: boolean;
  108508. MAINUV2: boolean;
  108509. DIFFUSE: boolean;
  108510. DIFFUSEDIRECTUV: number;
  108511. AMBIENT: boolean;
  108512. AMBIENTDIRECTUV: number;
  108513. OPACITY: boolean;
  108514. OPACITYDIRECTUV: number;
  108515. OPACITYRGB: boolean;
  108516. REFLECTION: boolean;
  108517. EMISSIVE: boolean;
  108518. EMISSIVEDIRECTUV: number;
  108519. SPECULAR: boolean;
  108520. SPECULARDIRECTUV: number;
  108521. BUMP: boolean;
  108522. BUMPDIRECTUV: number;
  108523. PARALLAX: boolean;
  108524. PARALLAXOCCLUSION: boolean;
  108525. SPECULAROVERALPHA: boolean;
  108526. CLIPPLANE: boolean;
  108527. CLIPPLANE2: boolean;
  108528. CLIPPLANE3: boolean;
  108529. CLIPPLANE4: boolean;
  108530. ALPHATEST: boolean;
  108531. DEPTHPREPASS: boolean;
  108532. ALPHAFROMDIFFUSE: boolean;
  108533. POINTSIZE: boolean;
  108534. FOG: boolean;
  108535. SPECULARTERM: boolean;
  108536. DIFFUSEFRESNEL: boolean;
  108537. OPACITYFRESNEL: boolean;
  108538. REFLECTIONFRESNEL: boolean;
  108539. REFRACTIONFRESNEL: boolean;
  108540. EMISSIVEFRESNEL: boolean;
  108541. FRESNEL: boolean;
  108542. NORMAL: boolean;
  108543. UV1: boolean;
  108544. UV2: boolean;
  108545. VERTEXCOLOR: boolean;
  108546. VERTEXALPHA: boolean;
  108547. NUM_BONE_INFLUENCERS: number;
  108548. BonesPerMesh: number;
  108549. BONETEXTURE: boolean;
  108550. INSTANCES: boolean;
  108551. GLOSSINESS: boolean;
  108552. ROUGHNESS: boolean;
  108553. EMISSIVEASILLUMINATION: boolean;
  108554. LINKEMISSIVEWITHDIFFUSE: boolean;
  108555. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108556. LIGHTMAP: boolean;
  108557. LIGHTMAPDIRECTUV: number;
  108558. OBJECTSPACE_NORMALMAP: boolean;
  108559. USELIGHTMAPASSHADOWMAP: boolean;
  108560. REFLECTIONMAP_3D: boolean;
  108561. REFLECTIONMAP_SPHERICAL: boolean;
  108562. REFLECTIONMAP_PLANAR: boolean;
  108563. REFLECTIONMAP_CUBIC: boolean;
  108564. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108565. REFLECTIONMAP_PROJECTION: boolean;
  108566. REFLECTIONMAP_SKYBOX: boolean;
  108567. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108568. REFLECTIONMAP_EXPLICIT: boolean;
  108569. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108570. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108571. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108572. INVERTCUBICMAP: boolean;
  108573. LOGARITHMICDEPTH: boolean;
  108574. REFRACTION: boolean;
  108575. REFRACTIONMAP_3D: boolean;
  108576. REFLECTIONOVERALPHA: boolean;
  108577. TWOSIDEDLIGHTING: boolean;
  108578. SHADOWFLOAT: boolean;
  108579. MORPHTARGETS: boolean;
  108580. MORPHTARGETS_NORMAL: boolean;
  108581. MORPHTARGETS_TANGENT: boolean;
  108582. MORPHTARGETS_UV: boolean;
  108583. NUM_MORPH_INFLUENCERS: number;
  108584. NONUNIFORMSCALING: boolean;
  108585. PREMULTIPLYALPHA: boolean;
  108586. IMAGEPROCESSING: boolean;
  108587. VIGNETTE: boolean;
  108588. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108589. VIGNETTEBLENDMODEOPAQUE: boolean;
  108590. TONEMAPPING: boolean;
  108591. TONEMAPPING_ACES: boolean;
  108592. CONTRAST: boolean;
  108593. COLORCURVES: boolean;
  108594. COLORGRADING: boolean;
  108595. COLORGRADING3D: boolean;
  108596. SAMPLER3DGREENDEPTH: boolean;
  108597. SAMPLER3DBGRMAP: boolean;
  108598. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108599. MULTIVIEW: boolean;
  108600. /**
  108601. * If the reflection texture on this material is in linear color space
  108602. * @hidden
  108603. */
  108604. IS_REFLECTION_LINEAR: boolean;
  108605. /**
  108606. * If the refraction texture on this material is in linear color space
  108607. * @hidden
  108608. */
  108609. IS_REFRACTION_LINEAR: boolean;
  108610. EXPOSURE: boolean;
  108611. constructor();
  108612. setReflectionMode(modeToEnable: string): void;
  108613. }
  108614. /**
  108615. * This is the default material used in Babylon. It is the best trade off between quality
  108616. * and performances.
  108617. * @see http://doc.babylonjs.com/babylon101/materials
  108618. */
  108619. export class StandardMaterial extends PushMaterial {
  108620. private _diffuseTexture;
  108621. /**
  108622. * The basic texture of the material as viewed under a light.
  108623. */
  108624. diffuseTexture: Nullable<BaseTexture>;
  108625. private _ambientTexture;
  108626. /**
  108627. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108628. */
  108629. ambientTexture: Nullable<BaseTexture>;
  108630. private _opacityTexture;
  108631. /**
  108632. * Define the transparency of the material from a texture.
  108633. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108634. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108635. */
  108636. opacityTexture: Nullable<BaseTexture>;
  108637. private _reflectionTexture;
  108638. /**
  108639. * Define the texture used to display the reflection.
  108640. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108641. */
  108642. reflectionTexture: Nullable<BaseTexture>;
  108643. private _emissiveTexture;
  108644. /**
  108645. * Define texture of the material as if self lit.
  108646. * This will be mixed in the final result even in the absence of light.
  108647. */
  108648. emissiveTexture: Nullable<BaseTexture>;
  108649. private _specularTexture;
  108650. /**
  108651. * Define how the color and intensity of the highlight given by the light in the material.
  108652. */
  108653. specularTexture: Nullable<BaseTexture>;
  108654. private _bumpTexture;
  108655. /**
  108656. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108657. * 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.
  108658. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108659. */
  108660. bumpTexture: Nullable<BaseTexture>;
  108661. private _lightmapTexture;
  108662. /**
  108663. * Complex lighting can be computationally expensive to compute at runtime.
  108664. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108665. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108666. */
  108667. lightmapTexture: Nullable<BaseTexture>;
  108668. private _refractionTexture;
  108669. /**
  108670. * Define the texture used to display the refraction.
  108671. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108672. */
  108673. refractionTexture: Nullable<BaseTexture>;
  108674. /**
  108675. * The color of the material lit by the environmental background lighting.
  108676. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108677. */
  108678. ambientColor: Color3;
  108679. /**
  108680. * The basic color of the material as viewed under a light.
  108681. */
  108682. diffuseColor: Color3;
  108683. /**
  108684. * Define how the color and intensity of the highlight given by the light in the material.
  108685. */
  108686. specularColor: Color3;
  108687. /**
  108688. * Define the color of the material as if self lit.
  108689. * This will be mixed in the final result even in the absence of light.
  108690. */
  108691. emissiveColor: Color3;
  108692. /**
  108693. * Defines how sharp are the highlights in the material.
  108694. * The bigger the value the sharper giving a more glossy feeling to the result.
  108695. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108696. */
  108697. specularPower: number;
  108698. private _useAlphaFromDiffuseTexture;
  108699. /**
  108700. * Does the transparency come from the diffuse texture alpha channel.
  108701. */
  108702. useAlphaFromDiffuseTexture: boolean;
  108703. private _useEmissiveAsIllumination;
  108704. /**
  108705. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108706. */
  108707. useEmissiveAsIllumination: boolean;
  108708. private _linkEmissiveWithDiffuse;
  108709. /**
  108710. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108711. * the emissive level when the final color is close to one.
  108712. */
  108713. linkEmissiveWithDiffuse: boolean;
  108714. private _useSpecularOverAlpha;
  108715. /**
  108716. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108717. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108718. */
  108719. useSpecularOverAlpha: boolean;
  108720. private _useReflectionOverAlpha;
  108721. /**
  108722. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108723. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108724. */
  108725. useReflectionOverAlpha: boolean;
  108726. private _disableLighting;
  108727. /**
  108728. * Does lights from the scene impacts this material.
  108729. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108730. */
  108731. disableLighting: boolean;
  108732. private _useObjectSpaceNormalMap;
  108733. /**
  108734. * Allows using an object space normal map (instead of tangent space).
  108735. */
  108736. useObjectSpaceNormalMap: boolean;
  108737. private _useParallax;
  108738. /**
  108739. * Is parallax enabled or not.
  108740. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108741. */
  108742. useParallax: boolean;
  108743. private _useParallaxOcclusion;
  108744. /**
  108745. * Is parallax occlusion enabled or not.
  108746. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108747. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108748. */
  108749. useParallaxOcclusion: boolean;
  108750. /**
  108751. * 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.
  108752. */
  108753. parallaxScaleBias: number;
  108754. private _roughness;
  108755. /**
  108756. * Helps to define how blurry the reflections should appears in the material.
  108757. */
  108758. roughness: number;
  108759. /**
  108760. * In case of refraction, define the value of the index of refraction.
  108761. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108762. */
  108763. indexOfRefraction: number;
  108764. /**
  108765. * Invert the refraction texture alongside the y axis.
  108766. * It can be useful with procedural textures or probe for instance.
  108767. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108768. */
  108769. invertRefractionY: boolean;
  108770. /**
  108771. * Defines the alpha limits in alpha test mode.
  108772. */
  108773. alphaCutOff: number;
  108774. private _useLightmapAsShadowmap;
  108775. /**
  108776. * In case of light mapping, define whether the map contains light or shadow informations.
  108777. */
  108778. useLightmapAsShadowmap: boolean;
  108779. private _diffuseFresnelParameters;
  108780. /**
  108781. * Define the diffuse fresnel parameters of the material.
  108782. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108783. */
  108784. diffuseFresnelParameters: FresnelParameters;
  108785. private _opacityFresnelParameters;
  108786. /**
  108787. * Define the opacity fresnel parameters of the material.
  108788. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108789. */
  108790. opacityFresnelParameters: FresnelParameters;
  108791. private _reflectionFresnelParameters;
  108792. /**
  108793. * Define the reflection fresnel parameters of the material.
  108794. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108795. */
  108796. reflectionFresnelParameters: FresnelParameters;
  108797. private _refractionFresnelParameters;
  108798. /**
  108799. * Define the refraction fresnel parameters of the material.
  108800. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108801. */
  108802. refractionFresnelParameters: FresnelParameters;
  108803. private _emissiveFresnelParameters;
  108804. /**
  108805. * Define the emissive fresnel parameters of the material.
  108806. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108807. */
  108808. emissiveFresnelParameters: FresnelParameters;
  108809. private _useReflectionFresnelFromSpecular;
  108810. /**
  108811. * If true automatically deducts the fresnels values from the material specularity.
  108812. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108813. */
  108814. useReflectionFresnelFromSpecular: boolean;
  108815. private _useGlossinessFromSpecularMapAlpha;
  108816. /**
  108817. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  108818. */
  108819. useGlossinessFromSpecularMapAlpha: boolean;
  108820. private _maxSimultaneousLights;
  108821. /**
  108822. * Defines the maximum number of lights that can be used in the material
  108823. */
  108824. maxSimultaneousLights: number;
  108825. private _invertNormalMapX;
  108826. /**
  108827. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108828. */
  108829. invertNormalMapX: boolean;
  108830. private _invertNormalMapY;
  108831. /**
  108832. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108833. */
  108834. invertNormalMapY: boolean;
  108835. private _twoSidedLighting;
  108836. /**
  108837. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108838. */
  108839. twoSidedLighting: boolean;
  108840. /**
  108841. * Default configuration related to image processing available in the standard Material.
  108842. */
  108843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108844. /**
  108845. * Gets the image processing configuration used either in this material.
  108846. */
  108847. /**
  108848. * Sets the Default image processing configuration used either in the this material.
  108849. *
  108850. * If sets to null, the scene one is in use.
  108851. */
  108852. imageProcessingConfiguration: ImageProcessingConfiguration;
  108853. /**
  108854. * Keep track of the image processing observer to allow dispose and replace.
  108855. */
  108856. private _imageProcessingObserver;
  108857. /**
  108858. * Attaches a new image processing configuration to the Standard Material.
  108859. * @param configuration
  108860. */
  108861. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108862. /**
  108863. * Gets wether the color curves effect is enabled.
  108864. */
  108865. /**
  108866. * Sets wether the color curves effect is enabled.
  108867. */
  108868. cameraColorCurvesEnabled: boolean;
  108869. /**
  108870. * Gets wether the color grading effect is enabled.
  108871. */
  108872. /**
  108873. * Gets wether the color grading effect is enabled.
  108874. */
  108875. cameraColorGradingEnabled: boolean;
  108876. /**
  108877. * Gets wether tonemapping is enabled or not.
  108878. */
  108879. /**
  108880. * Sets wether tonemapping is enabled or not
  108881. */
  108882. cameraToneMappingEnabled: boolean;
  108883. /**
  108884. * The camera exposure used on this material.
  108885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108886. * This corresponds to a photographic exposure.
  108887. */
  108888. /**
  108889. * The camera exposure used on this material.
  108890. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108891. * This corresponds to a photographic exposure.
  108892. */
  108893. cameraExposure: number;
  108894. /**
  108895. * Gets The camera contrast used on this material.
  108896. */
  108897. /**
  108898. * Sets The camera contrast used on this material.
  108899. */
  108900. cameraContrast: number;
  108901. /**
  108902. * Gets the Color Grading 2D Lookup Texture.
  108903. */
  108904. /**
  108905. * Sets the Color Grading 2D Lookup Texture.
  108906. */
  108907. cameraColorGradingTexture: Nullable<BaseTexture>;
  108908. /**
  108909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108911. * 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;
  108912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108913. */
  108914. /**
  108915. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108916. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108917. * 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;
  108918. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108919. */
  108920. cameraColorCurves: Nullable<ColorCurves>;
  108921. /**
  108922. * Custom callback helping to override the default shader used in the material.
  108923. */
  108924. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108925. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108926. protected _worldViewProjectionMatrix: Matrix;
  108927. protected _globalAmbientColor: Color3;
  108928. protected _useLogarithmicDepth: boolean;
  108929. protected _rebuildInParallel: boolean;
  108930. /**
  108931. * Instantiates a new standard material.
  108932. * This is the default material used in Babylon. It is the best trade off between quality
  108933. * and performances.
  108934. * @see http://doc.babylonjs.com/babylon101/materials
  108935. * @param name Define the name of the material in the scene
  108936. * @param scene Define the scene the material belong to
  108937. */
  108938. constructor(name: string, scene: Scene);
  108939. /**
  108940. * Gets a boolean indicating that current material needs to register RTT
  108941. */
  108942. readonly hasRenderTargetTextures: boolean;
  108943. /**
  108944. * Gets the current class name of the material e.g. "StandardMaterial"
  108945. * Mainly use in serialization.
  108946. * @returns the class name
  108947. */
  108948. getClassName(): string;
  108949. /**
  108950. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108951. * You can try switching to logarithmic depth.
  108952. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108953. */
  108954. useLogarithmicDepth: boolean;
  108955. /**
  108956. * Specifies if the material will require alpha blending
  108957. * @returns a boolean specifying if alpha blending is needed
  108958. */
  108959. needAlphaBlending(): boolean;
  108960. /**
  108961. * Specifies if this material should be rendered in alpha test mode
  108962. * @returns a boolean specifying if an alpha test is needed.
  108963. */
  108964. needAlphaTesting(): boolean;
  108965. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108966. /**
  108967. * Get the texture used for alpha test purpose.
  108968. * @returns the diffuse texture in case of the standard material.
  108969. */
  108970. getAlphaTestTexture(): Nullable<BaseTexture>;
  108971. /**
  108972. * Get if the submesh is ready to be used and all its information available.
  108973. * Child classes can use it to update shaders
  108974. * @param mesh defines the mesh to check
  108975. * @param subMesh defines which submesh to check
  108976. * @param useInstances specifies that instances should be used
  108977. * @returns a boolean indicating that the submesh is ready or not
  108978. */
  108979. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108980. /**
  108981. * Builds the material UBO layouts.
  108982. * Used internally during the effect preparation.
  108983. */
  108984. buildUniformLayout(): void;
  108985. /**
  108986. * Unbinds the material from the mesh
  108987. */
  108988. unbind(): void;
  108989. /**
  108990. * Binds the submesh to this material by preparing the effect and shader to draw
  108991. * @param world defines the world transformation matrix
  108992. * @param mesh defines the mesh containing the submesh
  108993. * @param subMesh defines the submesh to bind the material to
  108994. */
  108995. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108996. /**
  108997. * Get the list of animatables in the material.
  108998. * @returns the list of animatables object used in the material
  108999. */
  109000. getAnimatables(): IAnimatable[];
  109001. /**
  109002. * Gets the active textures from the material
  109003. * @returns an array of textures
  109004. */
  109005. getActiveTextures(): BaseTexture[];
  109006. /**
  109007. * Specifies if the material uses a texture
  109008. * @param texture defines the texture to check against the material
  109009. * @returns a boolean specifying if the material uses the texture
  109010. */
  109011. hasTexture(texture: BaseTexture): boolean;
  109012. /**
  109013. * Disposes the material
  109014. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109015. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109016. */
  109017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109018. /**
  109019. * Makes a duplicate of the material, and gives it a new name
  109020. * @param name defines the new name for the duplicated material
  109021. * @returns the cloned material
  109022. */
  109023. clone(name: string): StandardMaterial;
  109024. /**
  109025. * Serializes this material in a JSON representation
  109026. * @returns the serialized material object
  109027. */
  109028. serialize(): any;
  109029. /**
  109030. * Creates a standard material from parsed material data
  109031. * @param source defines the JSON representation of the material
  109032. * @param scene defines the hosting scene
  109033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109034. * @returns a new standard material
  109035. */
  109036. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109037. /**
  109038. * Are diffuse textures enabled in the application.
  109039. */
  109040. static DiffuseTextureEnabled: boolean;
  109041. /**
  109042. * Are ambient textures enabled in the application.
  109043. */
  109044. static AmbientTextureEnabled: boolean;
  109045. /**
  109046. * Are opacity textures enabled in the application.
  109047. */
  109048. static OpacityTextureEnabled: boolean;
  109049. /**
  109050. * Are reflection textures enabled in the application.
  109051. */
  109052. static ReflectionTextureEnabled: boolean;
  109053. /**
  109054. * Are emissive textures enabled in the application.
  109055. */
  109056. static EmissiveTextureEnabled: boolean;
  109057. /**
  109058. * Are specular textures enabled in the application.
  109059. */
  109060. static SpecularTextureEnabled: boolean;
  109061. /**
  109062. * Are bump textures enabled in the application.
  109063. */
  109064. static BumpTextureEnabled: boolean;
  109065. /**
  109066. * Are lightmap textures enabled in the application.
  109067. */
  109068. static LightmapTextureEnabled: boolean;
  109069. /**
  109070. * Are refraction textures enabled in the application.
  109071. */
  109072. static RefractionTextureEnabled: boolean;
  109073. /**
  109074. * Are color grading textures enabled in the application.
  109075. */
  109076. static ColorGradingTextureEnabled: boolean;
  109077. /**
  109078. * Are fresnels enabled in the application.
  109079. */
  109080. static FresnelEnabled: boolean;
  109081. }
  109082. }
  109083. declare module BABYLON {
  109084. /** @hidden */
  109085. export var imageProcessingPixelShader: {
  109086. name: string;
  109087. shader: string;
  109088. };
  109089. }
  109090. declare module BABYLON {
  109091. /**
  109092. * ImageProcessingPostProcess
  109093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109094. */
  109095. export class ImageProcessingPostProcess extends PostProcess {
  109096. /**
  109097. * Default configuration related to image processing available in the PBR Material.
  109098. */
  109099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109100. /**
  109101. * Gets the image processing configuration used either in this material.
  109102. */
  109103. /**
  109104. * Sets the Default image processing configuration used either in the this material.
  109105. *
  109106. * If sets to null, the scene one is in use.
  109107. */
  109108. imageProcessingConfiguration: ImageProcessingConfiguration;
  109109. /**
  109110. * Keep track of the image processing observer to allow dispose and replace.
  109111. */
  109112. private _imageProcessingObserver;
  109113. /**
  109114. * Attaches a new image processing configuration to the PBR Material.
  109115. * @param configuration
  109116. */
  109117. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109118. /**
  109119. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109120. */
  109121. /**
  109122. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109123. */
  109124. colorCurves: Nullable<ColorCurves>;
  109125. /**
  109126. * Gets wether the color curves effect is enabled.
  109127. */
  109128. /**
  109129. * Sets wether the color curves effect is enabled.
  109130. */
  109131. colorCurvesEnabled: boolean;
  109132. /**
  109133. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109134. */
  109135. /**
  109136. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109137. */
  109138. colorGradingTexture: Nullable<BaseTexture>;
  109139. /**
  109140. * Gets wether the color grading effect is enabled.
  109141. */
  109142. /**
  109143. * Gets wether the color grading effect is enabled.
  109144. */
  109145. colorGradingEnabled: boolean;
  109146. /**
  109147. * Gets exposure used in the effect.
  109148. */
  109149. /**
  109150. * Sets exposure used in the effect.
  109151. */
  109152. exposure: number;
  109153. /**
  109154. * Gets wether tonemapping is enabled or not.
  109155. */
  109156. /**
  109157. * Sets wether tonemapping is enabled or not
  109158. */
  109159. toneMappingEnabled: boolean;
  109160. /**
  109161. * Gets the type of tone mapping effect.
  109162. */
  109163. /**
  109164. * Sets the type of tone mapping effect.
  109165. */
  109166. toneMappingType: number;
  109167. /**
  109168. * Gets contrast used in the effect.
  109169. */
  109170. /**
  109171. * Sets contrast used in the effect.
  109172. */
  109173. contrast: number;
  109174. /**
  109175. * Gets Vignette stretch size.
  109176. */
  109177. /**
  109178. * Sets Vignette stretch size.
  109179. */
  109180. vignetteStretch: number;
  109181. /**
  109182. * Gets Vignette centre X Offset.
  109183. */
  109184. /**
  109185. * Sets Vignette centre X Offset.
  109186. */
  109187. vignetteCentreX: number;
  109188. /**
  109189. * Gets Vignette centre Y Offset.
  109190. */
  109191. /**
  109192. * Sets Vignette centre Y Offset.
  109193. */
  109194. vignetteCentreY: number;
  109195. /**
  109196. * Gets Vignette weight or intensity of the vignette effect.
  109197. */
  109198. /**
  109199. * Sets Vignette weight or intensity of the vignette effect.
  109200. */
  109201. vignetteWeight: number;
  109202. /**
  109203. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109204. * if vignetteEnabled is set to true.
  109205. */
  109206. /**
  109207. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109208. * if vignetteEnabled is set to true.
  109209. */
  109210. vignetteColor: Color4;
  109211. /**
  109212. * Gets Camera field of view used by the Vignette effect.
  109213. */
  109214. /**
  109215. * Sets Camera field of view used by the Vignette effect.
  109216. */
  109217. vignetteCameraFov: number;
  109218. /**
  109219. * Gets the vignette blend mode allowing different kind of effect.
  109220. */
  109221. /**
  109222. * Sets the vignette blend mode allowing different kind of effect.
  109223. */
  109224. vignetteBlendMode: number;
  109225. /**
  109226. * Gets wether the vignette effect is enabled.
  109227. */
  109228. /**
  109229. * Sets wether the vignette effect is enabled.
  109230. */
  109231. vignetteEnabled: boolean;
  109232. private _fromLinearSpace;
  109233. /**
  109234. * Gets wether the input of the processing is in Gamma or Linear Space.
  109235. */
  109236. /**
  109237. * Sets wether the input of the processing is in Gamma or Linear Space.
  109238. */
  109239. fromLinearSpace: boolean;
  109240. /**
  109241. * Defines cache preventing GC.
  109242. */
  109243. private _defines;
  109244. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109245. /**
  109246. * "ImageProcessingPostProcess"
  109247. * @returns "ImageProcessingPostProcess"
  109248. */
  109249. getClassName(): string;
  109250. protected _updateParameters(): void;
  109251. dispose(camera?: Camera): void;
  109252. }
  109253. }
  109254. declare module BABYLON {
  109255. /**
  109256. * Class containing static functions to help procedurally build meshes
  109257. */
  109258. export class GroundBuilder {
  109259. /**
  109260. * Creates a ground mesh
  109261. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109262. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109264. * @param name defines the name of the mesh
  109265. * @param options defines the options used to create the mesh
  109266. * @param scene defines the hosting scene
  109267. * @returns the ground mesh
  109268. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109269. */
  109270. static CreateGround(name: string, options: {
  109271. width?: number;
  109272. height?: number;
  109273. subdivisions?: number;
  109274. subdivisionsX?: number;
  109275. subdivisionsY?: number;
  109276. updatable?: boolean;
  109277. }, scene: any): Mesh;
  109278. /**
  109279. * Creates a tiled ground mesh
  109280. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109281. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109282. * * 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
  109283. * * 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
  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 options defines the options used to create the mesh
  109287. * @param scene defines the hosting scene
  109288. * @returns the tiled ground mesh
  109289. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109290. */
  109291. static CreateTiledGround(name: string, options: {
  109292. xmin: number;
  109293. zmin: number;
  109294. xmax: number;
  109295. zmax: number;
  109296. subdivisions?: {
  109297. w: number;
  109298. h: number;
  109299. };
  109300. precision?: {
  109301. w: number;
  109302. h: number;
  109303. };
  109304. updatable?: boolean;
  109305. }, scene?: Nullable<Scene>): Mesh;
  109306. /**
  109307. * Creates a ground mesh from a height map
  109308. * * The parameter `url` sets the URL of the height map image resource.
  109309. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109310. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109311. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109312. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109313. * * 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.
  109314. * * 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).
  109315. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109317. * @param name defines the name of the mesh
  109318. * @param url defines the url to the height map
  109319. * @param options defines the options used to create the mesh
  109320. * @param scene defines the hosting scene
  109321. * @returns the ground mesh
  109322. * @see https://doc.babylonjs.com/babylon101/height_map
  109323. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109324. */
  109325. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109326. width?: number;
  109327. height?: number;
  109328. subdivisions?: number;
  109329. minHeight?: number;
  109330. maxHeight?: number;
  109331. colorFilter?: Color3;
  109332. alphaFilter?: number;
  109333. updatable?: boolean;
  109334. onReady?: (mesh: GroundMesh) => void;
  109335. }, scene?: Nullable<Scene>): GroundMesh;
  109336. }
  109337. }
  109338. declare module BABYLON {
  109339. /**
  109340. * Class containing static functions to help procedurally build meshes
  109341. */
  109342. export class TorusBuilder {
  109343. /**
  109344. * Creates a torus mesh
  109345. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109346. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109347. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109351. * @param name defines the name of the mesh
  109352. * @param options defines the options used to create the mesh
  109353. * @param scene defines the hosting scene
  109354. * @returns the torus mesh
  109355. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109356. */
  109357. static CreateTorus(name: string, options: {
  109358. diameter?: number;
  109359. thickness?: number;
  109360. tessellation?: number;
  109361. updatable?: boolean;
  109362. sideOrientation?: number;
  109363. frontUVs?: Vector4;
  109364. backUVs?: Vector4;
  109365. }, scene: any): Mesh;
  109366. }
  109367. }
  109368. declare module BABYLON {
  109369. /**
  109370. * Class containing static functions to help procedurally build meshes
  109371. */
  109372. export class CylinderBuilder {
  109373. /**
  109374. * Creates a cylinder or a cone mesh
  109375. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109376. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109377. * * 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.
  109378. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109379. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109380. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109381. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109382. * * 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).
  109383. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109384. * * 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).
  109385. * * 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
  109386. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109387. * * 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
  109388. * * 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.
  109389. * * If `enclose` is false, a ring surface is one element.
  109390. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109391. * * 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
  109392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109395. * @param name defines the name of the mesh
  109396. * @param options defines the options used to create the mesh
  109397. * @param scene defines the hosting scene
  109398. * @returns the cylinder mesh
  109399. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109400. */
  109401. static CreateCylinder(name: string, options: {
  109402. height?: number;
  109403. diameterTop?: number;
  109404. diameterBottom?: number;
  109405. diameter?: number;
  109406. tessellation?: number;
  109407. subdivisions?: number;
  109408. arc?: number;
  109409. faceColors?: Color4[];
  109410. faceUV?: Vector4[];
  109411. updatable?: boolean;
  109412. hasRings?: boolean;
  109413. enclose?: boolean;
  109414. cap?: number;
  109415. sideOrientation?: number;
  109416. frontUVs?: Vector4;
  109417. backUVs?: Vector4;
  109418. }, scene: any): Mesh;
  109419. }
  109420. }
  109421. declare module BABYLON {
  109422. /**
  109423. * Options to modify the vr teleportation behavior.
  109424. */
  109425. export interface VRTeleportationOptions {
  109426. /**
  109427. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109428. */
  109429. floorMeshName?: string;
  109430. /**
  109431. * A list of meshes to be used as the teleportation floor. (default: empty)
  109432. */
  109433. floorMeshes?: Mesh[];
  109434. }
  109435. /**
  109436. * Options to modify the vr experience helper's behavior.
  109437. */
  109438. export interface VRExperienceHelperOptions extends WebVROptions {
  109439. /**
  109440. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109441. */
  109442. createDeviceOrientationCamera?: boolean;
  109443. /**
  109444. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109445. */
  109446. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109447. /**
  109448. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109449. */
  109450. laserToggle?: boolean;
  109451. /**
  109452. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109453. */
  109454. floorMeshes?: Mesh[];
  109455. /**
  109456. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109457. */
  109458. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109459. }
  109460. /**
  109461. * Event containing information after VR has been entered
  109462. */
  109463. export class OnAfterEnteringVRObservableEvent {
  109464. /**
  109465. * If entering vr was successful
  109466. */
  109467. success: boolean;
  109468. }
  109469. /**
  109470. * Helps to quickly add VR support to an existing scene.
  109471. * See http://doc.babylonjs.com/how_to/webvr_helper
  109472. */
  109473. export class VRExperienceHelper {
  109474. /** Options to modify the vr experience helper's behavior. */
  109475. webVROptions: VRExperienceHelperOptions;
  109476. private _scene;
  109477. private _position;
  109478. private _btnVR;
  109479. private _btnVRDisplayed;
  109480. private _webVRsupported;
  109481. private _webVRready;
  109482. private _webVRrequesting;
  109483. private _webVRpresenting;
  109484. private _hasEnteredVR;
  109485. private _fullscreenVRpresenting;
  109486. private _inputElement;
  109487. private _webVRCamera;
  109488. private _vrDeviceOrientationCamera;
  109489. private _deviceOrientationCamera;
  109490. private _existingCamera;
  109491. private _onKeyDown;
  109492. private _onVrDisplayPresentChange;
  109493. private _onVRDisplayChanged;
  109494. private _onVRRequestPresentStart;
  109495. private _onVRRequestPresentComplete;
  109496. /**
  109497. * 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)
  109498. */
  109499. enableGazeEvenWhenNoPointerLock: boolean;
  109500. /**
  109501. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109502. */
  109503. exitVROnDoubleTap: boolean;
  109504. /**
  109505. * Observable raised right before entering VR.
  109506. */
  109507. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109508. /**
  109509. * Observable raised when entering VR has completed.
  109510. */
  109511. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109512. /**
  109513. * Observable raised when exiting VR.
  109514. */
  109515. onExitingVRObservable: Observable<VRExperienceHelper>;
  109516. /**
  109517. * Observable raised when controller mesh is loaded.
  109518. */
  109519. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109520. /** Return this.onEnteringVRObservable
  109521. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109522. */
  109523. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109524. /** Return this.onExitingVRObservable
  109525. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109526. */
  109527. readonly onExitingVR: Observable<VRExperienceHelper>;
  109528. /** Return this.onControllerMeshLoadedObservable
  109529. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109530. */
  109531. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109532. private _rayLength;
  109533. private _useCustomVRButton;
  109534. private _teleportationRequested;
  109535. private _teleportActive;
  109536. private _floorMeshName;
  109537. private _floorMeshesCollection;
  109538. private _rotationAllowed;
  109539. private _teleportBackwardsVector;
  109540. private _teleportationTarget;
  109541. private _isDefaultTeleportationTarget;
  109542. private _postProcessMove;
  109543. private _teleportationFillColor;
  109544. private _teleportationBorderColor;
  109545. private _rotationAngle;
  109546. private _haloCenter;
  109547. private _cameraGazer;
  109548. private _padSensibilityUp;
  109549. private _padSensibilityDown;
  109550. private _leftController;
  109551. private _rightController;
  109552. /**
  109553. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109554. */
  109555. onNewMeshSelected: Observable<AbstractMesh>;
  109556. /**
  109557. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109558. * This observable will provide the mesh and the controller used to select the mesh
  109559. */
  109560. onMeshSelectedWithController: Observable<{
  109561. mesh: AbstractMesh;
  109562. controller: WebVRController;
  109563. }>;
  109564. /**
  109565. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109566. */
  109567. onNewMeshPicked: Observable<PickingInfo>;
  109568. private _circleEase;
  109569. /**
  109570. * Observable raised before camera teleportation
  109571. */
  109572. onBeforeCameraTeleport: Observable<Vector3>;
  109573. /**
  109574. * Observable raised after camera teleportation
  109575. */
  109576. onAfterCameraTeleport: Observable<Vector3>;
  109577. /**
  109578. * Observable raised when current selected mesh gets unselected
  109579. */
  109580. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109581. private _raySelectionPredicate;
  109582. /**
  109583. * To be optionaly changed by user to define custom ray selection
  109584. */
  109585. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109586. /**
  109587. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109588. */
  109589. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109590. /**
  109591. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109592. */
  109593. teleportationEnabled: boolean;
  109594. private _defaultHeight;
  109595. private _teleportationInitialized;
  109596. private _interactionsEnabled;
  109597. private _interactionsRequested;
  109598. private _displayGaze;
  109599. private _displayLaserPointer;
  109600. /**
  109601. * The mesh used to display where the user is going to teleport.
  109602. */
  109603. /**
  109604. * Sets the mesh to be used to display where the user is going to teleport.
  109605. */
  109606. teleportationTarget: Mesh;
  109607. /**
  109608. * 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
  109609. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109610. * See http://doc.babylonjs.com/resources/baking_transformations
  109611. */
  109612. gazeTrackerMesh: Mesh;
  109613. /**
  109614. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109615. */
  109616. updateGazeTrackerScale: boolean;
  109617. /**
  109618. * If the gaze trackers color should be updated when selecting meshes
  109619. */
  109620. updateGazeTrackerColor: boolean;
  109621. /**
  109622. * If the controller laser color should be updated when selecting meshes
  109623. */
  109624. updateControllerLaserColor: boolean;
  109625. /**
  109626. * The gaze tracking mesh corresponding to the left controller
  109627. */
  109628. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109629. /**
  109630. * The gaze tracking mesh corresponding to the right controller
  109631. */
  109632. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109633. /**
  109634. * If the ray of the gaze should be displayed.
  109635. */
  109636. /**
  109637. * Sets if the ray of the gaze should be displayed.
  109638. */
  109639. displayGaze: boolean;
  109640. /**
  109641. * If the ray of the LaserPointer should be displayed.
  109642. */
  109643. /**
  109644. * Sets if the ray of the LaserPointer should be displayed.
  109645. */
  109646. displayLaserPointer: boolean;
  109647. /**
  109648. * The deviceOrientationCamera used as the camera when not in VR.
  109649. */
  109650. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109651. /**
  109652. * Based on the current WebVR support, returns the current VR camera used.
  109653. */
  109654. readonly currentVRCamera: Nullable<Camera>;
  109655. /**
  109656. * The webVRCamera which is used when in VR.
  109657. */
  109658. readonly webVRCamera: WebVRFreeCamera;
  109659. /**
  109660. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109661. */
  109662. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109663. /**
  109664. * The html button that is used to trigger entering into VR.
  109665. */
  109666. readonly vrButton: Nullable<HTMLButtonElement>;
  109667. private readonly _teleportationRequestInitiated;
  109668. /**
  109669. * Defines wether or not Pointer lock should be requested when switching to
  109670. * full screen.
  109671. */
  109672. requestPointerLockOnFullScreen: boolean;
  109673. /**
  109674. * Instantiates a VRExperienceHelper.
  109675. * Helps to quickly add VR support to an existing scene.
  109676. * @param scene The scene the VRExperienceHelper belongs to.
  109677. * @param webVROptions Options to modify the vr experience helper's behavior.
  109678. */
  109679. constructor(scene: Scene,
  109680. /** Options to modify the vr experience helper's behavior. */
  109681. webVROptions?: VRExperienceHelperOptions);
  109682. private _onDefaultMeshLoaded;
  109683. private _onResize;
  109684. private _onFullscreenChange;
  109685. /**
  109686. * Gets a value indicating if we are currently in VR mode.
  109687. */
  109688. readonly isInVRMode: boolean;
  109689. private onVrDisplayPresentChange;
  109690. private onVRDisplayChanged;
  109691. private moveButtonToBottomRight;
  109692. private displayVRButton;
  109693. private updateButtonVisibility;
  109694. private _cachedAngularSensibility;
  109695. /**
  109696. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109697. * Otherwise, will use the fullscreen API.
  109698. */
  109699. enterVR(): void;
  109700. /**
  109701. * Attempt to exit VR, or fullscreen.
  109702. */
  109703. exitVR(): void;
  109704. /**
  109705. * The position of the vr experience helper.
  109706. */
  109707. /**
  109708. * Sets the position of the vr experience helper.
  109709. */
  109710. position: Vector3;
  109711. /**
  109712. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109713. */
  109714. enableInteractions(): void;
  109715. private readonly _noControllerIsActive;
  109716. private beforeRender;
  109717. private _isTeleportationFloor;
  109718. /**
  109719. * Adds a floor mesh to be used for teleportation.
  109720. * @param floorMesh the mesh to be used for teleportation.
  109721. */
  109722. addFloorMesh(floorMesh: Mesh): void;
  109723. /**
  109724. * Removes a floor mesh from being used for teleportation.
  109725. * @param floorMesh the mesh to be removed.
  109726. */
  109727. removeFloorMesh(floorMesh: Mesh): void;
  109728. /**
  109729. * Enables interactions and teleportation using the VR controllers and gaze.
  109730. * @param vrTeleportationOptions options to modify teleportation behavior.
  109731. */
  109732. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109733. private _onNewGamepadConnected;
  109734. private _tryEnableInteractionOnController;
  109735. private _onNewGamepadDisconnected;
  109736. private _enableInteractionOnController;
  109737. private _checkTeleportWithRay;
  109738. private _checkRotate;
  109739. private _checkTeleportBackwards;
  109740. private _enableTeleportationOnController;
  109741. private _createTeleportationCircles;
  109742. private _displayTeleportationTarget;
  109743. private _hideTeleportationTarget;
  109744. private _rotateCamera;
  109745. private _moveTeleportationSelectorTo;
  109746. private _workingVector;
  109747. private _workingQuaternion;
  109748. private _workingMatrix;
  109749. /**
  109750. * Teleports the users feet to the desired location
  109751. * @param location The location where the user's feet should be placed
  109752. */
  109753. teleportCamera(location: Vector3): void;
  109754. private _convertNormalToDirectionOfRay;
  109755. private _castRayAndSelectObject;
  109756. private _notifySelectedMeshUnselected;
  109757. /**
  109758. * Sets the color of the laser ray from the vr controllers.
  109759. * @param color new color for the ray.
  109760. */
  109761. changeLaserColor(color: Color3): void;
  109762. /**
  109763. * Sets the color of the ray from the vr headsets gaze.
  109764. * @param color new color for the ray.
  109765. */
  109766. changeGazeColor(color: Color3): void;
  109767. /**
  109768. * Exits VR and disposes of the vr experience helper
  109769. */
  109770. dispose(): void;
  109771. /**
  109772. * Gets the name of the VRExperienceHelper class
  109773. * @returns "VRExperienceHelper"
  109774. */
  109775. getClassName(): string;
  109776. }
  109777. }
  109778. declare module BABYLON {
  109779. /**
  109780. * States of the webXR experience
  109781. */
  109782. export enum WebXRState {
  109783. /**
  109784. * Transitioning to being in XR mode
  109785. */
  109786. ENTERING_XR = 0,
  109787. /**
  109788. * Transitioning to non XR mode
  109789. */
  109790. EXITING_XR = 1,
  109791. /**
  109792. * In XR mode and presenting
  109793. */
  109794. IN_XR = 2,
  109795. /**
  109796. * Not entered XR mode
  109797. */
  109798. NOT_IN_XR = 3
  109799. }
  109800. /**
  109801. * Abstraction of the XR render target
  109802. */
  109803. export interface WebXRRenderTarget extends IDisposable {
  109804. /**
  109805. * xrpresent context of the canvas which can be used to display/mirror xr content
  109806. */
  109807. canvasContext: WebGLRenderingContext;
  109808. /**
  109809. * xr layer for the canvas
  109810. */
  109811. xrLayer: Nullable<XRWebGLLayer>;
  109812. /**
  109813. * Initializes the xr layer for the session
  109814. * @param xrSession xr session
  109815. * @returns a promise that will resolve once the XR Layer has been created
  109816. */
  109817. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  109818. }
  109819. }
  109820. declare module BABYLON {
  109821. /**
  109822. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109823. */
  109824. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  109825. private _engine;
  109826. private _canvas;
  109827. /**
  109828. * xrpresent context of the canvas which can be used to display/mirror xr content
  109829. */
  109830. canvasContext: WebGLRenderingContext;
  109831. /**
  109832. * xr layer for the canvas
  109833. */
  109834. xrLayer: Nullable<XRWebGLLayer>;
  109835. /**
  109836. * Initializes the xr layer for the session
  109837. * @param xrSession xr session
  109838. * @returns a promise that will resolve once the XR Layer has been created
  109839. */
  109840. initializeXRLayerAsync(xrSession: any): any;
  109841. /**
  109842. * Initializes the canvas to be added/removed upon entering/exiting xr
  109843. * @param engine the Babylon engine
  109844. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109845. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  109846. */
  109847. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  109848. /**
  109849. * Disposes of the object
  109850. */
  109851. dispose(): void;
  109852. private _setManagedOutputCanvas;
  109853. private _addCanvas;
  109854. private _removeCanvas;
  109855. }
  109856. }
  109857. declare module BABYLON {
  109858. /**
  109859. * Manages an XRSession to work with Babylon's engine
  109860. * @see https://doc.babylonjs.com/how_to/webxr
  109861. */
  109862. export class WebXRSessionManager implements IDisposable {
  109863. private scene;
  109864. /**
  109865. * Fires every time a new xrFrame arrives which can be used to update the camera
  109866. */
  109867. onXRFrameObservable: Observable<any>;
  109868. /**
  109869. * Fires when the xr session is ended either by the device or manually done
  109870. */
  109871. onXRSessionEnded: Observable<any>;
  109872. /**
  109873. * Underlying xr session
  109874. */
  109875. session: XRSession;
  109876. /**
  109877. * Type of reference space used when creating the session
  109878. */
  109879. referenceSpace: XRReferenceSpace;
  109880. /**
  109881. * Current XR frame
  109882. */
  109883. currentFrame: Nullable<XRFrame>;
  109884. private _xrNavigator;
  109885. private baseLayer;
  109886. private _rttProvider;
  109887. private _sessionEnded;
  109888. /**
  109889. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  109890. * @param scene The scene which the session should be created for
  109891. */
  109892. constructor(scene: Scene);
  109893. /**
  109894. * Initializes the manager
  109895. * After initialization enterXR can be called to start an XR session
  109896. * @returns Promise which resolves after it is initialized
  109897. */
  109898. initializeAsync(): Promise<void>;
  109899. /**
  109900. * Initializes an xr session
  109901. * @param xrSessionMode mode to initialize
  109902. * @param optionalFeatures defines optional values to pass to the session builder
  109903. * @returns a promise which will resolve once the session has been initialized
  109904. */
  109905. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  109906. /**
  109907. * Sets the reference space on the xr session
  109908. * @param referenceSpace space to set
  109909. * @returns a promise that will resolve once the reference space has been set
  109910. */
  109911. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  109912. /**
  109913. * Updates the render state of the session
  109914. * @param state state to set
  109915. * @returns a promise that resolves once the render state has been updated
  109916. */
  109917. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  109918. /**
  109919. * Starts rendering to the xr layer
  109920. * @returns a promise that will resolve once rendering has started
  109921. */
  109922. startRenderingToXRAsync(): Promise<void>;
  109923. /**
  109924. * Gets the correct render target texture to be rendered this frame for this eye
  109925. * @param eye the eye for which to get the render target
  109926. * @returns the render target for the specified eye
  109927. */
  109928. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  109929. /**
  109930. * Stops the xrSession and restores the renderloop
  109931. * @returns Promise which resolves after it exits XR
  109932. */
  109933. exitXRAsync(): Promise<void>;
  109934. /**
  109935. * Checks if a session would be supported for the creation options specified
  109936. * @param sessionMode session mode to check if supported eg. immersive-vr
  109937. * @returns true if supported
  109938. */
  109939. supportsSessionAsync(sessionMode: XRSessionMode): any;
  109940. /**
  109941. * Creates a WebXRRenderTarget object for the XR session
  109942. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  109943. * @returns a WebXR render target to which the session can render
  109944. */
  109945. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  109946. /**
  109947. * @hidden
  109948. * Converts the render layer of xrSession to a render target
  109949. * @param session session to create render target for
  109950. * @param scene scene the new render target should be created for
  109951. */
  109952. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  109953. /**
  109954. * Disposes of the session manager
  109955. */
  109956. dispose(): void;
  109957. }
  109958. }
  109959. declare module BABYLON {
  109960. /**
  109961. * WebXR Camera which holds the views for the xrSession
  109962. * @see https://doc.babylonjs.com/how_to/webxr
  109963. */
  109964. export class WebXRCamera extends FreeCamera {
  109965. private static _TmpMatrix;
  109966. /**
  109967. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  109968. * @param name the name of the camera
  109969. * @param scene the scene to add the camera to
  109970. */
  109971. constructor(name: string, scene: Scene);
  109972. private _updateNumberOfRigCameras;
  109973. /** @hidden */
  109974. _updateForDualEyeDebugging(): void;
  109975. /**
  109976. * Updates the cameras position from the current pose information of the XR session
  109977. * @param xrSessionManager the session containing pose information
  109978. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109979. */
  109980. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109981. }
  109982. }
  109983. declare module BABYLON {
  109984. /**
  109985. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109986. * @see https://doc.babylonjs.com/how_to/webxr
  109987. */
  109988. export class WebXRExperienceHelper implements IDisposable {
  109989. private scene;
  109990. /**
  109991. * 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
  109992. */
  109993. container: AbstractMesh;
  109994. /**
  109995. * Camera used to render xr content
  109996. */
  109997. camera: WebXRCamera;
  109998. /**
  109999. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110000. */
  110001. state: WebXRState;
  110002. private _setState;
  110003. private static _TmpVector;
  110004. /**
  110005. * Fires when the state of the experience helper has changed
  110006. */
  110007. onStateChangedObservable: Observable<WebXRState>;
  110008. /** Session manager used to keep track of xr session */
  110009. sessionManager: WebXRSessionManager;
  110010. private _nonVRCamera;
  110011. private _originalSceneAutoClear;
  110012. private _supported;
  110013. /**
  110014. * Creates the experience helper
  110015. * @param scene the scene to attach the experience helper to
  110016. * @returns a promise for the experience helper
  110017. */
  110018. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110019. /**
  110020. * Creates a WebXRExperienceHelper
  110021. * @param scene The scene the helper should be created in
  110022. */
  110023. private constructor();
  110024. /**
  110025. * Exits XR mode and returns the scene to its original state
  110026. * @returns promise that resolves after xr mode has exited
  110027. */
  110028. exitXRAsync(): Promise<void>;
  110029. /**
  110030. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110031. * @param sessionMode options for the XR session
  110032. * @param referenceSpaceType frame of reference of the XR session
  110033. * @param renderTarget the output canvas that will be used to enter XR mode
  110034. * @returns promise that resolves after xr mode has entered
  110035. */
  110036. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  110037. /**
  110038. * Updates the global position of the camera by moving the camera's container
  110039. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110040. * @param position The desired global position of the camera
  110041. */
  110042. setPositionOfCameraUsingContainer(position: Vector3): void;
  110043. /**
  110044. * Rotates the xr camera by rotating the camera's container around the camera's position
  110045. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110046. * @param rotation the desired quaternion rotation to apply to the camera
  110047. */
  110048. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110049. /**
  110050. * Disposes of the experience helper
  110051. */
  110052. dispose(): void;
  110053. }
  110054. }
  110055. declare module BABYLON {
  110056. /**
  110057. * Button which can be used to enter a different mode of XR
  110058. */
  110059. export class WebXREnterExitUIButton {
  110060. /** button element */
  110061. element: HTMLElement;
  110062. /** XR initialization options for the button */
  110063. sessionMode: XRSessionMode;
  110064. /** Reference space type */
  110065. referenceSpaceType: XRReferenceSpaceType;
  110066. /**
  110067. * Creates a WebXREnterExitUIButton
  110068. * @param element button element
  110069. * @param sessionMode XR initialization session mode
  110070. * @param referenceSpaceType the type of reference space to be used
  110071. */
  110072. constructor(
  110073. /** button element */
  110074. element: HTMLElement,
  110075. /** XR initialization options for the button */
  110076. sessionMode: XRSessionMode,
  110077. /** Reference space type */
  110078. referenceSpaceType: XRReferenceSpaceType);
  110079. /**
  110080. * Overwritable function which can be used to update the button's visuals when the state changes
  110081. * @param activeButton the current active button in the UI
  110082. */
  110083. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110084. }
  110085. /**
  110086. * Options to create the webXR UI
  110087. */
  110088. export class WebXREnterExitUIOptions {
  110089. /**
  110090. * Context to enter xr with
  110091. */
  110092. renderTarget?: Nullable<WebXRRenderTarget>;
  110093. /**
  110094. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110095. */
  110096. customButtons?: Array<WebXREnterExitUIButton>;
  110097. }
  110098. /**
  110099. * UI to allow the user to enter/exit XR mode
  110100. */
  110101. export class WebXREnterExitUI implements IDisposable {
  110102. private scene;
  110103. private _overlay;
  110104. private _buttons;
  110105. private _activeButton;
  110106. /**
  110107. * Fired every time the active button is changed.
  110108. *
  110109. * When xr is entered via a button that launches xr that button will be the callback parameter
  110110. *
  110111. * When exiting xr the callback parameter will be null)
  110112. */
  110113. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110114. /**
  110115. * Creates UI to allow the user to enter/exit XR mode
  110116. * @param scene the scene to add the ui to
  110117. * @param helper the xr experience helper to enter/exit xr with
  110118. * @param options options to configure the UI
  110119. * @returns the created ui
  110120. */
  110121. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110122. private constructor();
  110123. private _updateButtons;
  110124. /**
  110125. * Disposes of the object
  110126. */
  110127. dispose(): void;
  110128. }
  110129. }
  110130. declare module BABYLON {
  110131. /**
  110132. * Represents an XR input
  110133. */
  110134. export class WebXRController {
  110135. private scene;
  110136. /** The underlying input source for the controller */
  110137. inputSource: XRInputSource;
  110138. private parentContainer;
  110139. /**
  110140. * 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
  110141. */
  110142. grip?: AbstractMesh;
  110143. /**
  110144. * Pointer which can be used to select objects or attach a visible laser to
  110145. */
  110146. pointer: AbstractMesh;
  110147. private _gamepadMode;
  110148. /**
  110149. * If available, this is the gamepad object related to this controller.
  110150. * Using this object it is possible to get click events and trackpad changes of the
  110151. * webxr controller that is currently being used.
  110152. */
  110153. gamepadController?: WebVRController;
  110154. /**
  110155. * Event that fires when the controller is removed/disposed
  110156. */
  110157. onDisposeObservable: Observable<{}>;
  110158. private _tmpMatrix;
  110159. private _tmpQuaternion;
  110160. private _tmpVector;
  110161. /**
  110162. * Creates the controller
  110163. * @see https://doc.babylonjs.com/how_to/webxr
  110164. * @param scene the scene which the controller should be associated to
  110165. * @param inputSource the underlying input source for the controller
  110166. * @param parentContainer parent that the controller meshes should be children of
  110167. */
  110168. constructor(scene: Scene,
  110169. /** The underlying input source for the controller */
  110170. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110171. /**
  110172. * Updates the controller pose based on the given XRFrame
  110173. * @param xrFrame xr frame to update the pose with
  110174. * @param referenceSpace reference space to use
  110175. */
  110176. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110177. /**
  110178. * Gets a world space ray coming from the controller
  110179. * @param result the resulting ray
  110180. */
  110181. getWorldPointerRayToRef(result: Ray): void;
  110182. /**
  110183. * Get the scene associated with this controller
  110184. * @returns the scene object
  110185. */
  110186. getScene(): Scene;
  110187. /**
  110188. * Disposes of the object
  110189. */
  110190. dispose(): void;
  110191. }
  110192. }
  110193. declare module BABYLON {
  110194. /**
  110195. * XR input used to track XR inputs such as controllers/rays
  110196. */
  110197. export class WebXRInput implements IDisposable {
  110198. /**
  110199. * Base experience the input listens to
  110200. */
  110201. baseExperience: WebXRExperienceHelper;
  110202. /**
  110203. * XR controllers being tracked
  110204. */
  110205. controllers: Array<WebXRController>;
  110206. private _frameObserver;
  110207. private _stateObserver;
  110208. /**
  110209. * Event when a controller has been connected/added
  110210. */
  110211. onControllerAddedObservable: Observable<WebXRController>;
  110212. /**
  110213. * Event when a controller has been removed/disconnected
  110214. */
  110215. onControllerRemovedObservable: Observable<WebXRController>;
  110216. /**
  110217. * Initializes the WebXRInput
  110218. * @param baseExperience experience helper which the input should be created for
  110219. */
  110220. constructor(
  110221. /**
  110222. * Base experience the input listens to
  110223. */
  110224. baseExperience: WebXRExperienceHelper);
  110225. private _onInputSourcesChange;
  110226. private _addAndRemoveControllers;
  110227. /**
  110228. * Disposes of the object
  110229. */
  110230. dispose(): void;
  110231. }
  110232. }
  110233. declare module BABYLON {
  110234. /**
  110235. * Enables teleportation
  110236. */
  110237. export class WebXRControllerTeleportation {
  110238. private _teleportationFillColor;
  110239. private _teleportationBorderColor;
  110240. private _tmpRay;
  110241. private _tmpVector;
  110242. /**
  110243. * Creates a WebXRControllerTeleportation
  110244. * @param input input manager to add teleportation to
  110245. * @param floorMeshes floormeshes which can be teleported to
  110246. */
  110247. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110248. }
  110249. }
  110250. declare module BABYLON {
  110251. /**
  110252. * Handles pointer input automatically for the pointer of XR controllers
  110253. */
  110254. export class WebXRControllerPointerSelection {
  110255. private static _idCounter;
  110256. private _tmpRay;
  110257. /**
  110258. * Creates a WebXRControllerPointerSelection
  110259. * @param input input manager to setup pointer selection
  110260. */
  110261. constructor(input: WebXRInput);
  110262. private _convertNormalToDirectionOfRay;
  110263. private _updatePointerDistance;
  110264. }
  110265. }
  110266. declare module BABYLON {
  110267. /**
  110268. * Class used to represent data loading progression
  110269. */
  110270. export class SceneLoaderProgressEvent {
  110271. /** defines if data length to load can be evaluated */
  110272. readonly lengthComputable: boolean;
  110273. /** defines the loaded data length */
  110274. readonly loaded: number;
  110275. /** defines the data length to load */
  110276. readonly total: number;
  110277. /**
  110278. * Create a new progress event
  110279. * @param lengthComputable defines if data length to load can be evaluated
  110280. * @param loaded defines the loaded data length
  110281. * @param total defines the data length to load
  110282. */
  110283. constructor(
  110284. /** defines if data length to load can be evaluated */
  110285. lengthComputable: boolean,
  110286. /** defines the loaded data length */
  110287. loaded: number,
  110288. /** defines the data length to load */
  110289. total: number);
  110290. /**
  110291. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110292. * @param event defines the source event
  110293. * @returns a new SceneLoaderProgressEvent
  110294. */
  110295. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110296. }
  110297. /**
  110298. * Interface used by SceneLoader plugins to define supported file extensions
  110299. */
  110300. export interface ISceneLoaderPluginExtensions {
  110301. /**
  110302. * Defines the list of supported extensions
  110303. */
  110304. [extension: string]: {
  110305. isBinary: boolean;
  110306. };
  110307. }
  110308. /**
  110309. * Interface used by SceneLoader plugin factory
  110310. */
  110311. export interface ISceneLoaderPluginFactory {
  110312. /**
  110313. * Defines the name of the factory
  110314. */
  110315. name: string;
  110316. /**
  110317. * Function called to create a new plugin
  110318. * @return the new plugin
  110319. */
  110320. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110321. /**
  110322. * The callback that returns true if the data can be directly loaded.
  110323. * @param data string containing the file data
  110324. * @returns if the data can be loaded directly
  110325. */
  110326. canDirectLoad?(data: string): boolean;
  110327. }
  110328. /**
  110329. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110330. */
  110331. export interface ISceneLoaderPluginBase {
  110332. /**
  110333. * The friendly name of this plugin.
  110334. */
  110335. name: string;
  110336. /**
  110337. * The file extensions supported by this plugin.
  110338. */
  110339. extensions: string | ISceneLoaderPluginExtensions;
  110340. /**
  110341. * The callback called when loading from a url.
  110342. * @param scene scene loading this url
  110343. * @param url url to load
  110344. * @param onSuccess callback called when the file successfully loads
  110345. * @param onProgress callback called while file is loading (if the server supports this mode)
  110346. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110347. * @param onError callback called when the file fails to load
  110348. * @returns a file request object
  110349. */
  110350. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110351. /**
  110352. * The callback called when loading from a file object.
  110353. * @param scene scene loading this file
  110354. * @param file defines the file to load
  110355. * @param onSuccess defines the callback to call when data is loaded
  110356. * @param onProgress defines the callback to call during loading process
  110357. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110358. * @param onError defines the callback to call when an error occurs
  110359. * @returns a file request object
  110360. */
  110361. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110362. /**
  110363. * The callback that returns true if the data can be directly loaded.
  110364. * @param data string containing the file data
  110365. * @returns if the data can be loaded directly
  110366. */
  110367. canDirectLoad?(data: string): boolean;
  110368. /**
  110369. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110370. * @param scene scene loading this data
  110371. * @param data string containing the data
  110372. * @returns data to pass to the plugin
  110373. */
  110374. directLoad?(scene: Scene, data: string): any;
  110375. /**
  110376. * The callback that allows custom handling of the root url based on the response url.
  110377. * @param rootUrl the original root url
  110378. * @param responseURL the response url if available
  110379. * @returns the new root url
  110380. */
  110381. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110382. }
  110383. /**
  110384. * Interface used to define a SceneLoader plugin
  110385. */
  110386. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110387. /**
  110388. * Import meshes into a scene.
  110389. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110390. * @param scene The scene to import into
  110391. * @param data The data to import
  110392. * @param rootUrl The root url for scene and resources
  110393. * @param meshes The meshes array to import into
  110394. * @param particleSystems The particle systems array to import into
  110395. * @param skeletons The skeletons array to import into
  110396. * @param onError The callback when import fails
  110397. * @returns True if successful or false otherwise
  110398. */
  110399. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110400. /**
  110401. * Load into a scene.
  110402. * @param scene The scene to load into
  110403. * @param data The data to import
  110404. * @param rootUrl The root url for scene and resources
  110405. * @param onError The callback when import fails
  110406. * @returns True if successful or false otherwise
  110407. */
  110408. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110409. /**
  110410. * Load into an asset container.
  110411. * @param scene The scene to load into
  110412. * @param data The data to import
  110413. * @param rootUrl The root url for scene and resources
  110414. * @param onError The callback when import fails
  110415. * @returns The loaded asset container
  110416. */
  110417. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110418. }
  110419. /**
  110420. * Interface used to define an async SceneLoader plugin
  110421. */
  110422. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110423. /**
  110424. * Import meshes into a scene.
  110425. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110426. * @param scene The scene to import into
  110427. * @param data The data to import
  110428. * @param rootUrl The root url for scene and resources
  110429. * @param onProgress The callback when the load progresses
  110430. * @param fileName Defines the name of the file to load
  110431. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110432. */
  110433. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110434. meshes: AbstractMesh[];
  110435. particleSystems: IParticleSystem[];
  110436. skeletons: Skeleton[];
  110437. animationGroups: AnimationGroup[];
  110438. }>;
  110439. /**
  110440. * Load into a scene.
  110441. * @param scene The scene to load into
  110442. * @param data The data to import
  110443. * @param rootUrl The root url for scene and resources
  110444. * @param onProgress The callback when the load progresses
  110445. * @param fileName Defines the name of the file to load
  110446. * @returns Nothing
  110447. */
  110448. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110449. /**
  110450. * Load into an asset container.
  110451. * @param scene The scene to load into
  110452. * @param data The data to import
  110453. * @param rootUrl The root url for scene and resources
  110454. * @param onProgress The callback when the load progresses
  110455. * @param fileName Defines the name of the file to load
  110456. * @returns The loaded asset container
  110457. */
  110458. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110459. }
  110460. /**
  110461. * Class used to load scene from various file formats using registered plugins
  110462. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110463. */
  110464. export class SceneLoader {
  110465. /**
  110466. * No logging while loading
  110467. */
  110468. static readonly NO_LOGGING: number;
  110469. /**
  110470. * Minimal logging while loading
  110471. */
  110472. static readonly MINIMAL_LOGGING: number;
  110473. /**
  110474. * Summary logging while loading
  110475. */
  110476. static readonly SUMMARY_LOGGING: number;
  110477. /**
  110478. * Detailled logging while loading
  110479. */
  110480. static readonly DETAILED_LOGGING: number;
  110481. /**
  110482. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110483. */
  110484. static ForceFullSceneLoadingForIncremental: boolean;
  110485. /**
  110486. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110487. */
  110488. static ShowLoadingScreen: boolean;
  110489. /**
  110490. * Defines the current logging level (while loading the scene)
  110491. * @ignorenaming
  110492. */
  110493. static loggingLevel: number;
  110494. /**
  110495. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110496. */
  110497. static CleanBoneMatrixWeights: boolean;
  110498. /**
  110499. * Event raised when a plugin is used to load a scene
  110500. */
  110501. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110502. private static _registeredPlugins;
  110503. private static _getDefaultPlugin;
  110504. private static _getPluginForExtension;
  110505. private static _getPluginForDirectLoad;
  110506. private static _getPluginForFilename;
  110507. private static _getDirectLoad;
  110508. private static _loadData;
  110509. private static _getFileInfo;
  110510. /**
  110511. * Gets a plugin that can load the given extension
  110512. * @param extension defines the extension to load
  110513. * @returns a plugin or null if none works
  110514. */
  110515. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110516. /**
  110517. * Gets a boolean indicating that the given extension can be loaded
  110518. * @param extension defines the extension to load
  110519. * @returns true if the extension is supported
  110520. */
  110521. static IsPluginForExtensionAvailable(extension: string): boolean;
  110522. /**
  110523. * Adds a new plugin to the list of registered plugins
  110524. * @param plugin defines the plugin to add
  110525. */
  110526. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110527. /**
  110528. * Import meshes into a scene
  110529. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110530. * @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)
  110531. * @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)
  110532. * @param scene the instance of BABYLON.Scene to append to
  110533. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110534. * @param onProgress a callback with a progress event for each file being loaded
  110535. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110536. * @param pluginExtension the extension used to determine the plugin
  110537. * @returns The loaded plugin
  110538. */
  110539. 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>;
  110540. /**
  110541. * Import meshes into a scene
  110542. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110543. * @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)
  110544. * @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)
  110545. * @param scene the instance of BABYLON.Scene to append to
  110546. * @param onProgress a callback with a progress event for each file being loaded
  110547. * @param pluginExtension the extension used to determine the plugin
  110548. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110549. */
  110550. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110551. meshes: AbstractMesh[];
  110552. particleSystems: IParticleSystem[];
  110553. skeletons: Skeleton[];
  110554. animationGroups: AnimationGroup[];
  110555. }>;
  110556. /**
  110557. * Load a scene
  110558. * @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)
  110559. * @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)
  110560. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110561. * @param onSuccess a callback with the scene when import succeeds
  110562. * @param onProgress a callback with a progress event for each file being loaded
  110563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110564. * @param pluginExtension the extension used to determine the plugin
  110565. * @returns The loaded plugin
  110566. */
  110567. 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>;
  110568. /**
  110569. * Load a scene
  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 engine is the instance of BABYLON.Engine to use to create the scene
  110573. * @param onProgress a callback with a progress event for each file being loaded
  110574. * @param pluginExtension the extension used to determine the plugin
  110575. * @returns The loaded scene
  110576. */
  110577. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110578. /**
  110579. * Append a scene
  110580. * @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)
  110581. * @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)
  110582. * @param scene is the instance of BABYLON.Scene to append to
  110583. * @param onSuccess a callback with the scene when import succeeds
  110584. * @param onProgress a callback with a progress event for each file being loaded
  110585. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110586. * @param pluginExtension the extension used to determine the plugin
  110587. * @returns The loaded plugin
  110588. */
  110589. 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>;
  110590. /**
  110591. * Append a scene
  110592. * @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)
  110593. * @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)
  110594. * @param scene is the instance of BABYLON.Scene to append to
  110595. * @param onProgress a callback with a progress event for each file being loaded
  110596. * @param pluginExtension the extension used to determine the plugin
  110597. * @returns The given scene
  110598. */
  110599. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110600. /**
  110601. * Load a scene into an asset container
  110602. * @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)
  110603. * @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)
  110604. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110605. * @param onSuccess a callback with the scene when import succeeds
  110606. * @param onProgress a callback with a progress event for each file being loaded
  110607. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110608. * @param pluginExtension the extension used to determine the plugin
  110609. * @returns The loaded plugin
  110610. */
  110611. 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>;
  110612. /**
  110613. * Load a scene into an asset container
  110614. * @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)
  110615. * @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)
  110616. * @param scene is the instance of Scene to append to
  110617. * @param onProgress a callback with a progress event for each file being loaded
  110618. * @param pluginExtension the extension used to determine the plugin
  110619. * @returns The loaded asset container
  110620. */
  110621. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110622. }
  110623. }
  110624. declare module BABYLON {
  110625. /**
  110626. * Generic Controller
  110627. */
  110628. export class GenericController extends WebVRController {
  110629. /**
  110630. * Base Url for the controller model.
  110631. */
  110632. static readonly MODEL_BASE_URL: string;
  110633. /**
  110634. * File name for the controller model.
  110635. */
  110636. static readonly MODEL_FILENAME: string;
  110637. /**
  110638. * Creates a new GenericController from a gamepad
  110639. * @param vrGamepad the gamepad that the controller should be created from
  110640. */
  110641. constructor(vrGamepad: any);
  110642. /**
  110643. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110644. * @param scene scene in which to add meshes
  110645. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110646. */
  110647. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110648. /**
  110649. * Called once for each button that changed state since the last frame
  110650. * @param buttonIdx Which button index changed
  110651. * @param state New state of the button
  110652. * @param changes Which properties on the state changed since last frame
  110653. */
  110654. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110655. }
  110656. }
  110657. declare module BABYLON {
  110658. /**
  110659. * Defines the WindowsMotionController object that the state of the windows motion controller
  110660. */
  110661. export class WindowsMotionController extends WebVRController {
  110662. /**
  110663. * The base url used to load the left and right controller models
  110664. */
  110665. static MODEL_BASE_URL: string;
  110666. /**
  110667. * The name of the left controller model file
  110668. */
  110669. static MODEL_LEFT_FILENAME: string;
  110670. /**
  110671. * The name of the right controller model file
  110672. */
  110673. static MODEL_RIGHT_FILENAME: string;
  110674. /**
  110675. * The controller name prefix for this controller type
  110676. */
  110677. static readonly GAMEPAD_ID_PREFIX: string;
  110678. /**
  110679. * The controller id pattern for this controller type
  110680. */
  110681. private static readonly GAMEPAD_ID_PATTERN;
  110682. private _loadedMeshInfo;
  110683. private readonly _mapping;
  110684. /**
  110685. * Fired when the trackpad on this controller is clicked
  110686. */
  110687. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110688. /**
  110689. * Fired when the trackpad on this controller is modified
  110690. */
  110691. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110692. /**
  110693. * The current x and y values of this controller's trackpad
  110694. */
  110695. trackpad: StickValues;
  110696. /**
  110697. * Creates a new WindowsMotionController from a gamepad
  110698. * @param vrGamepad the gamepad that the controller should be created from
  110699. */
  110700. constructor(vrGamepad: any);
  110701. /**
  110702. * Fired when the trigger on this controller is modified
  110703. */
  110704. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110705. /**
  110706. * Fired when the menu button on this controller is modified
  110707. */
  110708. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110709. /**
  110710. * Fired when the grip button on this controller is modified
  110711. */
  110712. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110713. /**
  110714. * Fired when the thumbstick button on this controller is modified
  110715. */
  110716. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110717. /**
  110718. * Fired when the touchpad button on this controller is modified
  110719. */
  110720. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110721. /**
  110722. * Fired when the touchpad values on this controller are modified
  110723. */
  110724. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110725. private _updateTrackpad;
  110726. /**
  110727. * Called once per frame by the engine.
  110728. */
  110729. update(): void;
  110730. /**
  110731. * Called once for each button that changed state since the last frame
  110732. * @param buttonIdx Which button index changed
  110733. * @param state New state of the button
  110734. * @param changes Which properties on the state changed since last frame
  110735. */
  110736. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110737. /**
  110738. * Moves the buttons on the controller mesh based on their current state
  110739. * @param buttonName the name of the button to move
  110740. * @param buttonValue the value of the button which determines the buttons new position
  110741. */
  110742. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  110743. /**
  110744. * Moves the axis on the controller mesh based on its current state
  110745. * @param axis the index of the axis
  110746. * @param axisValue the value of the axis which determines the meshes new position
  110747. * @hidden
  110748. */
  110749. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  110750. /**
  110751. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110752. * @param scene scene in which to add meshes
  110753. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110754. */
  110755. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  110756. /**
  110757. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  110758. * can be transformed by button presses and axes values, based on this._mapping.
  110759. *
  110760. * @param scene scene in which the meshes exist
  110761. * @param meshes list of meshes that make up the controller model to process
  110762. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  110763. */
  110764. private processModel;
  110765. private createMeshInfo;
  110766. /**
  110767. * Gets the ray of the controller in the direction the controller is pointing
  110768. * @param length the length the resulting ray should be
  110769. * @returns a ray in the direction the controller is pointing
  110770. */
  110771. getForwardRay(length?: number): Ray;
  110772. /**
  110773. * Disposes of the controller
  110774. */
  110775. dispose(): void;
  110776. }
  110777. }
  110778. declare module BABYLON {
  110779. /**
  110780. * Oculus Touch Controller
  110781. */
  110782. export class OculusTouchController extends WebVRController {
  110783. /**
  110784. * Base Url for the controller model.
  110785. */
  110786. static MODEL_BASE_URL: string;
  110787. /**
  110788. * File name for the left controller model.
  110789. */
  110790. static MODEL_LEFT_FILENAME: string;
  110791. /**
  110792. * File name for the right controller model.
  110793. */
  110794. static MODEL_RIGHT_FILENAME: string;
  110795. /**
  110796. * Base Url for the Quest controller model.
  110797. */
  110798. static QUEST_MODEL_BASE_URL: string;
  110799. /**
  110800. * @hidden
  110801. * If the controllers are running on a device that needs the updated Quest controller models
  110802. */
  110803. static _IsQuest: boolean;
  110804. /**
  110805. * Fired when the secondary trigger on this controller is modified
  110806. */
  110807. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  110808. /**
  110809. * Fired when the thumb rest on this controller is modified
  110810. */
  110811. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  110812. /**
  110813. * Creates a new OculusTouchController from a gamepad
  110814. * @param vrGamepad the gamepad that the controller should be created from
  110815. */
  110816. constructor(vrGamepad: any);
  110817. /**
  110818. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110819. * @param scene scene in which to add meshes
  110820. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110821. */
  110822. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110823. /**
  110824. * Fired when the A button on this controller is modified
  110825. */
  110826. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110827. /**
  110828. * Fired when the B button on this controller is modified
  110829. */
  110830. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110831. /**
  110832. * Fired when the X button on this controller is modified
  110833. */
  110834. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110835. /**
  110836. * Fired when the Y button on this controller is modified
  110837. */
  110838. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110839. /**
  110840. * Called once for each button that changed state since the last frame
  110841. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  110842. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  110843. * 2) secondary trigger (same)
  110844. * 3) A (right) X (left), touch, pressed = value
  110845. * 4) B / Y
  110846. * 5) thumb rest
  110847. * @param buttonIdx Which button index changed
  110848. * @param state New state of the button
  110849. * @param changes Which properties on the state changed since last frame
  110850. */
  110851. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110852. }
  110853. }
  110854. declare module BABYLON {
  110855. /**
  110856. * Vive Controller
  110857. */
  110858. export class ViveController extends WebVRController {
  110859. /**
  110860. * Base Url for the controller model.
  110861. */
  110862. static MODEL_BASE_URL: string;
  110863. /**
  110864. * File name for the controller model.
  110865. */
  110866. static MODEL_FILENAME: string;
  110867. /**
  110868. * Creates a new ViveController from a gamepad
  110869. * @param vrGamepad the gamepad that the controller should be created from
  110870. */
  110871. constructor(vrGamepad: any);
  110872. /**
  110873. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110874. * @param scene scene in which to add meshes
  110875. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110876. */
  110877. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110878. /**
  110879. * Fired when the left button on this controller is modified
  110880. */
  110881. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110882. /**
  110883. * Fired when the right button on this controller is modified
  110884. */
  110885. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110886. /**
  110887. * Fired when the menu button on this controller is modified
  110888. */
  110889. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110890. /**
  110891. * Called once for each button that changed state since the last frame
  110892. * Vive mapping:
  110893. * 0: touchpad
  110894. * 1: trigger
  110895. * 2: left AND right buttons
  110896. * 3: menu button
  110897. * @param buttonIdx Which button index changed
  110898. * @param state New state of the button
  110899. * @param changes Which properties on the state changed since last frame
  110900. */
  110901. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110902. }
  110903. }
  110904. declare module BABYLON {
  110905. /**
  110906. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  110907. */
  110908. export class WebXRControllerModelLoader {
  110909. /**
  110910. * Creates the WebXRControllerModelLoader
  110911. * @param input xr input that creates the controllers
  110912. */
  110913. constructor(input: WebXRInput);
  110914. }
  110915. }
  110916. declare module BABYLON {
  110917. /**
  110918. * Contains an array of blocks representing the octree
  110919. */
  110920. export interface IOctreeContainer<T> {
  110921. /**
  110922. * Blocks within the octree
  110923. */
  110924. blocks: Array<OctreeBlock<T>>;
  110925. }
  110926. /**
  110927. * Class used to store a cell in an octree
  110928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110929. */
  110930. export class OctreeBlock<T> {
  110931. /**
  110932. * Gets the content of the current block
  110933. */
  110934. entries: T[];
  110935. /**
  110936. * Gets the list of block children
  110937. */
  110938. blocks: Array<OctreeBlock<T>>;
  110939. private _depth;
  110940. private _maxDepth;
  110941. private _capacity;
  110942. private _minPoint;
  110943. private _maxPoint;
  110944. private _boundingVectors;
  110945. private _creationFunc;
  110946. /**
  110947. * Creates a new block
  110948. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110949. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110950. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110951. * @param depth defines the current depth of this block in the octree
  110952. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110953. * @param creationFunc defines a callback to call when an element is added to the block
  110954. */
  110955. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110956. /**
  110957. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110958. */
  110959. readonly capacity: number;
  110960. /**
  110961. * Gets the minimum vector (in world space) of the block's bounding box
  110962. */
  110963. readonly minPoint: Vector3;
  110964. /**
  110965. * Gets the maximum vector (in world space) of the block's bounding box
  110966. */
  110967. readonly maxPoint: Vector3;
  110968. /**
  110969. * Add a new element to this block
  110970. * @param entry defines the element to add
  110971. */
  110972. addEntry(entry: T): void;
  110973. /**
  110974. * Remove an element from this block
  110975. * @param entry defines the element to remove
  110976. */
  110977. removeEntry(entry: T): void;
  110978. /**
  110979. * Add an array of elements to this block
  110980. * @param entries defines the array of elements to add
  110981. */
  110982. addEntries(entries: T[]): void;
  110983. /**
  110984. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110985. * @param frustumPlanes defines the frustum planes to test
  110986. * @param selection defines the array to store current content if selection is positive
  110987. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110988. */
  110989. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110990. /**
  110991. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110992. * @param sphereCenter defines the bounding sphere center
  110993. * @param sphereRadius defines the bounding sphere radius
  110994. * @param selection defines the array to store current content if selection is positive
  110995. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110996. */
  110997. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110998. /**
  110999. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111000. * @param ray defines the ray to test with
  111001. * @param selection defines the array to store current content if selection is positive
  111002. */
  111003. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111004. /**
  111005. * Subdivide the content into child blocks (this block will then be empty)
  111006. */
  111007. createInnerBlocks(): void;
  111008. /**
  111009. * @hidden
  111010. */
  111011. 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;
  111012. }
  111013. }
  111014. declare module BABYLON {
  111015. /**
  111016. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111017. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111018. */
  111019. export class Octree<T> {
  111020. /** 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.) */
  111021. maxDepth: number;
  111022. /**
  111023. * Blocks within the octree containing objects
  111024. */
  111025. blocks: Array<OctreeBlock<T>>;
  111026. /**
  111027. * Content stored in the octree
  111028. */
  111029. dynamicContent: T[];
  111030. private _maxBlockCapacity;
  111031. private _selectionContent;
  111032. private _creationFunc;
  111033. /**
  111034. * Creates a octree
  111035. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111036. * @param creationFunc function to be used to instatiate the octree
  111037. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111038. * @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.)
  111039. */
  111040. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111041. /** 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.) */
  111042. maxDepth?: number);
  111043. /**
  111044. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111045. * @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);
  111046. * @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);
  111047. * @param entries meshes to be added to the octree blocks
  111048. */
  111049. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111050. /**
  111051. * Adds a mesh to the octree
  111052. * @param entry Mesh to add to the octree
  111053. */
  111054. addMesh(entry: T): void;
  111055. /**
  111056. * Remove an element from the octree
  111057. * @param entry defines the element to remove
  111058. */
  111059. removeMesh(entry: T): void;
  111060. /**
  111061. * Selects an array of meshes within the frustum
  111062. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111063. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111064. * @returns array of meshes within the frustum
  111065. */
  111066. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111067. /**
  111068. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111069. * @param sphereCenter defines the bounding sphere center
  111070. * @param sphereRadius defines the bounding sphere radius
  111071. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111072. * @returns an array of objects that intersect the sphere
  111073. */
  111074. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111075. /**
  111076. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111077. * @param ray defines the ray to test with
  111078. * @returns array of intersected objects
  111079. */
  111080. intersectsRay(ray: Ray): SmartArray<T>;
  111081. /**
  111082. * Adds a mesh into the octree block if it intersects the block
  111083. */
  111084. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111085. /**
  111086. * Adds a submesh into the octree block if it intersects the block
  111087. */
  111088. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111089. }
  111090. }
  111091. declare module BABYLON {
  111092. interface Scene {
  111093. /**
  111094. * @hidden
  111095. * Backing Filed
  111096. */
  111097. _selectionOctree: Octree<AbstractMesh>;
  111098. /**
  111099. * Gets the octree used to boost mesh selection (picking)
  111100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111101. */
  111102. selectionOctree: Octree<AbstractMesh>;
  111103. /**
  111104. * Creates or updates the octree used to boost selection (picking)
  111105. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111106. * @param maxCapacity defines the maximum capacity per leaf
  111107. * @param maxDepth defines the maximum depth of the octree
  111108. * @returns an octree of AbstractMesh
  111109. */
  111110. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111111. }
  111112. interface AbstractMesh {
  111113. /**
  111114. * @hidden
  111115. * Backing Field
  111116. */
  111117. _submeshesOctree: Octree<SubMesh>;
  111118. /**
  111119. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111120. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111121. * @param maxCapacity defines the maximum size of each block (64 by default)
  111122. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111123. * @returns the new octree
  111124. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111125. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111126. */
  111127. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111128. }
  111129. /**
  111130. * Defines the octree scene component responsible to manage any octrees
  111131. * in a given scene.
  111132. */
  111133. export class OctreeSceneComponent {
  111134. /**
  111135. * The component name help to identify the component in the list of scene components.
  111136. */
  111137. readonly name: string;
  111138. /**
  111139. * The scene the component belongs to.
  111140. */
  111141. scene: Scene;
  111142. /**
  111143. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111144. */
  111145. readonly checksIsEnabled: boolean;
  111146. /**
  111147. * Creates a new instance of the component for the given scene
  111148. * @param scene Defines the scene to register the component in
  111149. */
  111150. constructor(scene: Scene);
  111151. /**
  111152. * Registers the component in a given scene
  111153. */
  111154. register(): void;
  111155. /**
  111156. * Return the list of active meshes
  111157. * @returns the list of active meshes
  111158. */
  111159. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111160. /**
  111161. * Return the list of active sub meshes
  111162. * @param mesh The mesh to get the candidates sub meshes from
  111163. * @returns the list of active sub meshes
  111164. */
  111165. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111166. private _tempRay;
  111167. /**
  111168. * Return the list of sub meshes intersecting with a given local ray
  111169. * @param mesh defines the mesh to find the submesh for
  111170. * @param localRay defines the ray in local space
  111171. * @returns the list of intersecting sub meshes
  111172. */
  111173. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111174. /**
  111175. * Return the list of sub meshes colliding with a collider
  111176. * @param mesh defines the mesh to find the submesh for
  111177. * @param collider defines the collider to evaluate the collision against
  111178. * @returns the list of colliding sub meshes
  111179. */
  111180. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111181. /**
  111182. * Rebuilds the elements related to this component in case of
  111183. * context lost for instance.
  111184. */
  111185. rebuild(): void;
  111186. /**
  111187. * Disposes the component and the associated ressources.
  111188. */
  111189. dispose(): void;
  111190. }
  111191. }
  111192. declare module BABYLON {
  111193. /**
  111194. * Renders a layer on top of an existing scene
  111195. */
  111196. export class UtilityLayerRenderer implements IDisposable {
  111197. /** the original scene that will be rendered on top of */
  111198. originalScene: Scene;
  111199. private _pointerCaptures;
  111200. private _lastPointerEvents;
  111201. private static _DefaultUtilityLayer;
  111202. private static _DefaultKeepDepthUtilityLayer;
  111203. private _sharedGizmoLight;
  111204. private _renderCamera;
  111205. /**
  111206. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111207. * @returns the camera that is used when rendering the utility layer
  111208. */
  111209. getRenderCamera(): Nullable<Camera>;
  111210. /**
  111211. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111212. * @param cam the camera that should be used when rendering the utility layer
  111213. */
  111214. setRenderCamera(cam: Nullable<Camera>): void;
  111215. /**
  111216. * @hidden
  111217. * Light which used by gizmos to get light shading
  111218. */
  111219. _getSharedGizmoLight(): HemisphericLight;
  111220. /**
  111221. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111222. */
  111223. pickUtilitySceneFirst: boolean;
  111224. /**
  111225. * 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)
  111226. */
  111227. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111228. /**
  111229. * 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)
  111230. */
  111231. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111232. /**
  111233. * The scene that is rendered on top of the original scene
  111234. */
  111235. utilityLayerScene: Scene;
  111236. /**
  111237. * If the utility layer should automatically be rendered on top of existing scene
  111238. */
  111239. shouldRender: boolean;
  111240. /**
  111241. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111242. */
  111243. onlyCheckPointerDownEvents: boolean;
  111244. /**
  111245. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111246. */
  111247. processAllEvents: boolean;
  111248. /**
  111249. * Observable raised when the pointer move from the utility layer scene to the main scene
  111250. */
  111251. onPointerOutObservable: Observable<number>;
  111252. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111253. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111254. private _afterRenderObserver;
  111255. private _sceneDisposeObserver;
  111256. private _originalPointerObserver;
  111257. /**
  111258. * Instantiates a UtilityLayerRenderer
  111259. * @param originalScene the original scene that will be rendered on top of
  111260. * @param handleEvents boolean indicating if the utility layer should handle events
  111261. */
  111262. constructor(
  111263. /** the original scene that will be rendered on top of */
  111264. originalScene: Scene, handleEvents?: boolean);
  111265. private _notifyObservers;
  111266. /**
  111267. * Renders the utility layers scene on top of the original scene
  111268. */
  111269. render(): void;
  111270. /**
  111271. * Disposes of the renderer
  111272. */
  111273. dispose(): void;
  111274. private _updateCamera;
  111275. }
  111276. }
  111277. declare module BABYLON {
  111278. /**
  111279. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111280. */
  111281. export class Gizmo implements IDisposable {
  111282. /** The utility layer the gizmo will be added to */
  111283. gizmoLayer: UtilityLayerRenderer;
  111284. /**
  111285. * The root mesh of the gizmo
  111286. */
  111287. _rootMesh: Mesh;
  111288. private _attachedMesh;
  111289. /**
  111290. * Ratio for the scale of the gizmo (Default: 1)
  111291. */
  111292. scaleRatio: number;
  111293. /**
  111294. * If a custom mesh has been set (Default: false)
  111295. */
  111296. protected _customMeshSet: boolean;
  111297. /**
  111298. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111299. * * When set, interactions will be enabled
  111300. */
  111301. attachedMesh: Nullable<AbstractMesh>;
  111302. /**
  111303. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111304. * @param mesh The mesh to replace the default mesh of the gizmo
  111305. */
  111306. setCustomMesh(mesh: Mesh): void;
  111307. /**
  111308. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111309. */
  111310. updateGizmoRotationToMatchAttachedMesh: boolean;
  111311. /**
  111312. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111313. */
  111314. updateGizmoPositionToMatchAttachedMesh: boolean;
  111315. /**
  111316. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111317. */
  111318. updateScale: boolean;
  111319. protected _interactionsEnabled: boolean;
  111320. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111321. private _beforeRenderObserver;
  111322. private _tempVector;
  111323. /**
  111324. * Creates a gizmo
  111325. * @param gizmoLayer The utility layer the gizmo will be added to
  111326. */
  111327. constructor(
  111328. /** The utility layer the gizmo will be added to */
  111329. gizmoLayer?: UtilityLayerRenderer);
  111330. /**
  111331. * Updates the gizmo to match the attached mesh's position/rotation
  111332. */
  111333. protected _update(): void;
  111334. /**
  111335. * Disposes of the gizmo
  111336. */
  111337. dispose(): void;
  111338. }
  111339. }
  111340. declare module BABYLON {
  111341. /**
  111342. * Single plane drag gizmo
  111343. */
  111344. export class PlaneDragGizmo extends Gizmo {
  111345. /**
  111346. * Drag behavior responsible for the gizmos dragging interactions
  111347. */
  111348. dragBehavior: PointerDragBehavior;
  111349. private _pointerObserver;
  111350. /**
  111351. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111352. */
  111353. snapDistance: number;
  111354. /**
  111355. * Event that fires each time the gizmo snaps to a new location.
  111356. * * snapDistance is the the change in distance
  111357. */
  111358. onSnapObservable: Observable<{
  111359. snapDistance: number;
  111360. }>;
  111361. private _plane;
  111362. private _coloredMaterial;
  111363. private _hoverMaterial;
  111364. private _isEnabled;
  111365. private _parent;
  111366. /** @hidden */
  111367. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111368. /** @hidden */
  111369. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111370. /**
  111371. * Creates a PlaneDragGizmo
  111372. * @param gizmoLayer The utility layer the gizmo will be added to
  111373. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111374. * @param color The color of the gizmo
  111375. */
  111376. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111377. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111378. /**
  111379. * If the gizmo is enabled
  111380. */
  111381. isEnabled: boolean;
  111382. /**
  111383. * Disposes of the gizmo
  111384. */
  111385. dispose(): void;
  111386. }
  111387. }
  111388. declare module BABYLON {
  111389. /**
  111390. * Gizmo that enables dragging a mesh along 3 axis
  111391. */
  111392. export class PositionGizmo extends Gizmo {
  111393. /**
  111394. * Internal gizmo used for interactions on the x axis
  111395. */
  111396. xGizmo: AxisDragGizmo;
  111397. /**
  111398. * Internal gizmo used for interactions on the y axis
  111399. */
  111400. yGizmo: AxisDragGizmo;
  111401. /**
  111402. * Internal gizmo used for interactions on the z axis
  111403. */
  111404. zGizmo: AxisDragGizmo;
  111405. /**
  111406. * Internal gizmo used for interactions on the yz plane
  111407. */
  111408. xPlaneGizmo: PlaneDragGizmo;
  111409. /**
  111410. * Internal gizmo used for interactions on the xz plane
  111411. */
  111412. yPlaneGizmo: PlaneDragGizmo;
  111413. /**
  111414. * Internal gizmo used for interactions on the xy plane
  111415. */
  111416. zPlaneGizmo: PlaneDragGizmo;
  111417. /**
  111418. * private variables
  111419. */
  111420. private _meshAttached;
  111421. private _updateGizmoRotationToMatchAttachedMesh;
  111422. private _snapDistance;
  111423. private _scaleRatio;
  111424. /** Fires an event when any of it's sub gizmos are dragged */
  111425. onDragStartObservable: Observable<unknown>;
  111426. /** Fires an event when any of it's sub gizmos are released from dragging */
  111427. onDragEndObservable: Observable<unknown>;
  111428. /**
  111429. * If set to true, planar drag is enabled
  111430. */
  111431. private _planarGizmoEnabled;
  111432. attachedMesh: Nullable<AbstractMesh>;
  111433. /**
  111434. * Creates a PositionGizmo
  111435. * @param gizmoLayer The utility layer the gizmo will be added to
  111436. */
  111437. constructor(gizmoLayer?: UtilityLayerRenderer);
  111438. /**
  111439. * If the planar drag gizmo is enabled
  111440. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111441. */
  111442. planarGizmoEnabled: boolean;
  111443. updateGizmoRotationToMatchAttachedMesh: boolean;
  111444. /**
  111445. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111446. */
  111447. snapDistance: number;
  111448. /**
  111449. * Ratio for the scale of the gizmo (Default: 1)
  111450. */
  111451. scaleRatio: number;
  111452. /**
  111453. * Disposes of the gizmo
  111454. */
  111455. dispose(): void;
  111456. /**
  111457. * CustomMeshes are not supported by this gizmo
  111458. * @param mesh The mesh to replace the default mesh of the gizmo
  111459. */
  111460. setCustomMesh(mesh: Mesh): void;
  111461. }
  111462. }
  111463. declare module BABYLON {
  111464. /**
  111465. * Single axis drag gizmo
  111466. */
  111467. export class AxisDragGizmo extends Gizmo {
  111468. /**
  111469. * Drag behavior responsible for the gizmos dragging interactions
  111470. */
  111471. dragBehavior: PointerDragBehavior;
  111472. private _pointerObserver;
  111473. /**
  111474. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111475. */
  111476. snapDistance: number;
  111477. /**
  111478. * Event that fires each time the gizmo snaps to a new location.
  111479. * * snapDistance is the the change in distance
  111480. */
  111481. onSnapObservable: Observable<{
  111482. snapDistance: number;
  111483. }>;
  111484. private _isEnabled;
  111485. private _parent;
  111486. private _arrow;
  111487. private _coloredMaterial;
  111488. private _hoverMaterial;
  111489. /** @hidden */
  111490. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111491. /** @hidden */
  111492. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111493. /**
  111494. * Creates an AxisDragGizmo
  111495. * @param gizmoLayer The utility layer the gizmo will be added to
  111496. * @param dragAxis The axis which the gizmo will be able to drag on
  111497. * @param color The color of the gizmo
  111498. */
  111499. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111500. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111501. /**
  111502. * If the gizmo is enabled
  111503. */
  111504. isEnabled: boolean;
  111505. /**
  111506. * Disposes of the gizmo
  111507. */
  111508. dispose(): void;
  111509. }
  111510. }
  111511. declare module BABYLON.Debug {
  111512. /**
  111513. * The Axes viewer will show 3 axes in a specific point in space
  111514. */
  111515. export class AxesViewer {
  111516. private _xAxis;
  111517. private _yAxis;
  111518. private _zAxis;
  111519. private _scaleLinesFactor;
  111520. private _instanced;
  111521. /**
  111522. * Gets the hosting scene
  111523. */
  111524. scene: Scene;
  111525. /**
  111526. * Gets or sets a number used to scale line length
  111527. */
  111528. scaleLines: number;
  111529. /** Gets the node hierarchy used to render x-axis */
  111530. readonly xAxis: TransformNode;
  111531. /** Gets the node hierarchy used to render y-axis */
  111532. readonly yAxis: TransformNode;
  111533. /** Gets the node hierarchy used to render z-axis */
  111534. readonly zAxis: TransformNode;
  111535. /**
  111536. * Creates a new AxesViewer
  111537. * @param scene defines the hosting scene
  111538. * @param scaleLines defines a number used to scale line length (1 by default)
  111539. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111540. * @param xAxis defines the node hierarchy used to render the x-axis
  111541. * @param yAxis defines the node hierarchy used to render the y-axis
  111542. * @param zAxis defines the node hierarchy used to render the z-axis
  111543. */
  111544. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111545. /**
  111546. * Force the viewer to update
  111547. * @param position defines the position of the viewer
  111548. * @param xaxis defines the x axis of the viewer
  111549. * @param yaxis defines the y axis of the viewer
  111550. * @param zaxis defines the z axis of the viewer
  111551. */
  111552. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111553. /**
  111554. * Creates an instance of this axes viewer.
  111555. * @returns a new axes viewer with instanced meshes
  111556. */
  111557. createInstance(): AxesViewer;
  111558. /** Releases resources */
  111559. dispose(): void;
  111560. private static _SetRenderingGroupId;
  111561. }
  111562. }
  111563. declare module BABYLON.Debug {
  111564. /**
  111565. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111566. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111567. */
  111568. export class BoneAxesViewer extends AxesViewer {
  111569. /**
  111570. * Gets or sets the target mesh where to display the axes viewer
  111571. */
  111572. mesh: Nullable<Mesh>;
  111573. /**
  111574. * Gets or sets the target bone where to display the axes viewer
  111575. */
  111576. bone: Nullable<Bone>;
  111577. /** Gets current position */
  111578. pos: Vector3;
  111579. /** Gets direction of X axis */
  111580. xaxis: Vector3;
  111581. /** Gets direction of Y axis */
  111582. yaxis: Vector3;
  111583. /** Gets direction of Z axis */
  111584. zaxis: Vector3;
  111585. /**
  111586. * Creates a new BoneAxesViewer
  111587. * @param scene defines the hosting scene
  111588. * @param bone defines the target bone
  111589. * @param mesh defines the target mesh
  111590. * @param scaleLines defines a scaling factor for line length (1 by default)
  111591. */
  111592. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  111593. /**
  111594. * Force the viewer to update
  111595. */
  111596. update(): void;
  111597. /** Releases resources */
  111598. dispose(): void;
  111599. }
  111600. }
  111601. declare module BABYLON {
  111602. /**
  111603. * Interface used to define scene explorer extensibility option
  111604. */
  111605. export interface IExplorerExtensibilityOption {
  111606. /**
  111607. * Define the option label
  111608. */
  111609. label: string;
  111610. /**
  111611. * Defines the action to execute on click
  111612. */
  111613. action: (entity: any) => void;
  111614. }
  111615. /**
  111616. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111617. */
  111618. export interface IExplorerExtensibilityGroup {
  111619. /**
  111620. * Defines a predicate to test if a given type mut be extended
  111621. */
  111622. predicate: (entity: any) => boolean;
  111623. /**
  111624. * Gets the list of options added to a type
  111625. */
  111626. entries: IExplorerExtensibilityOption[];
  111627. }
  111628. /**
  111629. * Interface used to define the options to use to create the Inspector
  111630. */
  111631. export interface IInspectorOptions {
  111632. /**
  111633. * Display in overlay mode (default: false)
  111634. */
  111635. overlay?: boolean;
  111636. /**
  111637. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111638. */
  111639. globalRoot?: HTMLElement;
  111640. /**
  111641. * Display the Scene explorer
  111642. */
  111643. showExplorer?: boolean;
  111644. /**
  111645. * Display the property inspector
  111646. */
  111647. showInspector?: boolean;
  111648. /**
  111649. * Display in embed mode (both panes on the right)
  111650. */
  111651. embedMode?: boolean;
  111652. /**
  111653. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111654. */
  111655. handleResize?: boolean;
  111656. /**
  111657. * Allow the panes to popup (default: true)
  111658. */
  111659. enablePopup?: boolean;
  111660. /**
  111661. * Allow the panes to be closed by users (default: true)
  111662. */
  111663. enableClose?: boolean;
  111664. /**
  111665. * Optional list of extensibility entries
  111666. */
  111667. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111668. /**
  111669. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111670. */
  111671. inspectorURL?: string;
  111672. }
  111673. interface Scene {
  111674. /**
  111675. * @hidden
  111676. * Backing field
  111677. */
  111678. _debugLayer: DebugLayer;
  111679. /**
  111680. * Gets the debug layer (aka Inspector) associated with the scene
  111681. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111682. */
  111683. debugLayer: DebugLayer;
  111684. }
  111685. /**
  111686. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111687. * what is happening in your scene
  111688. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111689. */
  111690. export class DebugLayer {
  111691. /**
  111692. * Define the url to get the inspector script from.
  111693. * By default it uses the babylonjs CDN.
  111694. * @ignoreNaming
  111695. */
  111696. static InspectorURL: string;
  111697. private _scene;
  111698. private BJSINSPECTOR;
  111699. private _onPropertyChangedObservable?;
  111700. /**
  111701. * Observable triggered when a property is changed through the inspector.
  111702. */
  111703. readonly onPropertyChangedObservable: any;
  111704. /**
  111705. * Instantiates a new debug layer.
  111706. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111707. * what is happening in your scene
  111708. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111709. * @param scene Defines the scene to inspect
  111710. */
  111711. constructor(scene: Scene);
  111712. /** Creates the inspector window. */
  111713. private _createInspector;
  111714. /**
  111715. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  111716. * @param entity defines the entity to select
  111717. * @param lineContainerTitle defines the specific block to highlight
  111718. */
  111719. select(entity: any, lineContainerTitle?: string): void;
  111720. /** Get the inspector from bundle or global */
  111721. private _getGlobalInspector;
  111722. /**
  111723. * Get if the inspector is visible or not.
  111724. * @returns true if visible otherwise, false
  111725. */
  111726. isVisible(): boolean;
  111727. /**
  111728. * Hide the inspector and close its window.
  111729. */
  111730. hide(): void;
  111731. /**
  111732. * Launch the debugLayer.
  111733. * @param config Define the configuration of the inspector
  111734. * @return a promise fulfilled when the debug layer is visible
  111735. */
  111736. show(config?: IInspectorOptions): Promise<DebugLayer>;
  111737. }
  111738. }
  111739. declare module BABYLON {
  111740. /**
  111741. * Class containing static functions to help procedurally build meshes
  111742. */
  111743. export class BoxBuilder {
  111744. /**
  111745. * Creates a box mesh
  111746. * * The parameter `size` sets the size (float) of each box side (default 1)
  111747. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  111748. * * 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)
  111749. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  111750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111753. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  111754. * @param name defines the name of the mesh
  111755. * @param options defines the options used to create the mesh
  111756. * @param scene defines the hosting scene
  111757. * @returns the box mesh
  111758. */
  111759. static CreateBox(name: string, options: {
  111760. size?: number;
  111761. width?: number;
  111762. height?: number;
  111763. depth?: number;
  111764. faceUV?: Vector4[];
  111765. faceColors?: Color4[];
  111766. sideOrientation?: number;
  111767. frontUVs?: Vector4;
  111768. backUVs?: Vector4;
  111769. wrap?: boolean;
  111770. topBaseAt?: number;
  111771. bottomBaseAt?: number;
  111772. updatable?: boolean;
  111773. }, scene?: Nullable<Scene>): Mesh;
  111774. }
  111775. }
  111776. declare module BABYLON {
  111777. /**
  111778. * Class containing static functions to help procedurally build meshes
  111779. */
  111780. export class SphereBuilder {
  111781. /**
  111782. * Creates a sphere mesh
  111783. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  111784. * * 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`)
  111785. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  111786. * * 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
  111787. * * 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)
  111788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111791. * @param name defines the name of the mesh
  111792. * @param options defines the options used to create the mesh
  111793. * @param scene defines the hosting scene
  111794. * @returns the sphere mesh
  111795. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  111796. */
  111797. static CreateSphere(name: string, options: {
  111798. segments?: number;
  111799. diameter?: number;
  111800. diameterX?: number;
  111801. diameterY?: number;
  111802. diameterZ?: number;
  111803. arc?: number;
  111804. slice?: number;
  111805. sideOrientation?: number;
  111806. frontUVs?: Vector4;
  111807. backUVs?: Vector4;
  111808. updatable?: boolean;
  111809. }, scene?: Nullable<Scene>): Mesh;
  111810. }
  111811. }
  111812. declare module BABYLON.Debug {
  111813. /**
  111814. * Used to show the physics impostor around the specific mesh
  111815. */
  111816. export class PhysicsViewer {
  111817. /** @hidden */
  111818. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  111819. /** @hidden */
  111820. protected _meshes: Array<Nullable<AbstractMesh>>;
  111821. /** @hidden */
  111822. protected _scene: Nullable<Scene>;
  111823. /** @hidden */
  111824. protected _numMeshes: number;
  111825. /** @hidden */
  111826. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  111827. private _renderFunction;
  111828. private _utilityLayer;
  111829. private _debugBoxMesh;
  111830. private _debugSphereMesh;
  111831. private _debugCylinderMesh;
  111832. private _debugMaterial;
  111833. private _debugMeshMeshes;
  111834. /**
  111835. * Creates a new PhysicsViewer
  111836. * @param scene defines the hosting scene
  111837. */
  111838. constructor(scene: Scene);
  111839. /** @hidden */
  111840. protected _updateDebugMeshes(): void;
  111841. /**
  111842. * Renders a specified physic impostor
  111843. * @param impostor defines the impostor to render
  111844. * @param targetMesh defines the mesh represented by the impostor
  111845. * @returns the new debug mesh used to render the impostor
  111846. */
  111847. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  111848. /**
  111849. * Hides a specified physic impostor
  111850. * @param impostor defines the impostor to hide
  111851. */
  111852. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  111853. private _getDebugMaterial;
  111854. private _getDebugBoxMesh;
  111855. private _getDebugSphereMesh;
  111856. private _getDebugCylinderMesh;
  111857. private _getDebugMeshMesh;
  111858. private _getDebugMesh;
  111859. /** Releases all resources */
  111860. dispose(): void;
  111861. }
  111862. }
  111863. declare module BABYLON {
  111864. /**
  111865. * Class containing static functions to help procedurally build meshes
  111866. */
  111867. export class LinesBuilder {
  111868. /**
  111869. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  111870. * * 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
  111871. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  111872. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  111873. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  111874. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  111875. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  111876. * * 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
  111877. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  111878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  111880. * @param name defines the name of the new line system
  111881. * @param options defines the options used to create the line system
  111882. * @param scene defines the hosting scene
  111883. * @returns a new line system mesh
  111884. */
  111885. static CreateLineSystem(name: string, options: {
  111886. lines: Vector3[][];
  111887. updatable?: boolean;
  111888. instance?: Nullable<LinesMesh>;
  111889. colors?: Nullable<Color4[][]>;
  111890. useVertexAlpha?: boolean;
  111891. }, scene: Nullable<Scene>): LinesMesh;
  111892. /**
  111893. * Creates a line mesh
  111894. * 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
  111895. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111896. * * The parameter `points` is an array successive Vector3
  111897. * * 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
  111898. * * The optional parameter `colors` is an array of successive Color4, one per line point
  111899. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  111900. * * When updating an instance, remember that only point positions can change, not the number of points
  111901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  111903. * @param name defines the name of the new line system
  111904. * @param options defines the options used to create the line system
  111905. * @param scene defines the hosting scene
  111906. * @returns a new line mesh
  111907. */
  111908. static CreateLines(name: string, options: {
  111909. points: Vector3[];
  111910. updatable?: boolean;
  111911. instance?: Nullable<LinesMesh>;
  111912. colors?: Color4[];
  111913. useVertexAlpha?: boolean;
  111914. }, scene?: Nullable<Scene>): LinesMesh;
  111915. /**
  111916. * Creates a dashed line mesh
  111917. * * 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
  111918. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111919. * * The parameter `points` is an array successive Vector3
  111920. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  111921. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  111922. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  111923. * * 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
  111924. * * When updating an instance, remember that only point positions can change, not the number of points
  111925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111926. * @param name defines the name of the mesh
  111927. * @param options defines the options used to create the mesh
  111928. * @param scene defines the hosting scene
  111929. * @returns the dashed line mesh
  111930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111931. */
  111932. static CreateDashedLines(name: string, options: {
  111933. points: Vector3[];
  111934. dashSize?: number;
  111935. gapSize?: number;
  111936. dashNb?: number;
  111937. updatable?: boolean;
  111938. instance?: LinesMesh;
  111939. }, scene?: Nullable<Scene>): LinesMesh;
  111940. }
  111941. }
  111942. declare module BABYLON {
  111943. /**
  111944. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111945. * in order to better appreciate the issue one might have.
  111946. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111947. */
  111948. export class RayHelper {
  111949. /**
  111950. * Defines the ray we are currently tryin to visualize.
  111951. */
  111952. ray: Nullable<Ray>;
  111953. private _renderPoints;
  111954. private _renderLine;
  111955. private _renderFunction;
  111956. private _scene;
  111957. private _updateToMeshFunction;
  111958. private _attachedToMesh;
  111959. private _meshSpaceDirection;
  111960. private _meshSpaceOrigin;
  111961. /**
  111962. * Helper function to create a colored helper in a scene in one line.
  111963. * @param ray Defines the ray we are currently tryin to visualize
  111964. * @param scene Defines the scene the ray is used in
  111965. * @param color Defines the color we want to see the ray in
  111966. * @returns The newly created ray helper.
  111967. */
  111968. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111969. /**
  111970. * Instantiate a new ray helper.
  111971. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111972. * in order to better appreciate the issue one might have.
  111973. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111974. * @param ray Defines the ray we are currently tryin to visualize
  111975. */
  111976. constructor(ray: Ray);
  111977. /**
  111978. * Shows the ray we are willing to debug.
  111979. * @param scene Defines the scene the ray needs to be rendered in
  111980. * @param color Defines the color the ray needs to be rendered in
  111981. */
  111982. show(scene: Scene, color?: Color3): void;
  111983. /**
  111984. * Hides the ray we are debugging.
  111985. */
  111986. hide(): void;
  111987. private _render;
  111988. /**
  111989. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111990. * @param mesh Defines the mesh we want the helper attached to
  111991. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111992. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111993. * @param length Defines the length of the ray
  111994. */
  111995. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111996. /**
  111997. * Detach the ray helper from the mesh it has previously been attached to.
  111998. */
  111999. detachFromMesh(): void;
  112000. private _updateToMesh;
  112001. /**
  112002. * Dispose the helper and release its associated resources.
  112003. */
  112004. dispose(): void;
  112005. }
  112006. }
  112007. declare module BABYLON.Debug {
  112008. /**
  112009. * Class used to render a debug view of a given skeleton
  112010. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112011. */
  112012. export class SkeletonViewer {
  112013. /** defines the skeleton to render */
  112014. skeleton: Skeleton;
  112015. /** defines the mesh attached to the skeleton */
  112016. mesh: AbstractMesh;
  112017. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112018. autoUpdateBonesMatrices: boolean;
  112019. /** defines the rendering group id to use with the viewer */
  112020. renderingGroupId: number;
  112021. /** Gets or sets the color used to render the skeleton */
  112022. color: Color3;
  112023. private _scene;
  112024. private _debugLines;
  112025. private _debugMesh;
  112026. private _isEnabled;
  112027. private _renderFunction;
  112028. private _utilityLayer;
  112029. /**
  112030. * Returns the mesh used to render the bones
  112031. */
  112032. readonly debugMesh: Nullable<LinesMesh>;
  112033. /**
  112034. * Creates a new SkeletonViewer
  112035. * @param skeleton defines the skeleton to render
  112036. * @param mesh defines the mesh attached to the skeleton
  112037. * @param scene defines the hosting scene
  112038. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112039. * @param renderingGroupId defines the rendering group id to use with the viewer
  112040. */
  112041. constructor(
  112042. /** defines the skeleton to render */
  112043. skeleton: Skeleton,
  112044. /** defines the mesh attached to the skeleton */
  112045. mesh: AbstractMesh, scene: Scene,
  112046. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112047. autoUpdateBonesMatrices?: boolean,
  112048. /** defines the rendering group id to use with the viewer */
  112049. renderingGroupId?: number);
  112050. /** Gets or sets a boolean indicating if the viewer is enabled */
  112051. isEnabled: boolean;
  112052. private _getBonePosition;
  112053. private _getLinesForBonesWithLength;
  112054. private _getLinesForBonesNoLength;
  112055. /** Update the viewer to sync with current skeleton state */
  112056. update(): void;
  112057. /** Release associated resources */
  112058. dispose(): void;
  112059. }
  112060. }
  112061. declare module BABYLON {
  112062. /**
  112063. * Options to create the null engine
  112064. */
  112065. export class NullEngineOptions {
  112066. /**
  112067. * Render width (Default: 512)
  112068. */
  112069. renderWidth: number;
  112070. /**
  112071. * Render height (Default: 256)
  112072. */
  112073. renderHeight: number;
  112074. /**
  112075. * Texture size (Default: 512)
  112076. */
  112077. textureSize: number;
  112078. /**
  112079. * If delta time between frames should be constant
  112080. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112081. */
  112082. deterministicLockstep: boolean;
  112083. /**
  112084. * Maximum about of steps between frames (Default: 4)
  112085. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112086. */
  112087. lockstepMaxSteps: number;
  112088. }
  112089. /**
  112090. * The null engine class provides support for headless version of babylon.js.
  112091. * This can be used in server side scenario or for testing purposes
  112092. */
  112093. export class NullEngine extends Engine {
  112094. private _options;
  112095. /**
  112096. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112097. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112098. * @returns true if engine is in deterministic lock step mode
  112099. */
  112100. isDeterministicLockStep(): boolean;
  112101. /**
  112102. * Gets the max steps when engine is running in deterministic lock step
  112103. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112104. * @returns the max steps
  112105. */
  112106. getLockstepMaxSteps(): number;
  112107. /**
  112108. * Gets the current hardware scaling level.
  112109. * By default the hardware scaling level is computed from the window device ratio.
  112110. * 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.
  112111. * @returns a number indicating the current hardware scaling level
  112112. */
  112113. getHardwareScalingLevel(): number;
  112114. constructor(options?: NullEngineOptions);
  112115. /**
  112116. * Creates a vertex buffer
  112117. * @param vertices the data for the vertex buffer
  112118. * @returns the new WebGL static buffer
  112119. */
  112120. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112121. /**
  112122. * Creates a new index buffer
  112123. * @param indices defines the content of the index buffer
  112124. * @param updatable defines if the index buffer must be updatable
  112125. * @returns a new webGL buffer
  112126. */
  112127. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112128. /**
  112129. * Clear the current render buffer or the current render target (if any is set up)
  112130. * @param color defines the color to use
  112131. * @param backBuffer defines if the back buffer must be cleared
  112132. * @param depth defines if the depth buffer must be cleared
  112133. * @param stencil defines if the stencil buffer must be cleared
  112134. */
  112135. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112136. /**
  112137. * Gets the current render width
  112138. * @param useScreen defines if screen size must be used (or the current render target if any)
  112139. * @returns a number defining the current render width
  112140. */
  112141. getRenderWidth(useScreen?: boolean): number;
  112142. /**
  112143. * Gets the current render height
  112144. * @param useScreen defines if screen size must be used (or the current render target if any)
  112145. * @returns a number defining the current render height
  112146. */
  112147. getRenderHeight(useScreen?: boolean): number;
  112148. /**
  112149. * Set the WebGL's viewport
  112150. * @param viewport defines the viewport element to be used
  112151. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112152. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112153. */
  112154. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112155. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112156. /**
  112157. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112158. * @param pipelineContext defines the pipeline context to use
  112159. * @param uniformsNames defines the list of uniform names
  112160. * @returns an array of webGL uniform locations
  112161. */
  112162. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112163. /**
  112164. * Gets the lsit of active attributes for a given webGL program
  112165. * @param pipelineContext defines the pipeline context to use
  112166. * @param attributesNames defines the list of attribute names to get
  112167. * @returns an array of indices indicating the offset of each attribute
  112168. */
  112169. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112170. /**
  112171. * Binds an effect to the webGL context
  112172. * @param effect defines the effect to bind
  112173. */
  112174. bindSamplers(effect: Effect): void;
  112175. /**
  112176. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112177. * @param effect defines the effect to activate
  112178. */
  112179. enableEffect(effect: Effect): void;
  112180. /**
  112181. * Set various states to the webGL context
  112182. * @param culling defines backface culling state
  112183. * @param zOffset defines the value to apply to zOffset (0 by default)
  112184. * @param force defines if states must be applied even if cache is up to date
  112185. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112186. */
  112187. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112188. /**
  112189. * Set the value of an uniform to an array of int32
  112190. * @param uniform defines the webGL uniform location where to store the value
  112191. * @param array defines the array of int32 to store
  112192. */
  112193. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112194. /**
  112195. * Set the value of an uniform to an array of int32 (stored as vec2)
  112196. * @param uniform defines the webGL uniform location where to store the value
  112197. * @param array defines the array of int32 to store
  112198. */
  112199. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112200. /**
  112201. * Set the value of an uniform to an array of int32 (stored as vec3)
  112202. * @param uniform defines the webGL uniform location where to store the value
  112203. * @param array defines the array of int32 to store
  112204. */
  112205. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112206. /**
  112207. * Set the value of an uniform to an array of int32 (stored as vec4)
  112208. * @param uniform defines the webGL uniform location where to store the value
  112209. * @param array defines the array of int32 to store
  112210. */
  112211. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112212. /**
  112213. * Set the value of an uniform to an array of float32
  112214. * @param uniform defines the webGL uniform location where to store the value
  112215. * @param array defines the array of float32 to store
  112216. */
  112217. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112218. /**
  112219. * Set the value of an uniform to an array of float32 (stored as vec2)
  112220. * @param uniform defines the webGL uniform location where to store the value
  112221. * @param array defines the array of float32 to store
  112222. */
  112223. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112224. /**
  112225. * Set the value of an uniform to an array of float32 (stored as vec3)
  112226. * @param uniform defines the webGL uniform location where to store the value
  112227. * @param array defines the array of float32 to store
  112228. */
  112229. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112230. /**
  112231. * Set the value of an uniform to an array of float32 (stored as vec4)
  112232. * @param uniform defines the webGL uniform location where to store the value
  112233. * @param array defines the array of float32 to store
  112234. */
  112235. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112236. /**
  112237. * Set the value of an uniform to an array of number
  112238. * @param uniform defines the webGL uniform location where to store the value
  112239. * @param array defines the array of number to store
  112240. */
  112241. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112242. /**
  112243. * Set the value of an uniform to an array of number (stored as vec2)
  112244. * @param uniform defines the webGL uniform location where to store the value
  112245. * @param array defines the array of number to store
  112246. */
  112247. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112248. /**
  112249. * Set the value of an uniform to an array of number (stored as vec3)
  112250. * @param uniform defines the webGL uniform location where to store the value
  112251. * @param array defines the array of number to store
  112252. */
  112253. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112254. /**
  112255. * Set the value of an uniform to an array of number (stored as vec4)
  112256. * @param uniform defines the webGL uniform location where to store the value
  112257. * @param array defines the array of number to store
  112258. */
  112259. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112260. /**
  112261. * Set the value of an uniform to an array of float32 (stored as matrices)
  112262. * @param uniform defines the webGL uniform location where to store the value
  112263. * @param matrices defines the array of float32 to store
  112264. */
  112265. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112266. /**
  112267. * Set the value of an uniform to a matrix (3x3)
  112268. * @param uniform defines the webGL uniform location where to store the value
  112269. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112270. */
  112271. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112272. /**
  112273. * Set the value of an uniform to a matrix (2x2)
  112274. * @param uniform defines the webGL uniform location where to store the value
  112275. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112276. */
  112277. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112278. /**
  112279. * Set the value of an uniform to a number (float)
  112280. * @param uniform defines the webGL uniform location where to store the value
  112281. * @param value defines the float number to store
  112282. */
  112283. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112284. /**
  112285. * Set the value of an uniform to a vec2
  112286. * @param uniform defines the webGL uniform location where to store the value
  112287. * @param x defines the 1st component of the value
  112288. * @param y defines the 2nd component of the value
  112289. */
  112290. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112291. /**
  112292. * Set the value of an uniform to a vec3
  112293. * @param uniform defines the webGL uniform location where to store the value
  112294. * @param x defines the 1st component of the value
  112295. * @param y defines the 2nd component of the value
  112296. * @param z defines the 3rd component of the value
  112297. */
  112298. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112299. /**
  112300. * Set the value of an uniform to a boolean
  112301. * @param uniform defines the webGL uniform location where to store the value
  112302. * @param bool defines the boolean to store
  112303. */
  112304. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112305. /**
  112306. * Set the value of an uniform to a vec4
  112307. * @param uniform defines the webGL uniform location where to store the value
  112308. * @param x defines the 1st component of the value
  112309. * @param y defines the 2nd component of the value
  112310. * @param z defines the 3rd component of the value
  112311. * @param w defines the 4th component of the value
  112312. */
  112313. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112314. /**
  112315. * Sets the current alpha mode
  112316. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112317. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112318. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112319. */
  112320. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112321. /**
  112322. * Bind webGl buffers directly to the webGL context
  112323. * @param vertexBuffers defines the vertex buffer to bind
  112324. * @param indexBuffer defines the index buffer to bind
  112325. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112326. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112327. * @param effect defines the effect associated with the vertex buffer
  112328. */
  112329. bindBuffers(vertexBuffers: {
  112330. [key: string]: VertexBuffer;
  112331. }, indexBuffer: DataBuffer, effect: Effect): void;
  112332. /**
  112333. * Force the entire cache to be cleared
  112334. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112335. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112336. */
  112337. wipeCaches(bruteForce?: boolean): void;
  112338. /**
  112339. * Send a draw order
  112340. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112341. * @param indexStart defines the starting index
  112342. * @param indexCount defines the number of index to draw
  112343. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112344. */
  112345. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112346. /**
  112347. * Draw a list of indexed primitives
  112348. * @param fillMode defines the primitive to use
  112349. * @param indexStart defines the starting index
  112350. * @param indexCount defines the number of index to draw
  112351. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112352. */
  112353. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112354. /**
  112355. * Draw a list of unindexed primitives
  112356. * @param fillMode defines the primitive to use
  112357. * @param verticesStart defines the index of first vertex to draw
  112358. * @param verticesCount defines the count of vertices to draw
  112359. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112360. */
  112361. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112362. /** @hidden */
  112363. _createTexture(): WebGLTexture;
  112364. /** @hidden */
  112365. _releaseTexture(texture: InternalTexture): void;
  112366. /**
  112367. * Usually called from Texture.ts.
  112368. * Passed information to create a WebGLTexture
  112369. * @param urlArg defines a value which contains one of the following:
  112370. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112371. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112372. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112373. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112374. * @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)
  112375. * @param scene needed for loading to the correct scene
  112376. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112377. * @param onLoad optional callback to be called upon successful completion
  112378. * @param onError optional callback to be called upon failure
  112379. * @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
  112380. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112381. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112382. * @param forcedExtension defines the extension to use to pick the right loader
  112383. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112384. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112385. */
  112386. 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;
  112387. /**
  112388. * Creates a new render target texture
  112389. * @param size defines the size of the texture
  112390. * @param options defines the options used to create the texture
  112391. * @returns a new render target texture stored in an InternalTexture
  112392. */
  112393. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112394. /**
  112395. * Update the sampling mode of a given texture
  112396. * @param samplingMode defines the required sampling mode
  112397. * @param texture defines the texture to update
  112398. */
  112399. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112400. /**
  112401. * Binds the frame buffer to the specified texture.
  112402. * @param texture The texture to render to or null for the default canvas
  112403. * @param faceIndex The face of the texture to render to in case of cube texture
  112404. * @param requiredWidth The width of the target to render to
  112405. * @param requiredHeight The height of the target to render to
  112406. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112407. * @param depthStencilTexture The depth stencil texture to use to render
  112408. * @param lodLevel defines le lod level to bind to the frame buffer
  112409. */
  112410. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112411. /**
  112412. * Unbind the current render target texture from the webGL context
  112413. * @param texture defines the render target texture to unbind
  112414. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112415. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112416. */
  112417. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112418. /**
  112419. * Creates a dynamic vertex buffer
  112420. * @param vertices the data for the dynamic vertex buffer
  112421. * @returns the new WebGL dynamic buffer
  112422. */
  112423. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112424. /**
  112425. * Update the content of a dynamic texture
  112426. * @param texture defines the texture to update
  112427. * @param canvas defines the canvas containing the source
  112428. * @param invertY defines if data must be stored with Y axis inverted
  112429. * @param premulAlpha defines if alpha is stored as premultiplied
  112430. * @param format defines the format of the data
  112431. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112432. */
  112433. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112434. /**
  112435. * Gets a boolean indicating if all created effects are ready
  112436. * @returns true if all effects are ready
  112437. */
  112438. areAllEffectsReady(): boolean;
  112439. /**
  112440. * @hidden
  112441. * Get the current error code of the webGL context
  112442. * @returns the error code
  112443. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112444. */
  112445. getError(): number;
  112446. /** @hidden */
  112447. _getUnpackAlignement(): number;
  112448. /** @hidden */
  112449. _unpackFlipY(value: boolean): void;
  112450. /**
  112451. * Update a dynamic index buffer
  112452. * @param indexBuffer defines the target index buffer
  112453. * @param indices defines the data to update
  112454. * @param offset defines the offset in the target index buffer where update should start
  112455. */
  112456. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112457. /**
  112458. * Updates a dynamic vertex buffer.
  112459. * @param vertexBuffer the vertex buffer to update
  112460. * @param vertices the data used to update the vertex buffer
  112461. * @param byteOffset the byte offset of the data (optional)
  112462. * @param byteLength the byte length of the data (optional)
  112463. */
  112464. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112465. /** @hidden */
  112466. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112467. /** @hidden */
  112468. _bindTexture(channel: number, texture: InternalTexture): void;
  112469. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112470. /**
  112471. * 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
  112472. */
  112473. releaseEffects(): void;
  112474. displayLoadingUI(): void;
  112475. hideLoadingUI(): void;
  112476. /** @hidden */
  112477. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112478. /** @hidden */
  112479. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112480. /** @hidden */
  112481. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112482. /** @hidden */
  112483. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112484. }
  112485. }
  112486. declare module BABYLON {
  112487. /** @hidden */
  112488. export class _OcclusionDataStorage {
  112489. /** @hidden */
  112490. occlusionInternalRetryCounter: number;
  112491. /** @hidden */
  112492. isOcclusionQueryInProgress: boolean;
  112493. /** @hidden */
  112494. isOccluded: boolean;
  112495. /** @hidden */
  112496. occlusionRetryCount: number;
  112497. /** @hidden */
  112498. occlusionType: number;
  112499. /** @hidden */
  112500. occlusionQueryAlgorithmType: number;
  112501. }
  112502. interface Engine {
  112503. /**
  112504. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112505. * @return the new query
  112506. */
  112507. createQuery(): WebGLQuery;
  112508. /**
  112509. * Delete and release a webGL query
  112510. * @param query defines the query to delete
  112511. * @return the current engine
  112512. */
  112513. deleteQuery(query: WebGLQuery): Engine;
  112514. /**
  112515. * Check if a given query has resolved and got its value
  112516. * @param query defines the query to check
  112517. * @returns true if the query got its value
  112518. */
  112519. isQueryResultAvailable(query: WebGLQuery): boolean;
  112520. /**
  112521. * Gets the value of a given query
  112522. * @param query defines the query to check
  112523. * @returns the value of the query
  112524. */
  112525. getQueryResult(query: WebGLQuery): number;
  112526. /**
  112527. * Initiates an occlusion query
  112528. * @param algorithmType defines the algorithm to use
  112529. * @param query defines the query to use
  112530. * @returns the current engine
  112531. * @see http://doc.babylonjs.com/features/occlusionquery
  112532. */
  112533. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112534. /**
  112535. * Ends an occlusion query
  112536. * @see http://doc.babylonjs.com/features/occlusionquery
  112537. * @param algorithmType defines the algorithm to use
  112538. * @returns the current engine
  112539. */
  112540. endOcclusionQuery(algorithmType: number): Engine;
  112541. /**
  112542. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112543. * Please note that only one query can be issued at a time
  112544. * @returns a time token used to track the time span
  112545. */
  112546. startTimeQuery(): Nullable<_TimeToken>;
  112547. /**
  112548. * Ends a time query
  112549. * @param token defines the token used to measure the time span
  112550. * @returns the time spent (in ns)
  112551. */
  112552. endTimeQuery(token: _TimeToken): int;
  112553. /** @hidden */
  112554. _currentNonTimestampToken: Nullable<_TimeToken>;
  112555. /** @hidden */
  112556. _createTimeQuery(): WebGLQuery;
  112557. /** @hidden */
  112558. _deleteTimeQuery(query: WebGLQuery): void;
  112559. /** @hidden */
  112560. _getGlAlgorithmType(algorithmType: number): number;
  112561. /** @hidden */
  112562. _getTimeQueryResult(query: WebGLQuery): any;
  112563. /** @hidden */
  112564. _getTimeQueryAvailability(query: WebGLQuery): any;
  112565. }
  112566. interface AbstractMesh {
  112567. /**
  112568. * Backing filed
  112569. * @hidden
  112570. */
  112571. __occlusionDataStorage: _OcclusionDataStorage;
  112572. /**
  112573. * Access property
  112574. * @hidden
  112575. */
  112576. _occlusionDataStorage: _OcclusionDataStorage;
  112577. /**
  112578. * 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.
  112579. * The default value is -1 which means don't break the query and wait till the result
  112580. * @see http://doc.babylonjs.com/features/occlusionquery
  112581. */
  112582. occlusionRetryCount: number;
  112583. /**
  112584. * 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:
  112585. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  112586. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  112587. * * 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.
  112588. * @see http://doc.babylonjs.com/features/occlusionquery
  112589. */
  112590. occlusionType: number;
  112591. /**
  112592. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  112593. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  112594. * * 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.
  112595. * @see http://doc.babylonjs.com/features/occlusionquery
  112596. */
  112597. occlusionQueryAlgorithmType: number;
  112598. /**
  112599. * 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
  112600. * @see http://doc.babylonjs.com/features/occlusionquery
  112601. */
  112602. isOccluded: boolean;
  112603. /**
  112604. * Flag to check the progress status of the query
  112605. * @see http://doc.babylonjs.com/features/occlusionquery
  112606. */
  112607. isOcclusionQueryInProgress: boolean;
  112608. }
  112609. }
  112610. declare module BABYLON {
  112611. /** @hidden */
  112612. export var _forceTransformFeedbackToBundle: boolean;
  112613. interface Engine {
  112614. /**
  112615. * Creates a webGL transform feedback object
  112616. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112617. * @returns the webGL transform feedback object
  112618. */
  112619. createTransformFeedback(): WebGLTransformFeedback;
  112620. /**
  112621. * Delete a webGL transform feedback object
  112622. * @param value defines the webGL transform feedback object to delete
  112623. */
  112624. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112625. /**
  112626. * Bind a webGL transform feedback object to the webgl context
  112627. * @param value defines the webGL transform feedback object to bind
  112628. */
  112629. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112630. /**
  112631. * Begins a transform feedback operation
  112632. * @param usePoints defines if points or triangles must be used
  112633. */
  112634. beginTransformFeedback(usePoints: boolean): void;
  112635. /**
  112636. * Ends a transform feedback operation
  112637. */
  112638. endTransformFeedback(): void;
  112639. /**
  112640. * Specify the varyings to use with transform feedback
  112641. * @param program defines the associated webGL program
  112642. * @param value defines the list of strings representing the varying names
  112643. */
  112644. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112645. /**
  112646. * Bind a webGL buffer for a transform feedback operation
  112647. * @param value defines the webGL buffer to bind
  112648. */
  112649. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112650. }
  112651. }
  112652. declare module BABYLON {
  112653. /**
  112654. * Creation options of the multi render target texture.
  112655. */
  112656. export interface IMultiRenderTargetOptions {
  112657. /**
  112658. * Define if the texture needs to create mip maps after render.
  112659. */
  112660. generateMipMaps?: boolean;
  112661. /**
  112662. * Define the types of all the draw buffers we want to create
  112663. */
  112664. types?: number[];
  112665. /**
  112666. * Define the sampling modes of all the draw buffers we want to create
  112667. */
  112668. samplingModes?: number[];
  112669. /**
  112670. * Define if a depth buffer is required
  112671. */
  112672. generateDepthBuffer?: boolean;
  112673. /**
  112674. * Define if a stencil buffer is required
  112675. */
  112676. generateStencilBuffer?: boolean;
  112677. /**
  112678. * Define if a depth texture is required instead of a depth buffer
  112679. */
  112680. generateDepthTexture?: boolean;
  112681. /**
  112682. * Define the number of desired draw buffers
  112683. */
  112684. textureCount?: number;
  112685. /**
  112686. * Define if aspect ratio should be adapted to the texture or stay the scene one
  112687. */
  112688. doNotChangeAspectRatio?: boolean;
  112689. /**
  112690. * Define the default type of the buffers we are creating
  112691. */
  112692. defaultType?: number;
  112693. }
  112694. /**
  112695. * A multi render target, like a render target provides the ability to render to a texture.
  112696. * Unlike the render target, it can render to several draw buffers in one draw.
  112697. * This is specially interesting in deferred rendering or for any effects requiring more than
  112698. * just one color from a single pass.
  112699. */
  112700. export class MultiRenderTarget extends RenderTargetTexture {
  112701. private _internalTextures;
  112702. private _textures;
  112703. private _multiRenderTargetOptions;
  112704. /**
  112705. * Get if draw buffers are currently supported by the used hardware and browser.
  112706. */
  112707. readonly isSupported: boolean;
  112708. /**
  112709. * Get the list of textures generated by the multi render target.
  112710. */
  112711. readonly textures: Texture[];
  112712. /**
  112713. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  112714. */
  112715. readonly depthTexture: Texture;
  112716. /**
  112717. * Set the wrapping mode on U of all the textures we are rendering to.
  112718. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112719. */
  112720. wrapU: number;
  112721. /**
  112722. * Set the wrapping mode on V of all the textures we are rendering to.
  112723. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112724. */
  112725. wrapV: number;
  112726. /**
  112727. * Instantiate a new multi render target texture.
  112728. * A multi render target, like a render target provides the ability to render to a texture.
  112729. * Unlike the render target, it can render to several draw buffers in one draw.
  112730. * This is specially interesting in deferred rendering or for any effects requiring more than
  112731. * just one color from a single pass.
  112732. * @param name Define the name of the texture
  112733. * @param size Define the size of the buffers to render to
  112734. * @param count Define the number of target we are rendering into
  112735. * @param scene Define the scene the texture belongs to
  112736. * @param options Define the options used to create the multi render target
  112737. */
  112738. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  112739. /** @hidden */
  112740. _rebuild(): void;
  112741. private _createInternalTextures;
  112742. private _createTextures;
  112743. /**
  112744. * Define the number of samples used if MSAA is enabled.
  112745. */
  112746. samples: number;
  112747. /**
  112748. * Resize all the textures in the multi render target.
  112749. * Be carrefull as it will recreate all the data in the new texture.
  112750. * @param size Define the new size
  112751. */
  112752. resize(size: any): void;
  112753. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  112754. /**
  112755. * Dispose the render targets and their associated resources
  112756. */
  112757. dispose(): void;
  112758. /**
  112759. * Release all the underlying texture used as draw buffers.
  112760. */
  112761. releaseInternalTextures(): void;
  112762. }
  112763. }
  112764. declare module BABYLON {
  112765. interface ThinEngine {
  112766. /**
  112767. * Unbind a list of render target textures from the webGL context
  112768. * This is used only when drawBuffer extension or webGL2 are active
  112769. * @param textures defines the render target textures to unbind
  112770. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112771. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112772. */
  112773. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  112774. /**
  112775. * Create a multi render target texture
  112776. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  112777. * @param size defines the size of the texture
  112778. * @param options defines the creation options
  112779. * @returns the cube texture as an InternalTexture
  112780. */
  112781. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  112782. /**
  112783. * Update the sample count for a given multiple render target texture
  112784. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  112785. * @param textures defines the textures to update
  112786. * @param samples defines the sample count to set
  112787. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  112788. */
  112789. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  112790. }
  112791. }
  112792. declare module BABYLON {
  112793. /**
  112794. * Class used to define an additional view for the engine
  112795. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112796. */
  112797. export class EngineView {
  112798. /** Defines the canvas where to render the view */
  112799. target: HTMLCanvasElement;
  112800. /** Defines an optional camera used to render the view (will use active camera else) */
  112801. camera?: Camera;
  112802. }
  112803. interface Engine {
  112804. /**
  112805. * Gets or sets the HTML element to use for attaching events
  112806. */
  112807. inputElement: Nullable<HTMLElement>;
  112808. /**
  112809. * Gets the current engine view
  112810. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112811. */
  112812. activeView: Nullable<EngineView>;
  112813. /** Gets or sets the list of views */
  112814. views: EngineView[];
  112815. /**
  112816. * Register a new child canvas
  112817. * @param canvas defines the canvas to register
  112818. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  112819. * @returns the associated view
  112820. */
  112821. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  112822. /**
  112823. * Remove a registered child canvas
  112824. * @param canvas defines the canvas to remove
  112825. * @returns the current engine
  112826. */
  112827. unRegisterView(canvas: HTMLCanvasElement): Engine;
  112828. }
  112829. }
  112830. declare module BABYLON {
  112831. /**
  112832. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  112833. */
  112834. export interface CubeMapInfo {
  112835. /**
  112836. * The pixel array for the front face.
  112837. * This is stored in format, left to right, up to down format.
  112838. */
  112839. front: Nullable<ArrayBufferView>;
  112840. /**
  112841. * The pixel array for the back face.
  112842. * This is stored in format, left to right, up to down format.
  112843. */
  112844. back: Nullable<ArrayBufferView>;
  112845. /**
  112846. * The pixel array for the left face.
  112847. * This is stored in format, left to right, up to down format.
  112848. */
  112849. left: Nullable<ArrayBufferView>;
  112850. /**
  112851. * The pixel array for the right face.
  112852. * This is stored in format, left to right, up to down format.
  112853. */
  112854. right: Nullable<ArrayBufferView>;
  112855. /**
  112856. * The pixel array for the up face.
  112857. * This is stored in format, left to right, up to down format.
  112858. */
  112859. up: Nullable<ArrayBufferView>;
  112860. /**
  112861. * The pixel array for the down face.
  112862. * This is stored in format, left to right, up to down format.
  112863. */
  112864. down: Nullable<ArrayBufferView>;
  112865. /**
  112866. * The size of the cubemap stored.
  112867. *
  112868. * Each faces will be size * size pixels.
  112869. */
  112870. size: number;
  112871. /**
  112872. * The format of the texture.
  112873. *
  112874. * RGBA, RGB.
  112875. */
  112876. format: number;
  112877. /**
  112878. * The type of the texture data.
  112879. *
  112880. * UNSIGNED_INT, FLOAT.
  112881. */
  112882. type: number;
  112883. /**
  112884. * Specifies whether the texture is in gamma space.
  112885. */
  112886. gammaSpace: boolean;
  112887. }
  112888. /**
  112889. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  112890. */
  112891. export class PanoramaToCubeMapTools {
  112892. private static FACE_FRONT;
  112893. private static FACE_BACK;
  112894. private static FACE_RIGHT;
  112895. private static FACE_LEFT;
  112896. private static FACE_DOWN;
  112897. private static FACE_UP;
  112898. /**
  112899. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  112900. *
  112901. * @param float32Array The source data.
  112902. * @param inputWidth The width of the input panorama.
  112903. * @param inputHeight The height of the input panorama.
  112904. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  112905. * @return The cubemap data
  112906. */
  112907. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  112908. private static CreateCubemapTexture;
  112909. private static CalcProjectionSpherical;
  112910. }
  112911. }
  112912. declare module BABYLON {
  112913. /**
  112914. * Helper class dealing with the extraction of spherical polynomial dataArray
  112915. * from a cube map.
  112916. */
  112917. export class CubeMapToSphericalPolynomialTools {
  112918. private static FileFaces;
  112919. /**
  112920. * Converts a texture to the according Spherical Polynomial data.
  112921. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112922. *
  112923. * @param texture The texture to extract the information from.
  112924. * @return The Spherical Polynomial data.
  112925. */
  112926. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  112927. /**
  112928. * Converts a cubemap to the according Spherical Polynomial data.
  112929. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112930. *
  112931. * @param cubeInfo The Cube map to extract the information from.
  112932. * @return The Spherical Polynomial data.
  112933. */
  112934. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  112935. }
  112936. }
  112937. declare module BABYLON {
  112938. interface BaseTexture {
  112939. /**
  112940. * Get the polynomial representation of the texture data.
  112941. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  112942. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  112943. */
  112944. sphericalPolynomial: Nullable<SphericalPolynomial>;
  112945. }
  112946. }
  112947. declare module BABYLON {
  112948. /** @hidden */
  112949. export var rgbdEncodePixelShader: {
  112950. name: string;
  112951. shader: string;
  112952. };
  112953. }
  112954. declare module BABYLON {
  112955. /** @hidden */
  112956. export var rgbdDecodePixelShader: {
  112957. name: string;
  112958. shader: string;
  112959. };
  112960. }
  112961. declare module BABYLON {
  112962. /**
  112963. * Raw texture data and descriptor sufficient for WebGL texture upload
  112964. */
  112965. export interface EnvironmentTextureInfo {
  112966. /**
  112967. * Version of the environment map
  112968. */
  112969. version: number;
  112970. /**
  112971. * Width of image
  112972. */
  112973. width: number;
  112974. /**
  112975. * Irradiance information stored in the file.
  112976. */
  112977. irradiance: any;
  112978. /**
  112979. * Specular information stored in the file.
  112980. */
  112981. specular: any;
  112982. }
  112983. /**
  112984. * Defines One Image in the file. It requires only the position in the file
  112985. * as well as the length.
  112986. */
  112987. interface BufferImageData {
  112988. /**
  112989. * Length of the image data.
  112990. */
  112991. length: number;
  112992. /**
  112993. * Position of the data from the null terminator delimiting the end of the JSON.
  112994. */
  112995. position: number;
  112996. }
  112997. /**
  112998. * Defines the specular data enclosed in the file.
  112999. * This corresponds to the version 1 of the data.
  113000. */
  113001. export interface EnvironmentTextureSpecularInfoV1 {
  113002. /**
  113003. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113004. */
  113005. specularDataPosition?: number;
  113006. /**
  113007. * This contains all the images data needed to reconstruct the cubemap.
  113008. */
  113009. mipmaps: Array<BufferImageData>;
  113010. /**
  113011. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113012. */
  113013. lodGenerationScale: number;
  113014. }
  113015. /**
  113016. * Sets of helpers addressing the serialization and deserialization of environment texture
  113017. * stored in a BabylonJS env file.
  113018. * Those files are usually stored as .env files.
  113019. */
  113020. export class EnvironmentTextureTools {
  113021. /**
  113022. * Magic number identifying the env file.
  113023. */
  113024. private static _MagicBytes;
  113025. /**
  113026. * Gets the environment info from an env file.
  113027. * @param data The array buffer containing the .env bytes.
  113028. * @returns the environment file info (the json header) if successfully parsed.
  113029. */
  113030. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113031. /**
  113032. * Creates an environment texture from a loaded cube texture.
  113033. * @param texture defines the cube texture to convert in env file
  113034. * @return a promise containing the environment data if succesfull.
  113035. */
  113036. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113037. /**
  113038. * Creates a JSON representation of the spherical data.
  113039. * @param texture defines the texture containing the polynomials
  113040. * @return the JSON representation of the spherical info
  113041. */
  113042. private static _CreateEnvTextureIrradiance;
  113043. /**
  113044. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113045. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113046. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113047. * @return the views described by info providing access to the underlying buffer
  113048. */
  113049. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113050. /**
  113051. * Uploads the texture info contained in the env file to the GPU.
  113052. * @param texture defines the internal texture to upload to
  113053. * @param arrayBuffer defines the buffer cotaining the data to load
  113054. * @param info defines the texture info retrieved through the GetEnvInfo method
  113055. * @returns a promise
  113056. */
  113057. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113058. private static _OnImageReadyAsync;
  113059. /**
  113060. * Uploads the levels of image data to the GPU.
  113061. * @param texture defines the internal texture to upload to
  113062. * @param imageData defines the array buffer views of image data [mipmap][face]
  113063. * @returns a promise
  113064. */
  113065. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113066. /**
  113067. * Uploads spherical polynomials information to the texture.
  113068. * @param texture defines the texture we are trying to upload the information to
  113069. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113070. */
  113071. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113072. /** @hidden */
  113073. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113074. }
  113075. }
  113076. declare module BABYLON {
  113077. /**
  113078. * Contains position and normal vectors for a vertex
  113079. */
  113080. export class PositionNormalVertex {
  113081. /** the position of the vertex (defaut: 0,0,0) */
  113082. position: Vector3;
  113083. /** the normal of the vertex (defaut: 0,1,0) */
  113084. normal: Vector3;
  113085. /**
  113086. * Creates a PositionNormalVertex
  113087. * @param position the position of the vertex (defaut: 0,0,0)
  113088. * @param normal the normal of the vertex (defaut: 0,1,0)
  113089. */
  113090. constructor(
  113091. /** the position of the vertex (defaut: 0,0,0) */
  113092. position?: Vector3,
  113093. /** the normal of the vertex (defaut: 0,1,0) */
  113094. normal?: Vector3);
  113095. /**
  113096. * Clones the PositionNormalVertex
  113097. * @returns the cloned PositionNormalVertex
  113098. */
  113099. clone(): PositionNormalVertex;
  113100. }
  113101. /**
  113102. * Contains position, normal and uv vectors for a vertex
  113103. */
  113104. export class PositionNormalTextureVertex {
  113105. /** the position of the vertex (defaut: 0,0,0) */
  113106. position: Vector3;
  113107. /** the normal of the vertex (defaut: 0,1,0) */
  113108. normal: Vector3;
  113109. /** the uv of the vertex (default: 0,0) */
  113110. uv: Vector2;
  113111. /**
  113112. * Creates a PositionNormalTextureVertex
  113113. * @param position the position of the vertex (defaut: 0,0,0)
  113114. * @param normal the normal of the vertex (defaut: 0,1,0)
  113115. * @param uv the uv of the vertex (default: 0,0)
  113116. */
  113117. constructor(
  113118. /** the position of the vertex (defaut: 0,0,0) */
  113119. position?: Vector3,
  113120. /** the normal of the vertex (defaut: 0,1,0) */
  113121. normal?: Vector3,
  113122. /** the uv of the vertex (default: 0,0) */
  113123. uv?: Vector2);
  113124. /**
  113125. * Clones the PositionNormalTextureVertex
  113126. * @returns the cloned PositionNormalTextureVertex
  113127. */
  113128. clone(): PositionNormalTextureVertex;
  113129. }
  113130. }
  113131. declare module BABYLON {
  113132. /** @hidden */
  113133. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113134. private _genericAttributeLocation;
  113135. private _varyingLocationCount;
  113136. private _varyingLocationMap;
  113137. private _replacements;
  113138. private _textureCount;
  113139. private _uniforms;
  113140. lineProcessor(line: string): string;
  113141. attributeProcessor(attribute: string): string;
  113142. varyingProcessor(varying: string, isFragment: boolean): string;
  113143. uniformProcessor(uniform: string): string;
  113144. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113145. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113146. }
  113147. }
  113148. declare module BABYLON {
  113149. /**
  113150. * Container for accessors for natively-stored mesh data buffers.
  113151. */
  113152. class NativeDataBuffer extends DataBuffer {
  113153. /**
  113154. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113155. */
  113156. nativeIndexBuffer?: any;
  113157. /**
  113158. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113159. */
  113160. nativeVertexBuffer?: any;
  113161. }
  113162. /** @hidden */
  113163. class NativeTexture extends InternalTexture {
  113164. getInternalTexture(): InternalTexture;
  113165. getViewCount(): number;
  113166. }
  113167. /** @hidden */
  113168. export class NativeEngine extends Engine {
  113169. private readonly _native;
  113170. getHardwareScalingLevel(): number;
  113171. constructor();
  113172. /**
  113173. * Can be used to override the current requestAnimationFrame requester.
  113174. * @hidden
  113175. */
  113176. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113177. /**
  113178. * Override default engine behavior.
  113179. * @param color
  113180. * @param backBuffer
  113181. * @param depth
  113182. * @param stencil
  113183. */
  113184. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113185. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113186. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113187. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113188. recordVertexArrayObject(vertexBuffers: {
  113189. [key: string]: VertexBuffer;
  113190. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113191. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113192. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113193. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113194. /**
  113195. * Draw a list of indexed primitives
  113196. * @param fillMode defines the primitive to use
  113197. * @param indexStart defines the starting index
  113198. * @param indexCount defines the number of index to draw
  113199. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113200. */
  113201. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113202. /**
  113203. * Draw a list of unindexed primitives
  113204. * @param fillMode defines the primitive to use
  113205. * @param verticesStart defines the index of first vertex to draw
  113206. * @param verticesCount defines the count of vertices to draw
  113207. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113208. */
  113209. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113210. createPipelineContext(): IPipelineContext;
  113211. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113212. /** @hidden */
  113213. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113214. /** @hidden */
  113215. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113216. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113217. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113218. protected _setProgram(program: WebGLProgram): void;
  113219. _releaseEffect(effect: Effect): void;
  113220. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113221. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113222. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113223. bindSamplers(effect: Effect): void;
  113224. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113225. getRenderWidth(useScreen?: boolean): number;
  113226. getRenderHeight(useScreen?: boolean): number;
  113227. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113228. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113229. /**
  113230. * Set the z offset to apply to current rendering
  113231. * @param value defines the offset to apply
  113232. */
  113233. setZOffset(value: number): void;
  113234. /**
  113235. * Gets the current value of the zOffset
  113236. * @returns the current zOffset state
  113237. */
  113238. getZOffset(): number;
  113239. /**
  113240. * Enable or disable depth buffering
  113241. * @param enable defines the state to set
  113242. */
  113243. setDepthBuffer(enable: boolean): void;
  113244. /**
  113245. * Gets a boolean indicating if depth writing is enabled
  113246. * @returns the current depth writing state
  113247. */
  113248. getDepthWrite(): boolean;
  113249. /**
  113250. * Enable or disable depth writing
  113251. * @param enable defines the state to set
  113252. */
  113253. setDepthWrite(enable: boolean): void;
  113254. /**
  113255. * Enable or disable color writing
  113256. * @param enable defines the state to set
  113257. */
  113258. setColorWrite(enable: boolean): void;
  113259. /**
  113260. * Gets a boolean indicating if color writing is enabled
  113261. * @returns the current color writing state
  113262. */
  113263. getColorWrite(): boolean;
  113264. /**
  113265. * Sets alpha constants used by some alpha blending modes
  113266. * @param r defines the red component
  113267. * @param g defines the green component
  113268. * @param b defines the blue component
  113269. * @param a defines the alpha component
  113270. */
  113271. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113272. /**
  113273. * Sets the current alpha mode
  113274. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113275. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113276. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113277. */
  113278. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113279. /**
  113280. * Gets the current alpha mode
  113281. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113282. * @returns the current alpha mode
  113283. */
  113284. getAlphaMode(): number;
  113285. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113286. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113287. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113288. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113289. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113290. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113291. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113292. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113293. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113294. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113295. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113296. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113297. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113298. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113299. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113300. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113301. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113302. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113303. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113304. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113305. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113306. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113307. wipeCaches(bruteForce?: boolean): void;
  113308. _createTexture(): WebGLTexture;
  113309. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113310. /**
  113311. * Usually called from BABYLON.Texture.ts.
  113312. * Passed information to create a WebGLTexture
  113313. * @param urlArg defines a value which contains one of the following:
  113314. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113315. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113316. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113317. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113318. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113319. * @param scene needed for loading to the correct scene
  113320. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113321. * @param onLoad optional callback to be called upon successful completion
  113322. * @param onError optional callback to be called upon failure
  113323. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113324. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113325. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113326. * @param forcedExtension defines the extension to use to pick the right loader
  113327. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113328. */
  113329. 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;
  113330. /**
  113331. * Creates a cube texture
  113332. * @param rootUrl defines the url where the files to load is located
  113333. * @param scene defines the current scene
  113334. * @param files defines the list of files to load (1 per face)
  113335. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113336. * @param onLoad defines an optional callback raised when the texture is loaded
  113337. * @param onError defines an optional callback raised if there is an issue to load the texture
  113338. * @param format defines the format of the data
  113339. * @param forcedExtension defines the extension to use to pick the right loader
  113340. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113341. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113342. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113343. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113344. * @returns the cube texture as an InternalTexture
  113345. */
  113346. 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;
  113347. private _getSamplingFilter;
  113348. private static _GetNativeTextureFormat;
  113349. createRenderTargetTexture(size: number | {
  113350. width: number;
  113351. height: number;
  113352. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113353. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113354. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113355. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113356. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113357. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113358. /**
  113359. * Updates a dynamic vertex buffer.
  113360. * @param vertexBuffer the vertex buffer to update
  113361. * @param data the data used to update the vertex buffer
  113362. * @param byteOffset the byte offset of the data (optional)
  113363. * @param byteLength the byte length of the data (optional)
  113364. */
  113365. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113366. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113367. private _updateAnisotropicLevel;
  113368. private _getAddressMode;
  113369. /** @hidden */
  113370. _bindTexture(channel: number, texture: InternalTexture): void;
  113371. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113372. releaseEffects(): void;
  113373. /** @hidden */
  113374. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113375. /** @hidden */
  113376. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113377. /** @hidden */
  113378. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113379. /** @hidden */
  113380. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113381. }
  113382. }
  113383. declare module BABYLON {
  113384. /**
  113385. * Gather the list of clipboard event types as constants.
  113386. */
  113387. export class ClipboardEventTypes {
  113388. /**
  113389. * The clipboard event is fired when a copy command is active (pressed).
  113390. */
  113391. static readonly COPY: number;
  113392. /**
  113393. * The clipboard event is fired when a cut command is active (pressed).
  113394. */
  113395. static readonly CUT: number;
  113396. /**
  113397. * The clipboard event is fired when a paste command is active (pressed).
  113398. */
  113399. static readonly PASTE: number;
  113400. }
  113401. /**
  113402. * This class is used to store clipboard related info for the onClipboardObservable event.
  113403. */
  113404. export class ClipboardInfo {
  113405. /**
  113406. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113407. */
  113408. type: number;
  113409. /**
  113410. * Defines the related dom event
  113411. */
  113412. event: ClipboardEvent;
  113413. /**
  113414. *Creates an instance of ClipboardInfo.
  113415. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113416. * @param event Defines the related dom event
  113417. */
  113418. constructor(
  113419. /**
  113420. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113421. */
  113422. type: number,
  113423. /**
  113424. * Defines the related dom event
  113425. */
  113426. event: ClipboardEvent);
  113427. /**
  113428. * Get the clipboard event's type from the keycode.
  113429. * @param keyCode Defines the keyCode for the current keyboard event.
  113430. * @return {number}
  113431. */
  113432. static GetTypeFromCharacter(keyCode: number): number;
  113433. }
  113434. }
  113435. declare module BABYLON {
  113436. /**
  113437. * Google Daydream controller
  113438. */
  113439. export class DaydreamController extends WebVRController {
  113440. /**
  113441. * Base Url for the controller model.
  113442. */
  113443. static MODEL_BASE_URL: string;
  113444. /**
  113445. * File name for the controller model.
  113446. */
  113447. static MODEL_FILENAME: string;
  113448. /**
  113449. * Gamepad Id prefix used to identify Daydream Controller.
  113450. */
  113451. static readonly GAMEPAD_ID_PREFIX: string;
  113452. /**
  113453. * Creates a new DaydreamController from a gamepad
  113454. * @param vrGamepad the gamepad that the controller should be created from
  113455. */
  113456. constructor(vrGamepad: any);
  113457. /**
  113458. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113459. * @param scene scene in which to add meshes
  113460. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113461. */
  113462. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113463. /**
  113464. * Called once for each button that changed state since the last frame
  113465. * @param buttonIdx Which button index changed
  113466. * @param state New state of the button
  113467. * @param changes Which properties on the state changed since last frame
  113468. */
  113469. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113470. }
  113471. }
  113472. declare module BABYLON {
  113473. /**
  113474. * Gear VR Controller
  113475. */
  113476. export class GearVRController extends WebVRController {
  113477. /**
  113478. * Base Url for the controller model.
  113479. */
  113480. static MODEL_BASE_URL: string;
  113481. /**
  113482. * File name for the controller model.
  113483. */
  113484. static MODEL_FILENAME: string;
  113485. /**
  113486. * Gamepad Id prefix used to identify this controller.
  113487. */
  113488. static readonly GAMEPAD_ID_PREFIX: string;
  113489. private readonly _buttonIndexToObservableNameMap;
  113490. /**
  113491. * Creates a new GearVRController from a gamepad
  113492. * @param vrGamepad the gamepad that the controller should be created from
  113493. */
  113494. constructor(vrGamepad: any);
  113495. /**
  113496. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113497. * @param scene scene in which to add meshes
  113498. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113499. */
  113500. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113501. /**
  113502. * Called once for each button that changed state since the last frame
  113503. * @param buttonIdx Which button index changed
  113504. * @param state New state of the button
  113505. * @param changes Which properties on the state changed since last frame
  113506. */
  113507. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113508. }
  113509. }
  113510. declare module BABYLON {
  113511. /**
  113512. * Class containing static functions to help procedurally build meshes
  113513. */
  113514. export class PolyhedronBuilder {
  113515. /**
  113516. * Creates a polyhedron mesh
  113517. * * 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
  113518. * * The parameter `size` (positive float, default 1) sets the polygon size
  113519. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113520. * * 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`
  113521. * * 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
  113522. * * 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)`)
  113523. * * 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
  113524. * * 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
  113525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113528. * @param name defines the name of the mesh
  113529. * @param options defines the options used to create the mesh
  113530. * @param scene defines the hosting scene
  113531. * @returns the polyhedron mesh
  113532. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113533. */
  113534. static CreatePolyhedron(name: string, options: {
  113535. type?: number;
  113536. size?: number;
  113537. sizeX?: number;
  113538. sizeY?: number;
  113539. sizeZ?: number;
  113540. custom?: any;
  113541. faceUV?: Vector4[];
  113542. faceColors?: Color4[];
  113543. flat?: boolean;
  113544. updatable?: boolean;
  113545. sideOrientation?: number;
  113546. frontUVs?: Vector4;
  113547. backUVs?: Vector4;
  113548. }, scene?: Nullable<Scene>): Mesh;
  113549. }
  113550. }
  113551. declare module BABYLON {
  113552. /**
  113553. * Gizmo that enables scaling a mesh along 3 axis
  113554. */
  113555. export class ScaleGizmo extends Gizmo {
  113556. /**
  113557. * Internal gizmo used for interactions on the x axis
  113558. */
  113559. xGizmo: AxisScaleGizmo;
  113560. /**
  113561. * Internal gizmo used for interactions on the y axis
  113562. */
  113563. yGizmo: AxisScaleGizmo;
  113564. /**
  113565. * Internal gizmo used for interactions on the z axis
  113566. */
  113567. zGizmo: AxisScaleGizmo;
  113568. /**
  113569. * Internal gizmo used to scale all axis equally
  113570. */
  113571. uniformScaleGizmo: AxisScaleGizmo;
  113572. private _meshAttached;
  113573. private _updateGizmoRotationToMatchAttachedMesh;
  113574. private _snapDistance;
  113575. private _scaleRatio;
  113576. private _uniformScalingMesh;
  113577. private _octahedron;
  113578. /** Fires an event when any of it's sub gizmos are dragged */
  113579. onDragStartObservable: Observable<unknown>;
  113580. /** Fires an event when any of it's sub gizmos are released from dragging */
  113581. onDragEndObservable: Observable<unknown>;
  113582. attachedMesh: Nullable<AbstractMesh>;
  113583. /**
  113584. * Creates a ScaleGizmo
  113585. * @param gizmoLayer The utility layer the gizmo will be added to
  113586. */
  113587. constructor(gizmoLayer?: UtilityLayerRenderer);
  113588. updateGizmoRotationToMatchAttachedMesh: boolean;
  113589. /**
  113590. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113591. */
  113592. snapDistance: number;
  113593. /**
  113594. * Ratio for the scale of the gizmo (Default: 1)
  113595. */
  113596. scaleRatio: number;
  113597. /**
  113598. * Disposes of the gizmo
  113599. */
  113600. dispose(): void;
  113601. }
  113602. }
  113603. declare module BABYLON {
  113604. /**
  113605. * Single axis scale gizmo
  113606. */
  113607. export class AxisScaleGizmo extends Gizmo {
  113608. /**
  113609. * Drag behavior responsible for the gizmos dragging interactions
  113610. */
  113611. dragBehavior: PointerDragBehavior;
  113612. private _pointerObserver;
  113613. /**
  113614. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113615. */
  113616. snapDistance: number;
  113617. /**
  113618. * Event that fires each time the gizmo snaps to a new location.
  113619. * * snapDistance is the the change in distance
  113620. */
  113621. onSnapObservable: Observable<{
  113622. snapDistance: number;
  113623. }>;
  113624. /**
  113625. * If the scaling operation should be done on all axis (default: false)
  113626. */
  113627. uniformScaling: boolean;
  113628. private _isEnabled;
  113629. private _parent;
  113630. private _arrow;
  113631. private _coloredMaterial;
  113632. private _hoverMaterial;
  113633. /**
  113634. * Creates an AxisScaleGizmo
  113635. * @param gizmoLayer The utility layer the gizmo will be added to
  113636. * @param dragAxis The axis which the gizmo will be able to scale on
  113637. * @param color The color of the gizmo
  113638. */
  113639. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113640. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113641. /**
  113642. * If the gizmo is enabled
  113643. */
  113644. isEnabled: boolean;
  113645. /**
  113646. * Disposes of the gizmo
  113647. */
  113648. dispose(): void;
  113649. /**
  113650. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113651. * @param mesh The mesh to replace the default mesh of the gizmo
  113652. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113653. */
  113654. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113655. }
  113656. }
  113657. declare module BABYLON {
  113658. /**
  113659. * Bounding box gizmo
  113660. */
  113661. export class BoundingBoxGizmo extends Gizmo {
  113662. private _lineBoundingBox;
  113663. private _rotateSpheresParent;
  113664. private _scaleBoxesParent;
  113665. private _boundingDimensions;
  113666. private _renderObserver;
  113667. private _pointerObserver;
  113668. private _scaleDragSpeed;
  113669. private _tmpQuaternion;
  113670. private _tmpVector;
  113671. private _tmpRotationMatrix;
  113672. /**
  113673. * 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)
  113674. */
  113675. ignoreChildren: boolean;
  113676. /**
  113677. * 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)
  113678. */
  113679. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  113680. /**
  113681. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  113682. */
  113683. rotationSphereSize: number;
  113684. /**
  113685. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  113686. */
  113687. scaleBoxSize: number;
  113688. /**
  113689. * 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)
  113690. */
  113691. fixedDragMeshScreenSize: boolean;
  113692. /**
  113693. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  113694. */
  113695. fixedDragMeshScreenSizeDistanceFactor: number;
  113696. /**
  113697. * Fired when a rotation sphere or scale box is dragged
  113698. */
  113699. onDragStartObservable: Observable<{}>;
  113700. /**
  113701. * Fired when a scale box is dragged
  113702. */
  113703. onScaleBoxDragObservable: Observable<{}>;
  113704. /**
  113705. * Fired when a scale box drag is ended
  113706. */
  113707. onScaleBoxDragEndObservable: Observable<{}>;
  113708. /**
  113709. * Fired when a rotation sphere is dragged
  113710. */
  113711. onRotationSphereDragObservable: Observable<{}>;
  113712. /**
  113713. * Fired when a rotation sphere drag is ended
  113714. */
  113715. onRotationSphereDragEndObservable: Observable<{}>;
  113716. /**
  113717. * 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)
  113718. */
  113719. scalePivot: Nullable<Vector3>;
  113720. /**
  113721. * Mesh used as a pivot to rotate the attached mesh
  113722. */
  113723. private _anchorMesh;
  113724. private _existingMeshScale;
  113725. private _dragMesh;
  113726. private pointerDragBehavior;
  113727. private coloredMaterial;
  113728. private hoverColoredMaterial;
  113729. /**
  113730. * Sets the color of the bounding box gizmo
  113731. * @param color the color to set
  113732. */
  113733. setColor(color: Color3): void;
  113734. /**
  113735. * Creates an BoundingBoxGizmo
  113736. * @param gizmoLayer The utility layer the gizmo will be added to
  113737. * @param color The color of the gizmo
  113738. */
  113739. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  113740. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113741. private _selectNode;
  113742. /**
  113743. * Updates the bounding box information for the Gizmo
  113744. */
  113745. updateBoundingBox(): void;
  113746. private _updateRotationSpheres;
  113747. private _updateScaleBoxes;
  113748. /**
  113749. * Enables rotation on the specified axis and disables rotation on the others
  113750. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  113751. */
  113752. setEnabledRotationAxis(axis: string): void;
  113753. /**
  113754. * Enables/disables scaling
  113755. * @param enable if scaling should be enabled
  113756. */
  113757. setEnabledScaling(enable: boolean): void;
  113758. private _updateDummy;
  113759. /**
  113760. * Enables a pointer drag behavior on the bounding box of the gizmo
  113761. */
  113762. enableDragBehavior(): void;
  113763. /**
  113764. * Disposes of the gizmo
  113765. */
  113766. dispose(): void;
  113767. /**
  113768. * 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)
  113769. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  113770. * @returns the bounding box mesh with the passed in mesh as a child
  113771. */
  113772. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  113773. /**
  113774. * CustomMeshes are not supported by this gizmo
  113775. * @param mesh The mesh to replace the default mesh of the gizmo
  113776. */
  113777. setCustomMesh(mesh: Mesh): void;
  113778. }
  113779. }
  113780. declare module BABYLON {
  113781. /**
  113782. * Single plane rotation gizmo
  113783. */
  113784. export class PlaneRotationGizmo extends Gizmo {
  113785. /**
  113786. * Drag behavior responsible for the gizmos dragging interactions
  113787. */
  113788. dragBehavior: PointerDragBehavior;
  113789. private _pointerObserver;
  113790. /**
  113791. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  113792. */
  113793. snapDistance: number;
  113794. /**
  113795. * Event that fires each time the gizmo snaps to a new location.
  113796. * * snapDistance is the the change in distance
  113797. */
  113798. onSnapObservable: Observable<{
  113799. snapDistance: number;
  113800. }>;
  113801. private _isEnabled;
  113802. private _parent;
  113803. /**
  113804. * Creates a PlaneRotationGizmo
  113805. * @param gizmoLayer The utility layer the gizmo will be added to
  113806. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  113807. * @param color The color of the gizmo
  113808. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113809. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113810. */
  113811. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  113812. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113813. /**
  113814. * If the gizmo is enabled
  113815. */
  113816. isEnabled: boolean;
  113817. /**
  113818. * Disposes of the gizmo
  113819. */
  113820. dispose(): void;
  113821. }
  113822. }
  113823. declare module BABYLON {
  113824. /**
  113825. * Gizmo that enables rotating a mesh along 3 axis
  113826. */
  113827. export class RotationGizmo extends Gizmo {
  113828. /**
  113829. * Internal gizmo used for interactions on the x axis
  113830. */
  113831. xGizmo: PlaneRotationGizmo;
  113832. /**
  113833. * Internal gizmo used for interactions on the y axis
  113834. */
  113835. yGizmo: PlaneRotationGizmo;
  113836. /**
  113837. * Internal gizmo used for interactions on the z axis
  113838. */
  113839. zGizmo: PlaneRotationGizmo;
  113840. /** Fires an event when any of it's sub gizmos are dragged */
  113841. onDragStartObservable: Observable<unknown>;
  113842. /** Fires an event when any of it's sub gizmos are released from dragging */
  113843. onDragEndObservable: Observable<unknown>;
  113844. private _meshAttached;
  113845. attachedMesh: Nullable<AbstractMesh>;
  113846. /**
  113847. * Creates a RotationGizmo
  113848. * @param gizmoLayer The utility layer the gizmo will be added to
  113849. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113850. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113851. */
  113852. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  113853. updateGizmoRotationToMatchAttachedMesh: boolean;
  113854. /**
  113855. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113856. */
  113857. snapDistance: number;
  113858. /**
  113859. * Ratio for the scale of the gizmo (Default: 1)
  113860. */
  113861. scaleRatio: number;
  113862. /**
  113863. * Disposes of the gizmo
  113864. */
  113865. dispose(): void;
  113866. /**
  113867. * CustomMeshes are not supported by this gizmo
  113868. * @param mesh The mesh to replace the default mesh of the gizmo
  113869. */
  113870. setCustomMesh(mesh: Mesh): void;
  113871. }
  113872. }
  113873. declare module BABYLON {
  113874. /**
  113875. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  113876. */
  113877. export class GizmoManager implements IDisposable {
  113878. private scene;
  113879. /**
  113880. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  113881. */
  113882. gizmos: {
  113883. positionGizmo: Nullable<PositionGizmo>;
  113884. rotationGizmo: Nullable<RotationGizmo>;
  113885. scaleGizmo: Nullable<ScaleGizmo>;
  113886. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  113887. };
  113888. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  113889. clearGizmoOnEmptyPointerEvent: boolean;
  113890. /** Fires an event when the manager is attached to a mesh */
  113891. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  113892. private _gizmosEnabled;
  113893. private _pointerObserver;
  113894. private _attachedMesh;
  113895. private _boundingBoxColor;
  113896. private _defaultUtilityLayer;
  113897. private _defaultKeepDepthUtilityLayer;
  113898. /**
  113899. * When bounding box gizmo is enabled, this can be used to track drag/end events
  113900. */
  113901. boundingBoxDragBehavior: SixDofDragBehavior;
  113902. /**
  113903. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  113904. */
  113905. attachableMeshes: Nullable<Array<AbstractMesh>>;
  113906. /**
  113907. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  113908. */
  113909. usePointerToAttachGizmos: boolean;
  113910. /**
  113911. * Utility layer that the bounding box gizmo belongs to
  113912. */
  113913. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  113914. /**
  113915. * Utility layer that all gizmos besides bounding box belong to
  113916. */
  113917. readonly utilityLayer: UtilityLayerRenderer;
  113918. /**
  113919. * Instatiates a gizmo manager
  113920. * @param scene the scene to overlay the gizmos on top of
  113921. */
  113922. constructor(scene: Scene);
  113923. /**
  113924. * Attaches a set of gizmos to the specified mesh
  113925. * @param mesh The mesh the gizmo's should be attached to
  113926. */
  113927. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  113928. /**
  113929. * If the position gizmo is enabled
  113930. */
  113931. positionGizmoEnabled: boolean;
  113932. /**
  113933. * If the rotation gizmo is enabled
  113934. */
  113935. rotationGizmoEnabled: boolean;
  113936. /**
  113937. * If the scale gizmo is enabled
  113938. */
  113939. scaleGizmoEnabled: boolean;
  113940. /**
  113941. * If the boundingBox gizmo is enabled
  113942. */
  113943. boundingBoxGizmoEnabled: boolean;
  113944. /**
  113945. * Disposes of the gizmo manager
  113946. */
  113947. dispose(): void;
  113948. }
  113949. }
  113950. declare module BABYLON {
  113951. /**
  113952. * A directional light is defined by a direction (what a surprise!).
  113953. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  113954. * 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.
  113955. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113956. */
  113957. export class DirectionalLight extends ShadowLight {
  113958. private _shadowFrustumSize;
  113959. /**
  113960. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  113961. */
  113962. /**
  113963. * Specifies a fix frustum size for the shadow generation.
  113964. */
  113965. shadowFrustumSize: number;
  113966. private _shadowOrthoScale;
  113967. /**
  113968. * Gets the shadow projection scale against the optimal computed one.
  113969. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113970. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113971. */
  113972. /**
  113973. * Sets the shadow projection scale against the optimal computed one.
  113974. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113975. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113976. */
  113977. shadowOrthoScale: number;
  113978. /**
  113979. * Automatically compute the projection matrix to best fit (including all the casters)
  113980. * on each frame.
  113981. */
  113982. autoUpdateExtends: boolean;
  113983. private _orthoLeft;
  113984. private _orthoRight;
  113985. private _orthoTop;
  113986. private _orthoBottom;
  113987. /**
  113988. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  113989. * The directional light is emitted from everywhere in the given direction.
  113990. * It can cast shadows.
  113991. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113992. * @param name The friendly name of the light
  113993. * @param direction The direction of the light
  113994. * @param scene The scene the light belongs to
  113995. */
  113996. constructor(name: string, direction: Vector3, scene: Scene);
  113997. /**
  113998. * Returns the string "DirectionalLight".
  113999. * @return The class name
  114000. */
  114001. getClassName(): string;
  114002. /**
  114003. * Returns the integer 1.
  114004. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114005. */
  114006. getTypeID(): number;
  114007. /**
  114008. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114009. * Returns the DirectionalLight Shadow projection matrix.
  114010. */
  114011. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114012. /**
  114013. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114014. * Returns the DirectionalLight Shadow projection matrix.
  114015. */
  114016. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114017. /**
  114018. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114019. * Returns the DirectionalLight Shadow projection matrix.
  114020. */
  114021. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114022. protected _buildUniformLayout(): void;
  114023. /**
  114024. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114025. * @param effect The effect to update
  114026. * @param lightIndex The index of the light in the effect to update
  114027. * @returns The directional light
  114028. */
  114029. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114030. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114031. /**
  114032. * Gets the minZ used for shadow according to both the scene and the light.
  114033. *
  114034. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114035. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114036. * @param activeCamera The camera we are returning the min for
  114037. * @returns the depth min z
  114038. */
  114039. getDepthMinZ(activeCamera: Camera): number;
  114040. /**
  114041. * Gets the maxZ used for shadow according to both the scene and the light.
  114042. *
  114043. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114044. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114045. * @param activeCamera The camera we are returning the max for
  114046. * @returns the depth max z
  114047. */
  114048. getDepthMaxZ(activeCamera: Camera): number;
  114049. /**
  114050. * Prepares the list of defines specific to the light type.
  114051. * @param defines the list of defines
  114052. * @param lightIndex defines the index of the light for the effect
  114053. */
  114054. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114055. }
  114056. }
  114057. declare module BABYLON {
  114058. /**
  114059. * Class containing static functions to help procedurally build meshes
  114060. */
  114061. export class HemisphereBuilder {
  114062. /**
  114063. * Creates a hemisphere mesh
  114064. * @param name defines the name of the mesh
  114065. * @param options defines the options used to create the mesh
  114066. * @param scene defines the hosting scene
  114067. * @returns the hemisphere mesh
  114068. */
  114069. static CreateHemisphere(name: string, options: {
  114070. segments?: number;
  114071. diameter?: number;
  114072. sideOrientation?: number;
  114073. }, scene: any): Mesh;
  114074. }
  114075. }
  114076. declare module BABYLON {
  114077. /**
  114078. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114079. * These values define a cone of light starting from the position, emitting toward the direction.
  114080. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114081. * and the exponent defines the speed of the decay of the light with distance (reach).
  114082. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114083. */
  114084. export class SpotLight extends ShadowLight {
  114085. private _angle;
  114086. private _innerAngle;
  114087. private _cosHalfAngle;
  114088. private _lightAngleScale;
  114089. private _lightAngleOffset;
  114090. /**
  114091. * Gets the cone angle of the spot light in Radians.
  114092. */
  114093. /**
  114094. * Sets the cone angle of the spot light in Radians.
  114095. */
  114096. angle: number;
  114097. /**
  114098. * Only used in gltf falloff mode, this defines the angle where
  114099. * the directional falloff will start before cutting at angle which could be seen
  114100. * as outer angle.
  114101. */
  114102. /**
  114103. * Only used in gltf falloff mode, this defines the angle where
  114104. * the directional falloff will start before cutting at angle which could be seen
  114105. * as outer angle.
  114106. */
  114107. innerAngle: number;
  114108. private _shadowAngleScale;
  114109. /**
  114110. * Allows scaling the angle of the light for shadow generation only.
  114111. */
  114112. /**
  114113. * Allows scaling the angle of the light for shadow generation only.
  114114. */
  114115. shadowAngleScale: number;
  114116. /**
  114117. * The light decay speed with the distance from the emission spot.
  114118. */
  114119. exponent: number;
  114120. private _projectionTextureMatrix;
  114121. /**
  114122. * Allows reading the projecton texture
  114123. */
  114124. readonly projectionTextureMatrix: Matrix;
  114125. protected _projectionTextureLightNear: number;
  114126. /**
  114127. * Gets the near clip of the Spotlight for texture projection.
  114128. */
  114129. /**
  114130. * Sets the near clip of the Spotlight for texture projection.
  114131. */
  114132. projectionTextureLightNear: number;
  114133. protected _projectionTextureLightFar: number;
  114134. /**
  114135. * Gets the far clip of the Spotlight for texture projection.
  114136. */
  114137. /**
  114138. * Sets the far clip of the Spotlight for texture projection.
  114139. */
  114140. projectionTextureLightFar: number;
  114141. protected _projectionTextureUpDirection: Vector3;
  114142. /**
  114143. * Gets the Up vector of the Spotlight for texture projection.
  114144. */
  114145. /**
  114146. * Sets the Up vector of the Spotlight for texture projection.
  114147. */
  114148. projectionTextureUpDirection: Vector3;
  114149. private _projectionTexture;
  114150. /**
  114151. * Gets the projection texture of the light.
  114152. */
  114153. /**
  114154. * Sets the projection texture of the light.
  114155. */
  114156. projectionTexture: Nullable<BaseTexture>;
  114157. private _projectionTextureViewLightDirty;
  114158. private _projectionTextureProjectionLightDirty;
  114159. private _projectionTextureDirty;
  114160. private _projectionTextureViewTargetVector;
  114161. private _projectionTextureViewLightMatrix;
  114162. private _projectionTextureProjectionLightMatrix;
  114163. private _projectionTextureScalingMatrix;
  114164. /**
  114165. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114166. * It can cast shadows.
  114167. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114168. * @param name The light friendly name
  114169. * @param position The position of the spot light in the scene
  114170. * @param direction The direction of the light in the scene
  114171. * @param angle The cone angle of the light in Radians
  114172. * @param exponent The light decay speed with the distance from the emission spot
  114173. * @param scene The scene the lights belongs to
  114174. */
  114175. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114176. /**
  114177. * Returns the string "SpotLight".
  114178. * @returns the class name
  114179. */
  114180. getClassName(): string;
  114181. /**
  114182. * Returns the integer 2.
  114183. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114184. */
  114185. getTypeID(): number;
  114186. /**
  114187. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114188. */
  114189. protected _setDirection(value: Vector3): void;
  114190. /**
  114191. * Overrides the position setter to recompute the projection texture view light Matrix.
  114192. */
  114193. protected _setPosition(value: Vector3): void;
  114194. /**
  114195. * 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.
  114196. * Returns the SpotLight.
  114197. */
  114198. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114199. protected _computeProjectionTextureViewLightMatrix(): void;
  114200. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114201. /**
  114202. * Main function for light texture projection matrix computing.
  114203. */
  114204. protected _computeProjectionTextureMatrix(): void;
  114205. protected _buildUniformLayout(): void;
  114206. private _computeAngleValues;
  114207. /**
  114208. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114209. * @param effect The effect to update
  114210. * @param lightIndex The index of the light in the effect to update
  114211. * @returns The spot light
  114212. */
  114213. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114214. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114215. /**
  114216. * Disposes the light and the associated resources.
  114217. */
  114218. dispose(): void;
  114219. /**
  114220. * Prepares the list of defines specific to the light type.
  114221. * @param defines the list of defines
  114222. * @param lightIndex defines the index of the light for the effect
  114223. */
  114224. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114225. }
  114226. }
  114227. declare module BABYLON {
  114228. /**
  114229. * Gizmo that enables viewing a light
  114230. */
  114231. export class LightGizmo extends Gizmo {
  114232. private _lightMesh;
  114233. private _material;
  114234. private cachedPosition;
  114235. private cachedForward;
  114236. /**
  114237. * Creates a LightGizmo
  114238. * @param gizmoLayer The utility layer the gizmo will be added to
  114239. */
  114240. constructor(gizmoLayer?: UtilityLayerRenderer);
  114241. private _light;
  114242. /**
  114243. * The light that the gizmo is attached to
  114244. */
  114245. light: Nullable<Light>;
  114246. /**
  114247. * Gets the material used to render the light gizmo
  114248. */
  114249. readonly material: StandardMaterial;
  114250. /**
  114251. * @hidden
  114252. * Updates the gizmo to match the attached mesh's position/rotation
  114253. */
  114254. protected _update(): void;
  114255. private static _Scale;
  114256. /**
  114257. * Creates the lines for a light mesh
  114258. */
  114259. private static _createLightLines;
  114260. /**
  114261. * Disposes of the light gizmo
  114262. */
  114263. dispose(): void;
  114264. private static _CreateHemisphericLightMesh;
  114265. private static _CreatePointLightMesh;
  114266. private static _CreateSpotLightMesh;
  114267. private static _CreateDirectionalLightMesh;
  114268. }
  114269. }
  114270. declare module BABYLON {
  114271. /** @hidden */
  114272. export var backgroundFragmentDeclaration: {
  114273. name: string;
  114274. shader: string;
  114275. };
  114276. }
  114277. declare module BABYLON {
  114278. /** @hidden */
  114279. export var backgroundUboDeclaration: {
  114280. name: string;
  114281. shader: string;
  114282. };
  114283. }
  114284. declare module BABYLON {
  114285. /** @hidden */
  114286. export var backgroundPixelShader: {
  114287. name: string;
  114288. shader: string;
  114289. };
  114290. }
  114291. declare module BABYLON {
  114292. /** @hidden */
  114293. export var backgroundVertexDeclaration: {
  114294. name: string;
  114295. shader: string;
  114296. };
  114297. }
  114298. declare module BABYLON {
  114299. /** @hidden */
  114300. export var backgroundVertexShader: {
  114301. name: string;
  114302. shader: string;
  114303. };
  114304. }
  114305. declare module BABYLON {
  114306. /**
  114307. * Background material used to create an efficient environement around your scene.
  114308. */
  114309. export class BackgroundMaterial extends PushMaterial {
  114310. /**
  114311. * Standard reflectance value at parallel view angle.
  114312. */
  114313. static StandardReflectance0: number;
  114314. /**
  114315. * Standard reflectance value at grazing angle.
  114316. */
  114317. static StandardReflectance90: number;
  114318. protected _primaryColor: Color3;
  114319. /**
  114320. * Key light Color (multiply against the environement texture)
  114321. */
  114322. primaryColor: Color3;
  114323. protected __perceptualColor: Nullable<Color3>;
  114324. /**
  114325. * Experimental Internal Use Only.
  114326. *
  114327. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114328. * This acts as a helper to set the primary color to a more "human friendly" value.
  114329. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114330. * output color as close as possible from the chosen value.
  114331. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114332. * part of lighting setup.)
  114333. */
  114334. _perceptualColor: Nullable<Color3>;
  114335. protected _primaryColorShadowLevel: float;
  114336. /**
  114337. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114338. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114339. */
  114340. primaryColorShadowLevel: float;
  114341. protected _primaryColorHighlightLevel: float;
  114342. /**
  114343. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114344. * The primary color is used at the level chosen to define what the white area would look.
  114345. */
  114346. primaryColorHighlightLevel: float;
  114347. protected _reflectionTexture: Nullable<BaseTexture>;
  114348. /**
  114349. * Reflection Texture used in the material.
  114350. * Should be author in a specific way for the best result (refer to the documentation).
  114351. */
  114352. reflectionTexture: Nullable<BaseTexture>;
  114353. protected _reflectionBlur: float;
  114354. /**
  114355. * Reflection Texture level of blur.
  114356. *
  114357. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114358. * texture twice.
  114359. */
  114360. reflectionBlur: float;
  114361. protected _diffuseTexture: Nullable<BaseTexture>;
  114362. /**
  114363. * Diffuse Texture used in the material.
  114364. * Should be author in a specific way for the best result (refer to the documentation).
  114365. */
  114366. diffuseTexture: Nullable<BaseTexture>;
  114367. protected _shadowLights: Nullable<IShadowLight[]>;
  114368. /**
  114369. * Specify the list of lights casting shadow on the material.
  114370. * All scene shadow lights will be included if null.
  114371. */
  114372. shadowLights: Nullable<IShadowLight[]>;
  114373. protected _shadowLevel: float;
  114374. /**
  114375. * Helps adjusting the shadow to a softer level if required.
  114376. * 0 means black shadows and 1 means no shadows.
  114377. */
  114378. shadowLevel: float;
  114379. protected _sceneCenter: Vector3;
  114380. /**
  114381. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114382. * It is usually zero but might be interesting to modify according to your setup.
  114383. */
  114384. sceneCenter: Vector3;
  114385. protected _opacityFresnel: boolean;
  114386. /**
  114387. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114388. * This helps ensuring a nice transition when the camera goes under the ground.
  114389. */
  114390. opacityFresnel: boolean;
  114391. protected _reflectionFresnel: boolean;
  114392. /**
  114393. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114394. * This helps adding a mirror texture on the ground.
  114395. */
  114396. reflectionFresnel: boolean;
  114397. protected _reflectionFalloffDistance: number;
  114398. /**
  114399. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114400. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114401. */
  114402. reflectionFalloffDistance: number;
  114403. protected _reflectionAmount: number;
  114404. /**
  114405. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114406. */
  114407. reflectionAmount: number;
  114408. protected _reflectionReflectance0: number;
  114409. /**
  114410. * This specifies the weight of the reflection at grazing angle.
  114411. */
  114412. reflectionReflectance0: number;
  114413. protected _reflectionReflectance90: number;
  114414. /**
  114415. * This specifies the weight of the reflection at a perpendicular point of view.
  114416. */
  114417. reflectionReflectance90: number;
  114418. /**
  114419. * Sets the reflection reflectance fresnel values according to the default standard
  114420. * empirically know to work well :-)
  114421. */
  114422. reflectionStandardFresnelWeight: number;
  114423. protected _useRGBColor: boolean;
  114424. /**
  114425. * Helps to directly use the maps channels instead of their level.
  114426. */
  114427. useRGBColor: boolean;
  114428. protected _enableNoise: boolean;
  114429. /**
  114430. * This helps reducing the banding effect that could occur on the background.
  114431. */
  114432. enableNoise: boolean;
  114433. /**
  114434. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114435. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114436. * Recommended to be keep at 1.0 except for special cases.
  114437. */
  114438. fovMultiplier: number;
  114439. private _fovMultiplier;
  114440. /**
  114441. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114442. */
  114443. useEquirectangularFOV: boolean;
  114444. private _maxSimultaneousLights;
  114445. /**
  114446. * Number of Simultaneous lights allowed on the material.
  114447. */
  114448. maxSimultaneousLights: int;
  114449. /**
  114450. * Default configuration related to image processing available in the Background Material.
  114451. */
  114452. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114453. /**
  114454. * Keep track of the image processing observer to allow dispose and replace.
  114455. */
  114456. private _imageProcessingObserver;
  114457. /**
  114458. * Attaches a new image processing configuration to the PBR Material.
  114459. * @param configuration (if null the scene configuration will be use)
  114460. */
  114461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114462. /**
  114463. * Gets the image processing configuration used either in this material.
  114464. */
  114465. /**
  114466. * Sets the Default image processing configuration used either in the this material.
  114467. *
  114468. * If sets to null, the scene one is in use.
  114469. */
  114470. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114471. /**
  114472. * Gets wether the color curves effect is enabled.
  114473. */
  114474. /**
  114475. * Sets wether the color curves effect is enabled.
  114476. */
  114477. cameraColorCurvesEnabled: boolean;
  114478. /**
  114479. * Gets wether the color grading effect is enabled.
  114480. */
  114481. /**
  114482. * Gets wether the color grading effect is enabled.
  114483. */
  114484. cameraColorGradingEnabled: boolean;
  114485. /**
  114486. * Gets wether tonemapping is enabled or not.
  114487. */
  114488. /**
  114489. * Sets wether tonemapping is enabled or not
  114490. */
  114491. cameraToneMappingEnabled: boolean;
  114492. /**
  114493. * The camera exposure used on this material.
  114494. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114495. * This corresponds to a photographic exposure.
  114496. */
  114497. /**
  114498. * The camera exposure used on this material.
  114499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114500. * This corresponds to a photographic exposure.
  114501. */
  114502. cameraExposure: float;
  114503. /**
  114504. * Gets The camera contrast used on this material.
  114505. */
  114506. /**
  114507. * Sets The camera contrast used on this material.
  114508. */
  114509. cameraContrast: float;
  114510. /**
  114511. * Gets the Color Grading 2D Lookup Texture.
  114512. */
  114513. /**
  114514. * Sets the Color Grading 2D Lookup Texture.
  114515. */
  114516. cameraColorGradingTexture: Nullable<BaseTexture>;
  114517. /**
  114518. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114519. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114520. * 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;
  114521. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114522. */
  114523. /**
  114524. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114525. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114526. * 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;
  114527. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114528. */
  114529. cameraColorCurves: Nullable<ColorCurves>;
  114530. /**
  114531. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114532. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114533. */
  114534. switchToBGR: boolean;
  114535. private _renderTargets;
  114536. private _reflectionControls;
  114537. private _white;
  114538. private _primaryShadowColor;
  114539. private _primaryHighlightColor;
  114540. /**
  114541. * Instantiates a Background Material in the given scene
  114542. * @param name The friendly name of the material
  114543. * @param scene The scene to add the material to
  114544. */
  114545. constructor(name: string, scene: Scene);
  114546. /**
  114547. * Gets a boolean indicating that current material needs to register RTT
  114548. */
  114549. readonly hasRenderTargetTextures: boolean;
  114550. /**
  114551. * The entire material has been created in order to prevent overdraw.
  114552. * @returns false
  114553. */
  114554. needAlphaTesting(): boolean;
  114555. /**
  114556. * The entire material has been created in order to prevent overdraw.
  114557. * @returns true if blending is enable
  114558. */
  114559. needAlphaBlending(): boolean;
  114560. /**
  114561. * Checks wether the material is ready to be rendered for a given mesh.
  114562. * @param mesh The mesh to render
  114563. * @param subMesh The submesh to check against
  114564. * @param useInstances Specify wether or not the material is used with instances
  114565. * @returns true if all the dependencies are ready (Textures, Effects...)
  114566. */
  114567. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114568. /**
  114569. * Compute the primary color according to the chosen perceptual color.
  114570. */
  114571. private _computePrimaryColorFromPerceptualColor;
  114572. /**
  114573. * Compute the highlights and shadow colors according to their chosen levels.
  114574. */
  114575. private _computePrimaryColors;
  114576. /**
  114577. * Build the uniform buffer used in the material.
  114578. */
  114579. buildUniformLayout(): void;
  114580. /**
  114581. * Unbind the material.
  114582. */
  114583. unbind(): void;
  114584. /**
  114585. * Bind only the world matrix to the material.
  114586. * @param world The world matrix to bind.
  114587. */
  114588. bindOnlyWorldMatrix(world: Matrix): void;
  114589. /**
  114590. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  114591. * @param world The world matrix to bind.
  114592. * @param subMesh The submesh to bind for.
  114593. */
  114594. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114595. /**
  114596. * Checks to see if a texture is used in the material.
  114597. * @param texture - Base texture to use.
  114598. * @returns - Boolean specifying if a texture is used in the material.
  114599. */
  114600. hasTexture(texture: BaseTexture): boolean;
  114601. /**
  114602. * Dispose the material.
  114603. * @param forceDisposeEffect Force disposal of the associated effect.
  114604. * @param forceDisposeTextures Force disposal of the associated textures.
  114605. */
  114606. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114607. /**
  114608. * Clones the material.
  114609. * @param name The cloned name.
  114610. * @returns The cloned material.
  114611. */
  114612. clone(name: string): BackgroundMaterial;
  114613. /**
  114614. * Serializes the current material to its JSON representation.
  114615. * @returns The JSON representation.
  114616. */
  114617. serialize(): any;
  114618. /**
  114619. * Gets the class name of the material
  114620. * @returns "BackgroundMaterial"
  114621. */
  114622. getClassName(): string;
  114623. /**
  114624. * Parse a JSON input to create back a background material.
  114625. * @param source The JSON data to parse
  114626. * @param scene The scene to create the parsed material in
  114627. * @param rootUrl The root url of the assets the material depends upon
  114628. * @returns the instantiated BackgroundMaterial.
  114629. */
  114630. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  114631. }
  114632. }
  114633. declare module BABYLON {
  114634. /**
  114635. * Represents the different options available during the creation of
  114636. * a Environment helper.
  114637. *
  114638. * This can control the default ground, skybox and image processing setup of your scene.
  114639. */
  114640. export interface IEnvironmentHelperOptions {
  114641. /**
  114642. * Specifies wether or not to create a ground.
  114643. * True by default.
  114644. */
  114645. createGround: boolean;
  114646. /**
  114647. * Specifies the ground size.
  114648. * 15 by default.
  114649. */
  114650. groundSize: number;
  114651. /**
  114652. * The texture used on the ground for the main color.
  114653. * Comes from the BabylonJS CDN by default.
  114654. *
  114655. * Remarks: Can be either a texture or a url.
  114656. */
  114657. groundTexture: string | BaseTexture;
  114658. /**
  114659. * The color mixed in the ground texture by default.
  114660. * BabylonJS clearColor by default.
  114661. */
  114662. groundColor: Color3;
  114663. /**
  114664. * Specifies the ground opacity.
  114665. * 1 by default.
  114666. */
  114667. groundOpacity: number;
  114668. /**
  114669. * Enables the ground to receive shadows.
  114670. * True by default.
  114671. */
  114672. enableGroundShadow: boolean;
  114673. /**
  114674. * Helps preventing the shadow to be fully black on the ground.
  114675. * 0.5 by default.
  114676. */
  114677. groundShadowLevel: number;
  114678. /**
  114679. * Creates a mirror texture attach to the ground.
  114680. * false by default.
  114681. */
  114682. enableGroundMirror: boolean;
  114683. /**
  114684. * Specifies the ground mirror size ratio.
  114685. * 0.3 by default as the default kernel is 64.
  114686. */
  114687. groundMirrorSizeRatio: number;
  114688. /**
  114689. * Specifies the ground mirror blur kernel size.
  114690. * 64 by default.
  114691. */
  114692. groundMirrorBlurKernel: number;
  114693. /**
  114694. * Specifies the ground mirror visibility amount.
  114695. * 1 by default
  114696. */
  114697. groundMirrorAmount: number;
  114698. /**
  114699. * Specifies the ground mirror reflectance weight.
  114700. * This uses the standard weight of the background material to setup the fresnel effect
  114701. * of the mirror.
  114702. * 1 by default.
  114703. */
  114704. groundMirrorFresnelWeight: number;
  114705. /**
  114706. * Specifies the ground mirror Falloff distance.
  114707. * This can helps reducing the size of the reflection.
  114708. * 0 by Default.
  114709. */
  114710. groundMirrorFallOffDistance: number;
  114711. /**
  114712. * Specifies the ground mirror texture type.
  114713. * Unsigned Int by Default.
  114714. */
  114715. groundMirrorTextureType: number;
  114716. /**
  114717. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  114718. * the shown objects.
  114719. */
  114720. groundYBias: number;
  114721. /**
  114722. * Specifies wether or not to create a skybox.
  114723. * True by default.
  114724. */
  114725. createSkybox: boolean;
  114726. /**
  114727. * Specifies the skybox size.
  114728. * 20 by default.
  114729. */
  114730. skyboxSize: number;
  114731. /**
  114732. * The texture used on the skybox for the main color.
  114733. * Comes from the BabylonJS CDN by default.
  114734. *
  114735. * Remarks: Can be either a texture or a url.
  114736. */
  114737. skyboxTexture: string | BaseTexture;
  114738. /**
  114739. * The color mixed in the skybox texture by default.
  114740. * BabylonJS clearColor by default.
  114741. */
  114742. skyboxColor: Color3;
  114743. /**
  114744. * The background rotation around the Y axis of the scene.
  114745. * This helps aligning the key lights of your scene with the background.
  114746. * 0 by default.
  114747. */
  114748. backgroundYRotation: number;
  114749. /**
  114750. * Compute automatically the size of the elements to best fit with the scene.
  114751. */
  114752. sizeAuto: boolean;
  114753. /**
  114754. * Default position of the rootMesh if autoSize is not true.
  114755. */
  114756. rootPosition: Vector3;
  114757. /**
  114758. * Sets up the image processing in the scene.
  114759. * true by default.
  114760. */
  114761. setupImageProcessing: boolean;
  114762. /**
  114763. * The texture used as your environment texture in the scene.
  114764. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  114765. *
  114766. * Remarks: Can be either a texture or a url.
  114767. */
  114768. environmentTexture: string | BaseTexture;
  114769. /**
  114770. * The value of the exposure to apply to the scene.
  114771. * 0.6 by default if setupImageProcessing is true.
  114772. */
  114773. cameraExposure: number;
  114774. /**
  114775. * The value of the contrast to apply to the scene.
  114776. * 1.6 by default if setupImageProcessing is true.
  114777. */
  114778. cameraContrast: number;
  114779. /**
  114780. * Specifies wether or not tonemapping should be enabled in the scene.
  114781. * true by default if setupImageProcessing is true.
  114782. */
  114783. toneMappingEnabled: boolean;
  114784. }
  114785. /**
  114786. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  114787. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  114788. * It also helps with the default setup of your imageProcessing configuration.
  114789. */
  114790. export class EnvironmentHelper {
  114791. /**
  114792. * Default ground texture URL.
  114793. */
  114794. private static _groundTextureCDNUrl;
  114795. /**
  114796. * Default skybox texture URL.
  114797. */
  114798. private static _skyboxTextureCDNUrl;
  114799. /**
  114800. * Default environment texture URL.
  114801. */
  114802. private static _environmentTextureCDNUrl;
  114803. /**
  114804. * Creates the default options for the helper.
  114805. */
  114806. private static _getDefaultOptions;
  114807. private _rootMesh;
  114808. /**
  114809. * Gets the root mesh created by the helper.
  114810. */
  114811. readonly rootMesh: Mesh;
  114812. private _skybox;
  114813. /**
  114814. * Gets the skybox created by the helper.
  114815. */
  114816. readonly skybox: Nullable<Mesh>;
  114817. private _skyboxTexture;
  114818. /**
  114819. * Gets the skybox texture created by the helper.
  114820. */
  114821. readonly skyboxTexture: Nullable<BaseTexture>;
  114822. private _skyboxMaterial;
  114823. /**
  114824. * Gets the skybox material created by the helper.
  114825. */
  114826. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  114827. private _ground;
  114828. /**
  114829. * Gets the ground mesh created by the helper.
  114830. */
  114831. readonly ground: Nullable<Mesh>;
  114832. private _groundTexture;
  114833. /**
  114834. * Gets the ground texture created by the helper.
  114835. */
  114836. readonly groundTexture: Nullable<BaseTexture>;
  114837. private _groundMirror;
  114838. /**
  114839. * Gets the ground mirror created by the helper.
  114840. */
  114841. readonly groundMirror: Nullable<MirrorTexture>;
  114842. /**
  114843. * Gets the ground mirror render list to helps pushing the meshes
  114844. * you wish in the ground reflection.
  114845. */
  114846. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  114847. private _groundMaterial;
  114848. /**
  114849. * Gets the ground material created by the helper.
  114850. */
  114851. readonly groundMaterial: Nullable<BackgroundMaterial>;
  114852. /**
  114853. * Stores the creation options.
  114854. */
  114855. private readonly _scene;
  114856. private _options;
  114857. /**
  114858. * This observable will be notified with any error during the creation of the environment,
  114859. * mainly texture creation errors.
  114860. */
  114861. onErrorObservable: Observable<{
  114862. message?: string;
  114863. exception?: any;
  114864. }>;
  114865. /**
  114866. * constructor
  114867. * @param options Defines the options we want to customize the helper
  114868. * @param scene The scene to add the material to
  114869. */
  114870. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  114871. /**
  114872. * Updates the background according to the new options
  114873. * @param options
  114874. */
  114875. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  114876. /**
  114877. * Sets the primary color of all the available elements.
  114878. * @param color the main color to affect to the ground and the background
  114879. */
  114880. setMainColor(color: Color3): void;
  114881. /**
  114882. * Setup the image processing according to the specified options.
  114883. */
  114884. private _setupImageProcessing;
  114885. /**
  114886. * Setup the environment texture according to the specified options.
  114887. */
  114888. private _setupEnvironmentTexture;
  114889. /**
  114890. * Setup the background according to the specified options.
  114891. */
  114892. private _setupBackground;
  114893. /**
  114894. * Get the scene sizes according to the setup.
  114895. */
  114896. private _getSceneSize;
  114897. /**
  114898. * Setup the ground according to the specified options.
  114899. */
  114900. private _setupGround;
  114901. /**
  114902. * Setup the ground material according to the specified options.
  114903. */
  114904. private _setupGroundMaterial;
  114905. /**
  114906. * Setup the ground diffuse texture according to the specified options.
  114907. */
  114908. private _setupGroundDiffuseTexture;
  114909. /**
  114910. * Setup the ground mirror texture according to the specified options.
  114911. */
  114912. private _setupGroundMirrorTexture;
  114913. /**
  114914. * Setup the ground to receive the mirror texture.
  114915. */
  114916. private _setupMirrorInGroundMaterial;
  114917. /**
  114918. * Setup the skybox according to the specified options.
  114919. */
  114920. private _setupSkybox;
  114921. /**
  114922. * Setup the skybox material according to the specified options.
  114923. */
  114924. private _setupSkyboxMaterial;
  114925. /**
  114926. * Setup the skybox reflection texture according to the specified options.
  114927. */
  114928. private _setupSkyboxReflectionTexture;
  114929. private _errorHandler;
  114930. /**
  114931. * Dispose all the elements created by the Helper.
  114932. */
  114933. dispose(): void;
  114934. }
  114935. }
  114936. declare module BABYLON {
  114937. /**
  114938. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  114939. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  114940. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  114941. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114942. */
  114943. export class PhotoDome extends TransformNode {
  114944. /**
  114945. * Define the image as a Monoscopic panoramic 360 image.
  114946. */
  114947. static readonly MODE_MONOSCOPIC: number;
  114948. /**
  114949. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114950. */
  114951. static readonly MODE_TOPBOTTOM: number;
  114952. /**
  114953. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114954. */
  114955. static readonly MODE_SIDEBYSIDE: number;
  114956. private _useDirectMapping;
  114957. /**
  114958. * The texture being displayed on the sphere
  114959. */
  114960. protected _photoTexture: Texture;
  114961. /**
  114962. * Gets or sets the texture being displayed on the sphere
  114963. */
  114964. photoTexture: Texture;
  114965. /**
  114966. * Observable raised when an error occured while loading the 360 image
  114967. */
  114968. onLoadErrorObservable: Observable<string>;
  114969. /**
  114970. * The skybox material
  114971. */
  114972. protected _material: BackgroundMaterial;
  114973. /**
  114974. * The surface used for the skybox
  114975. */
  114976. protected _mesh: Mesh;
  114977. /**
  114978. * Gets the mesh used for the skybox.
  114979. */
  114980. readonly mesh: Mesh;
  114981. /**
  114982. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114983. * Also see the options.resolution property.
  114984. */
  114985. fovMultiplier: number;
  114986. private _imageMode;
  114987. /**
  114988. * Gets or set the current video mode for the video. It can be:
  114989. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  114990. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114991. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114992. */
  114993. imageMode: number;
  114994. /**
  114995. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  114996. * @param name Element's name, child elements will append suffixes for their own names.
  114997. * @param urlsOfPhoto defines the url of the photo to display
  114998. * @param options defines an object containing optional or exposed sub element properties
  114999. * @param onError defines a callback called when an error occured while loading the texture
  115000. */
  115001. constructor(name: string, urlOfPhoto: string, options: {
  115002. resolution?: number;
  115003. size?: number;
  115004. useDirectMapping?: boolean;
  115005. faceForward?: boolean;
  115006. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115007. private _onBeforeCameraRenderObserver;
  115008. private _changeImageMode;
  115009. /**
  115010. * Releases resources associated with this node.
  115011. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115012. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115013. */
  115014. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115015. }
  115016. }
  115017. declare module BABYLON {
  115018. /**
  115019. * Class used to host RGBD texture specific utilities
  115020. */
  115021. export class RGBDTextureTools {
  115022. /**
  115023. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115024. * @param texture the texture to expand.
  115025. */
  115026. static ExpandRGBDTexture(texture: Texture): void;
  115027. }
  115028. }
  115029. declare module BABYLON {
  115030. /**
  115031. * Class used to host texture specific utilities
  115032. */
  115033. export class BRDFTextureTools {
  115034. /**
  115035. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115036. * @param scene defines the hosting scene
  115037. * @returns the environment BRDF texture
  115038. */
  115039. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115040. private static _environmentBRDFBase64Texture;
  115041. }
  115042. }
  115043. declare module BABYLON {
  115044. /**
  115045. * @hidden
  115046. */
  115047. export interface IMaterialClearCoatDefines {
  115048. CLEARCOAT: boolean;
  115049. CLEARCOAT_DEFAULTIOR: boolean;
  115050. CLEARCOAT_TEXTURE: boolean;
  115051. CLEARCOAT_TEXTUREDIRECTUV: number;
  115052. CLEARCOAT_BUMP: boolean;
  115053. CLEARCOAT_BUMPDIRECTUV: number;
  115054. CLEARCOAT_TINT: boolean;
  115055. CLEARCOAT_TINT_TEXTURE: boolean;
  115056. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115057. /** @hidden */
  115058. _areTexturesDirty: boolean;
  115059. }
  115060. /**
  115061. * Define the code related to the clear coat parameters of the pbr material.
  115062. */
  115063. export class PBRClearCoatConfiguration {
  115064. /**
  115065. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115066. * The default fits with a polyurethane material.
  115067. */
  115068. private static readonly _DefaultIndexOfRefraction;
  115069. private _isEnabled;
  115070. /**
  115071. * Defines if the clear coat is enabled in the material.
  115072. */
  115073. isEnabled: boolean;
  115074. /**
  115075. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115076. */
  115077. intensity: number;
  115078. /**
  115079. * Defines the clear coat layer roughness.
  115080. */
  115081. roughness: number;
  115082. private _indexOfRefraction;
  115083. /**
  115084. * Defines the index of refraction of the clear coat.
  115085. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115086. * The default fits with a polyurethane material.
  115087. * Changing the default value is more performance intensive.
  115088. */
  115089. indexOfRefraction: number;
  115090. private _texture;
  115091. /**
  115092. * Stores the clear coat values in a texture.
  115093. */
  115094. texture: Nullable<BaseTexture>;
  115095. private _bumpTexture;
  115096. /**
  115097. * Define the clear coat specific bump texture.
  115098. */
  115099. bumpTexture: Nullable<BaseTexture>;
  115100. private _isTintEnabled;
  115101. /**
  115102. * Defines if the clear coat tint is enabled in the material.
  115103. */
  115104. isTintEnabled: boolean;
  115105. /**
  115106. * Defines the clear coat tint of the material.
  115107. * This is only use if tint is enabled
  115108. */
  115109. tintColor: Color3;
  115110. /**
  115111. * Defines the distance at which the tint color should be found in the
  115112. * clear coat media.
  115113. * This is only use if tint is enabled
  115114. */
  115115. tintColorAtDistance: number;
  115116. /**
  115117. * Defines the clear coat layer thickness.
  115118. * This is only use if tint is enabled
  115119. */
  115120. tintThickness: number;
  115121. private _tintTexture;
  115122. /**
  115123. * Stores the clear tint values in a texture.
  115124. * rgb is tint
  115125. * a is a thickness factor
  115126. */
  115127. tintTexture: Nullable<BaseTexture>;
  115128. /** @hidden */
  115129. private _internalMarkAllSubMeshesAsTexturesDirty;
  115130. /** @hidden */
  115131. _markAllSubMeshesAsTexturesDirty(): void;
  115132. /**
  115133. * Instantiate a new istance of clear coat configuration.
  115134. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115135. */
  115136. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115137. /**
  115138. * Gets wehter the submesh is ready to be used or not.
  115139. * @param defines the list of "defines" to update.
  115140. * @param scene defines the scene the material belongs to.
  115141. * @param engine defines the engine the material belongs to.
  115142. * @param disableBumpMap defines wether the material disables bump or not.
  115143. * @returns - boolean indicating that the submesh is ready or not.
  115144. */
  115145. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115146. /**
  115147. * Checks to see if a texture is used in the material.
  115148. * @param defines the list of "defines" to update.
  115149. * @param scene defines the scene to the material belongs to.
  115150. */
  115151. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115152. /**
  115153. * Binds the material data.
  115154. * @param uniformBuffer defines the Uniform buffer to fill in.
  115155. * @param scene defines the scene the material belongs to.
  115156. * @param engine defines the engine the material belongs to.
  115157. * @param disableBumpMap defines wether the material disables bump or not.
  115158. * @param isFrozen defines wether the material is frozen or not.
  115159. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115160. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115161. */
  115162. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115163. /**
  115164. * Checks to see if a texture is used in the material.
  115165. * @param texture - Base texture to use.
  115166. * @returns - Boolean specifying if a texture is used in the material.
  115167. */
  115168. hasTexture(texture: BaseTexture): boolean;
  115169. /**
  115170. * Returns an array of the actively used textures.
  115171. * @param activeTextures Array of BaseTextures
  115172. */
  115173. getActiveTextures(activeTextures: BaseTexture[]): void;
  115174. /**
  115175. * Returns the animatable textures.
  115176. * @param animatables Array of animatable textures.
  115177. */
  115178. getAnimatables(animatables: IAnimatable[]): void;
  115179. /**
  115180. * Disposes the resources of the material.
  115181. * @param forceDisposeTextures - Forces the disposal of all textures.
  115182. */
  115183. dispose(forceDisposeTextures?: boolean): void;
  115184. /**
  115185. * Get the current class name of the texture useful for serialization or dynamic coding.
  115186. * @returns "PBRClearCoatConfiguration"
  115187. */
  115188. getClassName(): string;
  115189. /**
  115190. * Add fallbacks to the effect fallbacks list.
  115191. * @param defines defines the Base texture to use.
  115192. * @param fallbacks defines the current fallback list.
  115193. * @param currentRank defines the current fallback rank.
  115194. * @returns the new fallback rank.
  115195. */
  115196. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115197. /**
  115198. * Add the required uniforms to the current list.
  115199. * @param uniforms defines the current uniform list.
  115200. */
  115201. static AddUniforms(uniforms: string[]): void;
  115202. /**
  115203. * Add the required samplers to the current list.
  115204. * @param samplers defines the current sampler list.
  115205. */
  115206. static AddSamplers(samplers: string[]): void;
  115207. /**
  115208. * Add the required uniforms to the current buffer.
  115209. * @param uniformBuffer defines the current uniform buffer.
  115210. */
  115211. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115212. /**
  115213. * Makes a duplicate of the current configuration into another one.
  115214. * @param clearCoatConfiguration define the config where to copy the info
  115215. */
  115216. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115217. /**
  115218. * Serializes this clear coat configuration.
  115219. * @returns - An object with the serialized config.
  115220. */
  115221. serialize(): any;
  115222. /**
  115223. * Parses a anisotropy Configuration from a serialized object.
  115224. * @param source - Serialized object.
  115225. * @param scene Defines the scene we are parsing for
  115226. * @param rootUrl Defines the rootUrl to load from
  115227. */
  115228. parse(source: any, scene: Scene, rootUrl: string): void;
  115229. }
  115230. }
  115231. declare module BABYLON {
  115232. /**
  115233. * @hidden
  115234. */
  115235. export interface IMaterialAnisotropicDefines {
  115236. ANISOTROPIC: boolean;
  115237. ANISOTROPIC_TEXTURE: boolean;
  115238. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115239. MAINUV1: boolean;
  115240. _areTexturesDirty: boolean;
  115241. _needUVs: boolean;
  115242. }
  115243. /**
  115244. * Define the code related to the anisotropic parameters of the pbr material.
  115245. */
  115246. export class PBRAnisotropicConfiguration {
  115247. private _isEnabled;
  115248. /**
  115249. * Defines if the anisotropy is enabled in the material.
  115250. */
  115251. isEnabled: boolean;
  115252. /**
  115253. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115254. */
  115255. intensity: number;
  115256. /**
  115257. * Defines if the effect is along the tangents, bitangents or in between.
  115258. * By default, the effect is "strectching" the highlights along the tangents.
  115259. */
  115260. direction: Vector2;
  115261. private _texture;
  115262. /**
  115263. * Stores the anisotropy values in a texture.
  115264. * rg is direction (like normal from -1 to 1)
  115265. * b is a intensity
  115266. */
  115267. texture: Nullable<BaseTexture>;
  115268. /** @hidden */
  115269. private _internalMarkAllSubMeshesAsTexturesDirty;
  115270. /** @hidden */
  115271. _markAllSubMeshesAsTexturesDirty(): void;
  115272. /**
  115273. * Instantiate a new istance of anisotropy configuration.
  115274. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115275. */
  115276. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115277. /**
  115278. * Specifies that the submesh is ready to be used.
  115279. * @param defines the list of "defines" to update.
  115280. * @param scene defines the scene the material belongs to.
  115281. * @returns - boolean indicating that the submesh is ready or not.
  115282. */
  115283. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115284. /**
  115285. * Checks to see if a texture is used in the material.
  115286. * @param defines the list of "defines" to update.
  115287. * @param mesh the mesh we are preparing the defines for.
  115288. * @param scene defines the scene the material belongs to.
  115289. */
  115290. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115291. /**
  115292. * Binds the material data.
  115293. * @param uniformBuffer defines the Uniform buffer to fill in.
  115294. * @param scene defines the scene the material belongs to.
  115295. * @param isFrozen defines wether the material is frozen or not.
  115296. */
  115297. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115298. /**
  115299. * Checks to see if a texture is used in the material.
  115300. * @param texture - Base texture to use.
  115301. * @returns - Boolean specifying if a texture is used in the material.
  115302. */
  115303. hasTexture(texture: BaseTexture): boolean;
  115304. /**
  115305. * Returns an array of the actively used textures.
  115306. * @param activeTextures Array of BaseTextures
  115307. */
  115308. getActiveTextures(activeTextures: BaseTexture[]): void;
  115309. /**
  115310. * Returns the animatable textures.
  115311. * @param animatables Array of animatable textures.
  115312. */
  115313. getAnimatables(animatables: IAnimatable[]): void;
  115314. /**
  115315. * Disposes the resources of the material.
  115316. * @param forceDisposeTextures - Forces the disposal of all textures.
  115317. */
  115318. dispose(forceDisposeTextures?: boolean): void;
  115319. /**
  115320. * Get the current class name of the texture useful for serialization or dynamic coding.
  115321. * @returns "PBRAnisotropicConfiguration"
  115322. */
  115323. getClassName(): string;
  115324. /**
  115325. * Add fallbacks to the effect fallbacks list.
  115326. * @param defines defines the Base texture to use.
  115327. * @param fallbacks defines the current fallback list.
  115328. * @param currentRank defines the current fallback rank.
  115329. * @returns the new fallback rank.
  115330. */
  115331. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115332. /**
  115333. * Add the required uniforms to the current list.
  115334. * @param uniforms defines the current uniform list.
  115335. */
  115336. static AddUniforms(uniforms: string[]): void;
  115337. /**
  115338. * Add the required uniforms to the current buffer.
  115339. * @param uniformBuffer defines the current uniform buffer.
  115340. */
  115341. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115342. /**
  115343. * Add the required samplers to the current list.
  115344. * @param samplers defines the current sampler list.
  115345. */
  115346. static AddSamplers(samplers: string[]): void;
  115347. /**
  115348. * Makes a duplicate of the current configuration into another one.
  115349. * @param anisotropicConfiguration define the config where to copy the info
  115350. */
  115351. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115352. /**
  115353. * Serializes this anisotropy configuration.
  115354. * @returns - An object with the serialized config.
  115355. */
  115356. serialize(): any;
  115357. /**
  115358. * Parses a anisotropy Configuration from a serialized object.
  115359. * @param source - Serialized object.
  115360. * @param scene Defines the scene we are parsing for
  115361. * @param rootUrl Defines the rootUrl to load from
  115362. */
  115363. parse(source: any, scene: Scene, rootUrl: string): void;
  115364. }
  115365. }
  115366. declare module BABYLON {
  115367. /**
  115368. * @hidden
  115369. */
  115370. export interface IMaterialBRDFDefines {
  115371. BRDF_V_HEIGHT_CORRELATED: boolean;
  115372. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115373. SPHERICAL_HARMONICS: boolean;
  115374. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115375. /** @hidden */
  115376. _areMiscDirty: boolean;
  115377. }
  115378. /**
  115379. * Define the code related to the BRDF parameters of the pbr material.
  115380. */
  115381. export class PBRBRDFConfiguration {
  115382. /**
  115383. * Default value used for the energy conservation.
  115384. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115385. */
  115386. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115387. /**
  115388. * Default value used for the Smith Visibility Height Correlated mode.
  115389. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115390. */
  115391. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115392. /**
  115393. * Default value used for the IBL diffuse part.
  115394. * This can help switching back to the polynomials mode globally which is a tiny bit
  115395. * less GPU intensive at the drawback of a lower quality.
  115396. */
  115397. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115398. /**
  115399. * Default value used for activating energy conservation for the specular workflow.
  115400. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115401. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115402. */
  115403. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115404. private _useEnergyConservation;
  115405. /**
  115406. * Defines if the material uses energy conservation.
  115407. */
  115408. useEnergyConservation: boolean;
  115409. private _useSmithVisibilityHeightCorrelated;
  115410. /**
  115411. * LEGACY Mode set to false
  115412. * Defines if the material uses height smith correlated visibility term.
  115413. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115414. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115415. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115416. * Not relying on height correlated will also disable energy conservation.
  115417. */
  115418. useSmithVisibilityHeightCorrelated: boolean;
  115419. private _useSphericalHarmonics;
  115420. /**
  115421. * LEGACY Mode set to false
  115422. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115423. * diffuse part of the IBL.
  115424. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115425. * to the ground truth.
  115426. */
  115427. useSphericalHarmonics: boolean;
  115428. private _useSpecularGlossinessInputEnergyConservation;
  115429. /**
  115430. * Defines if the material uses energy conservation, when the specular workflow is active.
  115431. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115432. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115433. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115434. */
  115435. useSpecularGlossinessInputEnergyConservation: boolean;
  115436. /** @hidden */
  115437. private _internalMarkAllSubMeshesAsMiscDirty;
  115438. /** @hidden */
  115439. _markAllSubMeshesAsMiscDirty(): void;
  115440. /**
  115441. * Instantiate a new istance of clear coat configuration.
  115442. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115443. */
  115444. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115445. /**
  115446. * Checks to see if a texture is used in the material.
  115447. * @param defines the list of "defines" to update.
  115448. */
  115449. prepareDefines(defines: IMaterialBRDFDefines): void;
  115450. /**
  115451. * Get the current class name of the texture useful for serialization or dynamic coding.
  115452. * @returns "PBRClearCoatConfiguration"
  115453. */
  115454. getClassName(): string;
  115455. /**
  115456. * Makes a duplicate of the current configuration into another one.
  115457. * @param brdfConfiguration define the config where to copy the info
  115458. */
  115459. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115460. /**
  115461. * Serializes this BRDF configuration.
  115462. * @returns - An object with the serialized config.
  115463. */
  115464. serialize(): any;
  115465. /**
  115466. * Parses a anisotropy Configuration from a serialized object.
  115467. * @param source - Serialized object.
  115468. * @param scene Defines the scene we are parsing for
  115469. * @param rootUrl Defines the rootUrl to load from
  115470. */
  115471. parse(source: any, scene: Scene, rootUrl: string): void;
  115472. }
  115473. }
  115474. declare module BABYLON {
  115475. /**
  115476. * @hidden
  115477. */
  115478. export interface IMaterialSheenDefines {
  115479. SHEEN: boolean;
  115480. SHEEN_TEXTURE: boolean;
  115481. SHEEN_TEXTUREDIRECTUV: number;
  115482. SHEEN_LINKWITHALBEDO: boolean;
  115483. /** @hidden */
  115484. _areTexturesDirty: boolean;
  115485. }
  115486. /**
  115487. * Define the code related to the Sheen parameters of the pbr material.
  115488. */
  115489. export class PBRSheenConfiguration {
  115490. private _isEnabled;
  115491. /**
  115492. * Defines if the material uses sheen.
  115493. */
  115494. isEnabled: boolean;
  115495. private _linkSheenWithAlbedo;
  115496. /**
  115497. * Defines if the sheen is linked to the sheen color.
  115498. */
  115499. linkSheenWithAlbedo: boolean;
  115500. /**
  115501. * Defines the sheen intensity.
  115502. */
  115503. intensity: number;
  115504. /**
  115505. * Defines the sheen color.
  115506. */
  115507. color: Color3;
  115508. private _texture;
  115509. /**
  115510. * Stores the sheen tint values in a texture.
  115511. * rgb is tint
  115512. * a is a intensity
  115513. */
  115514. texture: Nullable<BaseTexture>;
  115515. /** @hidden */
  115516. private _internalMarkAllSubMeshesAsTexturesDirty;
  115517. /** @hidden */
  115518. _markAllSubMeshesAsTexturesDirty(): void;
  115519. /**
  115520. * Instantiate a new istance of clear coat configuration.
  115521. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115522. */
  115523. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115524. /**
  115525. * Specifies that the submesh is ready to be used.
  115526. * @param defines the list of "defines" to update.
  115527. * @param scene defines the scene the material belongs to.
  115528. * @returns - boolean indicating that the submesh is ready or not.
  115529. */
  115530. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115531. /**
  115532. * Checks to see if a texture is used in the material.
  115533. * @param defines the list of "defines" to update.
  115534. * @param scene defines the scene the material belongs to.
  115535. */
  115536. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115537. /**
  115538. * Binds the material data.
  115539. * @param uniformBuffer defines the Uniform buffer to fill in.
  115540. * @param scene defines the scene the material belongs to.
  115541. * @param isFrozen defines wether the material is frozen or not.
  115542. */
  115543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115544. /**
  115545. * Checks to see if a texture is used in the material.
  115546. * @param texture - Base texture to use.
  115547. * @returns - Boolean specifying if a texture is used in the material.
  115548. */
  115549. hasTexture(texture: BaseTexture): boolean;
  115550. /**
  115551. * Returns an array of the actively used textures.
  115552. * @param activeTextures Array of BaseTextures
  115553. */
  115554. getActiveTextures(activeTextures: BaseTexture[]): void;
  115555. /**
  115556. * Returns the animatable textures.
  115557. * @param animatables Array of animatable textures.
  115558. */
  115559. getAnimatables(animatables: IAnimatable[]): void;
  115560. /**
  115561. * Disposes the resources of the material.
  115562. * @param forceDisposeTextures - Forces the disposal of all textures.
  115563. */
  115564. dispose(forceDisposeTextures?: boolean): void;
  115565. /**
  115566. * Get the current class name of the texture useful for serialization or dynamic coding.
  115567. * @returns "PBRSheenConfiguration"
  115568. */
  115569. getClassName(): string;
  115570. /**
  115571. * Add fallbacks to the effect fallbacks list.
  115572. * @param defines defines the Base texture to use.
  115573. * @param fallbacks defines the current fallback list.
  115574. * @param currentRank defines the current fallback rank.
  115575. * @returns the new fallback rank.
  115576. */
  115577. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115578. /**
  115579. * Add the required uniforms to the current list.
  115580. * @param uniforms defines the current uniform list.
  115581. */
  115582. static AddUniforms(uniforms: string[]): void;
  115583. /**
  115584. * Add the required uniforms to the current buffer.
  115585. * @param uniformBuffer defines the current uniform buffer.
  115586. */
  115587. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115588. /**
  115589. * Add the required samplers to the current list.
  115590. * @param samplers defines the current sampler list.
  115591. */
  115592. static AddSamplers(samplers: string[]): void;
  115593. /**
  115594. * Makes a duplicate of the current configuration into another one.
  115595. * @param sheenConfiguration define the config where to copy the info
  115596. */
  115597. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  115598. /**
  115599. * Serializes this BRDF configuration.
  115600. * @returns - An object with the serialized config.
  115601. */
  115602. serialize(): any;
  115603. /**
  115604. * Parses a anisotropy Configuration from a serialized object.
  115605. * @param source - Serialized object.
  115606. * @param scene Defines the scene we are parsing for
  115607. * @param rootUrl Defines the rootUrl to load from
  115608. */
  115609. parse(source: any, scene: Scene, rootUrl: string): void;
  115610. }
  115611. }
  115612. declare module BABYLON {
  115613. /**
  115614. * @hidden
  115615. */
  115616. export interface IMaterialSubSurfaceDefines {
  115617. SUBSURFACE: boolean;
  115618. SS_REFRACTION: boolean;
  115619. SS_TRANSLUCENCY: boolean;
  115620. SS_SCATERRING: boolean;
  115621. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115622. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115623. SS_REFRACTIONMAP_3D: boolean;
  115624. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115625. SS_LODINREFRACTIONALPHA: boolean;
  115626. SS_GAMMAREFRACTION: boolean;
  115627. SS_RGBDREFRACTION: boolean;
  115628. SS_LINEARSPECULARREFRACTION: boolean;
  115629. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115630. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115631. /** @hidden */
  115632. _areTexturesDirty: boolean;
  115633. }
  115634. /**
  115635. * Define the code related to the sub surface parameters of the pbr material.
  115636. */
  115637. export class PBRSubSurfaceConfiguration {
  115638. private _isRefractionEnabled;
  115639. /**
  115640. * Defines if the refraction is enabled in the material.
  115641. */
  115642. isRefractionEnabled: boolean;
  115643. private _isTranslucencyEnabled;
  115644. /**
  115645. * Defines if the translucency is enabled in the material.
  115646. */
  115647. isTranslucencyEnabled: boolean;
  115648. private _isScatteringEnabled;
  115649. /**
  115650. * Defines the refraction intensity of the material.
  115651. * The refraction when enabled replaces the Diffuse part of the material.
  115652. * The intensity helps transitionning between diffuse and refraction.
  115653. */
  115654. refractionIntensity: number;
  115655. /**
  115656. * Defines the translucency intensity of the material.
  115657. * When translucency has been enabled, this defines how much of the "translucency"
  115658. * is addded to the diffuse part of the material.
  115659. */
  115660. translucencyIntensity: number;
  115661. /**
  115662. * Defines the scattering intensity of the material.
  115663. * When scattering has been enabled, this defines how much of the "scattered light"
  115664. * is addded to the diffuse part of the material.
  115665. */
  115666. scatteringIntensity: number;
  115667. private _thicknessTexture;
  115668. /**
  115669. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115670. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115671. * 0 would mean minimumThickness
  115672. * 1 would mean maximumThickness
  115673. * The other channels might be use as a mask to vary the different effects intensity.
  115674. */
  115675. thicknessTexture: Nullable<BaseTexture>;
  115676. private _refractionTexture;
  115677. /**
  115678. * Defines the texture to use for refraction.
  115679. */
  115680. refractionTexture: Nullable<BaseTexture>;
  115681. private _indexOfRefraction;
  115682. /**
  115683. * Defines the index of refraction used in the material.
  115684. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  115685. */
  115686. indexOfRefraction: number;
  115687. private _invertRefractionY;
  115688. /**
  115689. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115690. */
  115691. invertRefractionY: boolean;
  115692. private _linkRefractionWithTransparency;
  115693. /**
  115694. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115695. * Materials half opaque for instance using refraction could benefit from this control.
  115696. */
  115697. linkRefractionWithTransparency: boolean;
  115698. /**
  115699. * Defines the minimum thickness stored in the thickness map.
  115700. * If no thickness map is defined, this value will be used to simulate thickness.
  115701. */
  115702. minimumThickness: number;
  115703. /**
  115704. * Defines the maximum thickness stored in the thickness map.
  115705. */
  115706. maximumThickness: number;
  115707. /**
  115708. * Defines the volume tint of the material.
  115709. * This is used for both translucency and scattering.
  115710. */
  115711. tintColor: Color3;
  115712. /**
  115713. * Defines the distance at which the tint color should be found in the media.
  115714. * This is used for refraction only.
  115715. */
  115716. tintColorAtDistance: number;
  115717. /**
  115718. * Defines how far each channel transmit through the media.
  115719. * It is defined as a color to simplify it selection.
  115720. */
  115721. diffusionDistance: Color3;
  115722. private _useMaskFromThicknessTexture;
  115723. /**
  115724. * Stores the intensity of the different subsurface effects in the thickness texture.
  115725. * * the green channel is the translucency intensity.
  115726. * * the blue channel is the scattering intensity.
  115727. * * the alpha channel is the refraction intensity.
  115728. */
  115729. useMaskFromThicknessTexture: boolean;
  115730. /** @hidden */
  115731. private _internalMarkAllSubMeshesAsTexturesDirty;
  115732. /** @hidden */
  115733. _markAllSubMeshesAsTexturesDirty(): void;
  115734. /**
  115735. * Instantiate a new istance of sub surface configuration.
  115736. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115737. */
  115738. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115739. /**
  115740. * Gets wehter the submesh is ready to be used or not.
  115741. * @param defines the list of "defines" to update.
  115742. * @param scene defines the scene the material belongs to.
  115743. * @returns - boolean indicating that the submesh is ready or not.
  115744. */
  115745. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  115746. /**
  115747. * Checks to see if a texture is used in the material.
  115748. * @param defines the list of "defines" to update.
  115749. * @param scene defines the scene to the material belongs to.
  115750. */
  115751. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  115752. /**
  115753. * Binds the material data.
  115754. * @param uniformBuffer defines the Uniform buffer to fill in.
  115755. * @param scene defines the scene the material belongs to.
  115756. * @param engine defines the engine the material belongs to.
  115757. * @param isFrozen defines wether the material is frozen or not.
  115758. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  115759. */
  115760. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  115761. /**
  115762. * Unbinds the material from the mesh.
  115763. * @param activeEffect defines the effect that should be unbound from.
  115764. * @returns true if unbound, otherwise false
  115765. */
  115766. unbind(activeEffect: Effect): boolean;
  115767. /**
  115768. * Returns the texture used for refraction or null if none is used.
  115769. * @param scene defines the scene the material belongs to.
  115770. * @returns - Refraction texture if present. If no refraction texture and refraction
  115771. * is linked with transparency, returns environment texture. Otherwise, returns null.
  115772. */
  115773. private _getRefractionTexture;
  115774. /**
  115775. * Returns true if alpha blending should be disabled.
  115776. */
  115777. readonly disableAlphaBlending: boolean;
  115778. /**
  115779. * Fills the list of render target textures.
  115780. * @param renderTargets the list of render targets to update
  115781. */
  115782. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  115783. /**
  115784. * Checks to see if a texture is used in the material.
  115785. * @param texture - Base texture to use.
  115786. * @returns - Boolean specifying if a texture is used in the material.
  115787. */
  115788. hasTexture(texture: BaseTexture): boolean;
  115789. /**
  115790. * Gets a boolean indicating that current material needs to register RTT
  115791. * @returns true if this uses a render target otherwise false.
  115792. */
  115793. hasRenderTargetTextures(): boolean;
  115794. /**
  115795. * Returns an array of the actively used textures.
  115796. * @param activeTextures Array of BaseTextures
  115797. */
  115798. getActiveTextures(activeTextures: BaseTexture[]): void;
  115799. /**
  115800. * Returns the animatable textures.
  115801. * @param animatables Array of animatable textures.
  115802. */
  115803. getAnimatables(animatables: IAnimatable[]): void;
  115804. /**
  115805. * Disposes the resources of the material.
  115806. * @param forceDisposeTextures - Forces the disposal of all textures.
  115807. */
  115808. dispose(forceDisposeTextures?: boolean): void;
  115809. /**
  115810. * Get the current class name of the texture useful for serialization or dynamic coding.
  115811. * @returns "PBRSubSurfaceConfiguration"
  115812. */
  115813. getClassName(): string;
  115814. /**
  115815. * Add fallbacks to the effect fallbacks list.
  115816. * @param defines defines the Base texture to use.
  115817. * @param fallbacks defines the current fallback list.
  115818. * @param currentRank defines the current fallback rank.
  115819. * @returns the new fallback rank.
  115820. */
  115821. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115822. /**
  115823. * Add the required uniforms to the current list.
  115824. * @param uniforms defines the current uniform list.
  115825. */
  115826. static AddUniforms(uniforms: string[]): void;
  115827. /**
  115828. * Add the required samplers to the current list.
  115829. * @param samplers defines the current sampler list.
  115830. */
  115831. static AddSamplers(samplers: string[]): void;
  115832. /**
  115833. * Add the required uniforms to the current buffer.
  115834. * @param uniformBuffer defines the current uniform buffer.
  115835. */
  115836. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115837. /**
  115838. * Makes a duplicate of the current configuration into another one.
  115839. * @param configuration define the config where to copy the info
  115840. */
  115841. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  115842. /**
  115843. * Serializes this Sub Surface configuration.
  115844. * @returns - An object with the serialized config.
  115845. */
  115846. serialize(): any;
  115847. /**
  115848. * Parses a anisotropy Configuration from a serialized object.
  115849. * @param source - Serialized object.
  115850. * @param scene Defines the scene we are parsing for
  115851. * @param rootUrl Defines the rootUrl to load from
  115852. */
  115853. parse(source: any, scene: Scene, rootUrl: string): void;
  115854. }
  115855. }
  115856. declare module BABYLON {
  115857. /** @hidden */
  115858. export var pbrFragmentDeclaration: {
  115859. name: string;
  115860. shader: string;
  115861. };
  115862. }
  115863. declare module BABYLON {
  115864. /** @hidden */
  115865. export var pbrUboDeclaration: {
  115866. name: string;
  115867. shader: string;
  115868. };
  115869. }
  115870. declare module BABYLON {
  115871. /** @hidden */
  115872. export var pbrFragmentExtraDeclaration: {
  115873. name: string;
  115874. shader: string;
  115875. };
  115876. }
  115877. declare module BABYLON {
  115878. /** @hidden */
  115879. export var pbrFragmentSamplersDeclaration: {
  115880. name: string;
  115881. shader: string;
  115882. };
  115883. }
  115884. declare module BABYLON {
  115885. /** @hidden */
  115886. export var pbrHelperFunctions: {
  115887. name: string;
  115888. shader: string;
  115889. };
  115890. }
  115891. declare module BABYLON {
  115892. /** @hidden */
  115893. export var harmonicsFunctions: {
  115894. name: string;
  115895. shader: string;
  115896. };
  115897. }
  115898. declare module BABYLON {
  115899. /** @hidden */
  115900. export var pbrDirectLightingSetupFunctions: {
  115901. name: string;
  115902. shader: string;
  115903. };
  115904. }
  115905. declare module BABYLON {
  115906. /** @hidden */
  115907. export var pbrDirectLightingFalloffFunctions: {
  115908. name: string;
  115909. shader: string;
  115910. };
  115911. }
  115912. declare module BABYLON {
  115913. /** @hidden */
  115914. export var pbrBRDFFunctions: {
  115915. name: string;
  115916. shader: string;
  115917. };
  115918. }
  115919. declare module BABYLON {
  115920. /** @hidden */
  115921. export var pbrDirectLightingFunctions: {
  115922. name: string;
  115923. shader: string;
  115924. };
  115925. }
  115926. declare module BABYLON {
  115927. /** @hidden */
  115928. export var pbrIBLFunctions: {
  115929. name: string;
  115930. shader: string;
  115931. };
  115932. }
  115933. declare module BABYLON {
  115934. /** @hidden */
  115935. export var pbrDebug: {
  115936. name: string;
  115937. shader: string;
  115938. };
  115939. }
  115940. declare module BABYLON {
  115941. /** @hidden */
  115942. export var pbrPixelShader: {
  115943. name: string;
  115944. shader: string;
  115945. };
  115946. }
  115947. declare module BABYLON {
  115948. /** @hidden */
  115949. export var pbrVertexDeclaration: {
  115950. name: string;
  115951. shader: string;
  115952. };
  115953. }
  115954. declare module BABYLON {
  115955. /** @hidden */
  115956. export var pbrVertexShader: {
  115957. name: string;
  115958. shader: string;
  115959. };
  115960. }
  115961. declare module BABYLON {
  115962. /**
  115963. * Manages the defines for the PBR Material.
  115964. * @hidden
  115965. */
  115966. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  115967. PBR: boolean;
  115968. MAINUV1: boolean;
  115969. MAINUV2: boolean;
  115970. UV1: boolean;
  115971. UV2: boolean;
  115972. ALBEDO: boolean;
  115973. ALBEDODIRECTUV: number;
  115974. VERTEXCOLOR: boolean;
  115975. AMBIENT: boolean;
  115976. AMBIENTDIRECTUV: number;
  115977. AMBIENTINGRAYSCALE: boolean;
  115978. OPACITY: boolean;
  115979. VERTEXALPHA: boolean;
  115980. OPACITYDIRECTUV: number;
  115981. OPACITYRGB: boolean;
  115982. ALPHATEST: boolean;
  115983. DEPTHPREPASS: boolean;
  115984. ALPHABLEND: boolean;
  115985. ALPHAFROMALBEDO: boolean;
  115986. ALPHATESTVALUE: string;
  115987. SPECULAROVERALPHA: boolean;
  115988. RADIANCEOVERALPHA: boolean;
  115989. ALPHAFRESNEL: boolean;
  115990. LINEARALPHAFRESNEL: boolean;
  115991. PREMULTIPLYALPHA: boolean;
  115992. EMISSIVE: boolean;
  115993. EMISSIVEDIRECTUV: number;
  115994. REFLECTIVITY: boolean;
  115995. REFLECTIVITYDIRECTUV: number;
  115996. SPECULARTERM: boolean;
  115997. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  115998. MICROSURFACEAUTOMATIC: boolean;
  115999. LODBASEDMICROSFURACE: boolean;
  116000. MICROSURFACEMAP: boolean;
  116001. MICROSURFACEMAPDIRECTUV: number;
  116002. METALLICWORKFLOW: boolean;
  116003. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116004. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116005. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116006. AOSTOREINMETALMAPRED: boolean;
  116007. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116008. ENVIRONMENTBRDF: boolean;
  116009. ENVIRONMENTBRDF_RGBD: boolean;
  116010. NORMAL: boolean;
  116011. TANGENT: boolean;
  116012. BUMP: boolean;
  116013. BUMPDIRECTUV: number;
  116014. OBJECTSPACE_NORMALMAP: boolean;
  116015. PARALLAX: boolean;
  116016. PARALLAXOCCLUSION: boolean;
  116017. NORMALXYSCALE: boolean;
  116018. LIGHTMAP: boolean;
  116019. LIGHTMAPDIRECTUV: number;
  116020. USELIGHTMAPASSHADOWMAP: boolean;
  116021. GAMMALIGHTMAP: boolean;
  116022. RGBDLIGHTMAP: boolean;
  116023. REFLECTION: boolean;
  116024. REFLECTIONMAP_3D: boolean;
  116025. REFLECTIONMAP_SPHERICAL: boolean;
  116026. REFLECTIONMAP_PLANAR: boolean;
  116027. REFLECTIONMAP_CUBIC: boolean;
  116028. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116029. REFLECTIONMAP_PROJECTION: boolean;
  116030. REFLECTIONMAP_SKYBOX: boolean;
  116031. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116032. REFLECTIONMAP_EXPLICIT: boolean;
  116033. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116034. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116035. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116036. INVERTCUBICMAP: boolean;
  116037. USESPHERICALFROMREFLECTIONMAP: boolean;
  116038. USEIRRADIANCEMAP: boolean;
  116039. SPHERICAL_HARMONICS: boolean;
  116040. USESPHERICALINVERTEX: boolean;
  116041. REFLECTIONMAP_OPPOSITEZ: boolean;
  116042. LODINREFLECTIONALPHA: boolean;
  116043. GAMMAREFLECTION: boolean;
  116044. RGBDREFLECTION: boolean;
  116045. LINEARSPECULARREFLECTION: boolean;
  116046. RADIANCEOCCLUSION: boolean;
  116047. HORIZONOCCLUSION: boolean;
  116048. INSTANCES: boolean;
  116049. NUM_BONE_INFLUENCERS: number;
  116050. BonesPerMesh: number;
  116051. BONETEXTURE: boolean;
  116052. NONUNIFORMSCALING: boolean;
  116053. MORPHTARGETS: boolean;
  116054. MORPHTARGETS_NORMAL: boolean;
  116055. MORPHTARGETS_TANGENT: boolean;
  116056. MORPHTARGETS_UV: boolean;
  116057. NUM_MORPH_INFLUENCERS: number;
  116058. IMAGEPROCESSING: boolean;
  116059. VIGNETTE: boolean;
  116060. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116061. VIGNETTEBLENDMODEOPAQUE: boolean;
  116062. TONEMAPPING: boolean;
  116063. TONEMAPPING_ACES: boolean;
  116064. CONTRAST: boolean;
  116065. COLORCURVES: boolean;
  116066. COLORGRADING: boolean;
  116067. COLORGRADING3D: boolean;
  116068. SAMPLER3DGREENDEPTH: boolean;
  116069. SAMPLER3DBGRMAP: boolean;
  116070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116071. EXPOSURE: boolean;
  116072. MULTIVIEW: boolean;
  116073. USEPHYSICALLIGHTFALLOFF: boolean;
  116074. USEGLTFLIGHTFALLOFF: boolean;
  116075. TWOSIDEDLIGHTING: boolean;
  116076. SHADOWFLOAT: boolean;
  116077. CLIPPLANE: boolean;
  116078. CLIPPLANE2: boolean;
  116079. CLIPPLANE3: boolean;
  116080. CLIPPLANE4: boolean;
  116081. POINTSIZE: boolean;
  116082. FOG: boolean;
  116083. LOGARITHMICDEPTH: boolean;
  116084. FORCENORMALFORWARD: boolean;
  116085. SPECULARAA: boolean;
  116086. CLEARCOAT: boolean;
  116087. CLEARCOAT_DEFAULTIOR: boolean;
  116088. CLEARCOAT_TEXTURE: boolean;
  116089. CLEARCOAT_TEXTUREDIRECTUV: number;
  116090. CLEARCOAT_BUMP: boolean;
  116091. CLEARCOAT_BUMPDIRECTUV: number;
  116092. CLEARCOAT_TINT: boolean;
  116093. CLEARCOAT_TINT_TEXTURE: boolean;
  116094. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116095. ANISOTROPIC: boolean;
  116096. ANISOTROPIC_TEXTURE: boolean;
  116097. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116098. BRDF_V_HEIGHT_CORRELATED: boolean;
  116099. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116100. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116101. SHEEN: boolean;
  116102. SHEEN_TEXTURE: boolean;
  116103. SHEEN_TEXTUREDIRECTUV: number;
  116104. SHEEN_LINKWITHALBEDO: boolean;
  116105. SUBSURFACE: boolean;
  116106. SS_REFRACTION: boolean;
  116107. SS_TRANSLUCENCY: boolean;
  116108. SS_SCATERRING: boolean;
  116109. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116110. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116111. SS_REFRACTIONMAP_3D: boolean;
  116112. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116113. SS_LODINREFRACTIONALPHA: boolean;
  116114. SS_GAMMAREFRACTION: boolean;
  116115. SS_RGBDREFRACTION: boolean;
  116116. SS_LINEARSPECULARREFRACTION: boolean;
  116117. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116118. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116119. UNLIT: boolean;
  116120. DEBUGMODE: number;
  116121. /**
  116122. * Initializes the PBR Material defines.
  116123. */
  116124. constructor();
  116125. /**
  116126. * Resets the PBR Material defines.
  116127. */
  116128. reset(): void;
  116129. }
  116130. /**
  116131. * The Physically based material base class of BJS.
  116132. *
  116133. * This offers the main features of a standard PBR material.
  116134. * For more information, please refer to the documentation :
  116135. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116136. */
  116137. export abstract class PBRBaseMaterial extends PushMaterial {
  116138. /**
  116139. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116140. */
  116141. static readonly PBRMATERIAL_OPAQUE: number;
  116142. /**
  116143. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116144. */
  116145. static readonly PBRMATERIAL_ALPHATEST: number;
  116146. /**
  116147. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116148. */
  116149. static readonly PBRMATERIAL_ALPHABLEND: number;
  116150. /**
  116151. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116152. * They are also discarded below the alpha cutoff threshold to improve performances.
  116153. */
  116154. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116155. /**
  116156. * Defines the default value of how much AO map is occluding the analytical lights
  116157. * (point spot...).
  116158. */
  116159. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116160. /**
  116161. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116162. */
  116163. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116164. /**
  116165. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116166. * to enhance interoperability with other engines.
  116167. */
  116168. static readonly LIGHTFALLOFF_GLTF: number;
  116169. /**
  116170. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116171. * to enhance interoperability with other materials.
  116172. */
  116173. static readonly LIGHTFALLOFF_STANDARD: number;
  116174. /**
  116175. * Intensity of the direct lights e.g. the four lights available in your scene.
  116176. * This impacts both the direct diffuse and specular highlights.
  116177. */
  116178. protected _directIntensity: number;
  116179. /**
  116180. * Intensity of the emissive part of the material.
  116181. * This helps controlling the emissive effect without modifying the emissive color.
  116182. */
  116183. protected _emissiveIntensity: number;
  116184. /**
  116185. * Intensity of the environment e.g. how much the environment will light the object
  116186. * either through harmonics for rough material or through the refelction for shiny ones.
  116187. */
  116188. protected _environmentIntensity: number;
  116189. /**
  116190. * This is a special control allowing the reduction of the specular highlights coming from the
  116191. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116192. */
  116193. protected _specularIntensity: number;
  116194. /**
  116195. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116196. */
  116197. private _lightingInfos;
  116198. /**
  116199. * Debug Control allowing disabling the bump map on this material.
  116200. */
  116201. protected _disableBumpMap: boolean;
  116202. /**
  116203. * AKA Diffuse Texture in standard nomenclature.
  116204. */
  116205. protected _albedoTexture: Nullable<BaseTexture>;
  116206. /**
  116207. * AKA Occlusion Texture in other nomenclature.
  116208. */
  116209. protected _ambientTexture: Nullable<BaseTexture>;
  116210. /**
  116211. * AKA Occlusion Texture Intensity in other nomenclature.
  116212. */
  116213. protected _ambientTextureStrength: number;
  116214. /**
  116215. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116216. * 1 means it completely occludes it
  116217. * 0 mean it has no impact
  116218. */
  116219. protected _ambientTextureImpactOnAnalyticalLights: number;
  116220. /**
  116221. * Stores the alpha values in a texture.
  116222. */
  116223. protected _opacityTexture: Nullable<BaseTexture>;
  116224. /**
  116225. * Stores the reflection values in a texture.
  116226. */
  116227. protected _reflectionTexture: Nullable<BaseTexture>;
  116228. /**
  116229. * Stores the emissive values in a texture.
  116230. */
  116231. protected _emissiveTexture: Nullable<BaseTexture>;
  116232. /**
  116233. * AKA Specular texture in other nomenclature.
  116234. */
  116235. protected _reflectivityTexture: Nullable<BaseTexture>;
  116236. /**
  116237. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116238. */
  116239. protected _metallicTexture: Nullable<BaseTexture>;
  116240. /**
  116241. * Specifies the metallic scalar of the metallic/roughness workflow.
  116242. * Can also be used to scale the metalness values of the metallic texture.
  116243. */
  116244. protected _metallic: Nullable<number>;
  116245. /**
  116246. * Specifies the roughness scalar of the metallic/roughness workflow.
  116247. * Can also be used to scale the roughness values of the metallic texture.
  116248. */
  116249. protected _roughness: Nullable<number>;
  116250. /**
  116251. * Specifies the an F0 factor to help configuring the material F0.
  116252. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116253. * to 0.5 the previously hard coded value stays the same.
  116254. * Can also be used to scale the F0 values of the metallic texture.
  116255. */
  116256. protected _metallicF0Factor: number;
  116257. /**
  116258. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116259. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116260. * your expectation as it multiplies with the texture data.
  116261. */
  116262. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116263. /**
  116264. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116265. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116266. */
  116267. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116268. /**
  116269. * Stores surface normal data used to displace a mesh in a texture.
  116270. */
  116271. protected _bumpTexture: Nullable<BaseTexture>;
  116272. /**
  116273. * Stores the pre-calculated light information of a mesh in a texture.
  116274. */
  116275. protected _lightmapTexture: Nullable<BaseTexture>;
  116276. /**
  116277. * The color of a material in ambient lighting.
  116278. */
  116279. protected _ambientColor: Color3;
  116280. /**
  116281. * AKA Diffuse Color in other nomenclature.
  116282. */
  116283. protected _albedoColor: Color3;
  116284. /**
  116285. * AKA Specular Color in other nomenclature.
  116286. */
  116287. protected _reflectivityColor: Color3;
  116288. /**
  116289. * The color applied when light is reflected from a material.
  116290. */
  116291. protected _reflectionColor: Color3;
  116292. /**
  116293. * The color applied when light is emitted from a material.
  116294. */
  116295. protected _emissiveColor: Color3;
  116296. /**
  116297. * AKA Glossiness in other nomenclature.
  116298. */
  116299. protected _microSurface: number;
  116300. /**
  116301. * Specifies that the material will use the light map as a show map.
  116302. */
  116303. protected _useLightmapAsShadowmap: boolean;
  116304. /**
  116305. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116306. * makes the reflect vector face the model (under horizon).
  116307. */
  116308. protected _useHorizonOcclusion: boolean;
  116309. /**
  116310. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116311. * too much the area relying on ambient texture to define their ambient occlusion.
  116312. */
  116313. protected _useRadianceOcclusion: boolean;
  116314. /**
  116315. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116316. */
  116317. protected _useAlphaFromAlbedoTexture: boolean;
  116318. /**
  116319. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116320. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116321. */
  116322. protected _useSpecularOverAlpha: boolean;
  116323. /**
  116324. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116325. */
  116326. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116327. /**
  116328. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116329. */
  116330. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116331. /**
  116332. * Specifies if the metallic texture contains the roughness information in its green channel.
  116333. */
  116334. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116335. /**
  116336. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116337. */
  116338. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116339. /**
  116340. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116341. */
  116342. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116343. /**
  116344. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116345. */
  116346. protected _useAmbientInGrayScale: boolean;
  116347. /**
  116348. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116349. * The material will try to infer what glossiness each pixel should be.
  116350. */
  116351. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116352. /**
  116353. * Defines the falloff type used in this material.
  116354. * It by default is Physical.
  116355. */
  116356. protected _lightFalloff: number;
  116357. /**
  116358. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116359. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116360. */
  116361. protected _useRadianceOverAlpha: boolean;
  116362. /**
  116363. * Allows using an object space normal map (instead of tangent space).
  116364. */
  116365. protected _useObjectSpaceNormalMap: boolean;
  116366. /**
  116367. * Allows using the bump map in parallax mode.
  116368. */
  116369. protected _useParallax: boolean;
  116370. /**
  116371. * Allows using the bump map in parallax occlusion mode.
  116372. */
  116373. protected _useParallaxOcclusion: boolean;
  116374. /**
  116375. * Controls the scale bias of the parallax mode.
  116376. */
  116377. protected _parallaxScaleBias: number;
  116378. /**
  116379. * If sets to true, disables all the lights affecting the material.
  116380. */
  116381. protected _disableLighting: boolean;
  116382. /**
  116383. * Number of Simultaneous lights allowed on the material.
  116384. */
  116385. protected _maxSimultaneousLights: number;
  116386. /**
  116387. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116388. */
  116389. protected _invertNormalMapX: boolean;
  116390. /**
  116391. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116392. */
  116393. protected _invertNormalMapY: boolean;
  116394. /**
  116395. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116396. */
  116397. protected _twoSidedLighting: boolean;
  116398. /**
  116399. * Defines the alpha limits in alpha test mode.
  116400. */
  116401. protected _alphaCutOff: number;
  116402. /**
  116403. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116404. */
  116405. protected _forceAlphaTest: boolean;
  116406. /**
  116407. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116408. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116409. */
  116410. protected _useAlphaFresnel: boolean;
  116411. /**
  116412. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116413. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116414. */
  116415. protected _useLinearAlphaFresnel: boolean;
  116416. /**
  116417. * The transparency mode of the material.
  116418. */
  116419. protected _transparencyMode: Nullable<number>;
  116420. /**
  116421. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116422. * from cos thetav and roughness:
  116423. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116424. */
  116425. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116426. /**
  116427. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116428. */
  116429. protected _forceIrradianceInFragment: boolean;
  116430. /**
  116431. * Force normal to face away from face.
  116432. */
  116433. protected _forceNormalForward: boolean;
  116434. /**
  116435. * Enables specular anti aliasing in the PBR shader.
  116436. * It will both interacts on the Geometry for analytical and IBL lighting.
  116437. * It also prefilter the roughness map based on the bump values.
  116438. */
  116439. protected _enableSpecularAntiAliasing: boolean;
  116440. /**
  116441. * Default configuration related to image processing available in the PBR Material.
  116442. */
  116443. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116444. /**
  116445. * Keep track of the image processing observer to allow dispose and replace.
  116446. */
  116447. private _imageProcessingObserver;
  116448. /**
  116449. * Attaches a new image processing configuration to the PBR Material.
  116450. * @param configuration
  116451. */
  116452. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116453. /**
  116454. * Stores the available render targets.
  116455. */
  116456. private _renderTargets;
  116457. /**
  116458. * Sets the global ambient color for the material used in lighting calculations.
  116459. */
  116460. private _globalAmbientColor;
  116461. /**
  116462. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116463. */
  116464. private _useLogarithmicDepth;
  116465. /**
  116466. * If set to true, no lighting calculations will be applied.
  116467. */
  116468. private _unlit;
  116469. private _debugMode;
  116470. /**
  116471. * @hidden
  116472. * This is reserved for the inspector.
  116473. * Defines the material debug mode.
  116474. * It helps seeing only some components of the material while troubleshooting.
  116475. */
  116476. debugMode: number;
  116477. /**
  116478. * @hidden
  116479. * This is reserved for the inspector.
  116480. * Specify from where on screen the debug mode should start.
  116481. * The value goes from -1 (full screen) to 1 (not visible)
  116482. * It helps with side by side comparison against the final render
  116483. * This defaults to -1
  116484. */
  116485. private debugLimit;
  116486. /**
  116487. * @hidden
  116488. * This is reserved for the inspector.
  116489. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116490. * You can use the factor to better multiply the final value.
  116491. */
  116492. private debugFactor;
  116493. /**
  116494. * Defines the clear coat layer parameters for the material.
  116495. */
  116496. readonly clearCoat: PBRClearCoatConfiguration;
  116497. /**
  116498. * Defines the anisotropic parameters for the material.
  116499. */
  116500. readonly anisotropy: PBRAnisotropicConfiguration;
  116501. /**
  116502. * Defines the BRDF parameters for the material.
  116503. */
  116504. readonly brdf: PBRBRDFConfiguration;
  116505. /**
  116506. * Defines the Sheen parameters for the material.
  116507. */
  116508. readonly sheen: PBRSheenConfiguration;
  116509. /**
  116510. * Defines the SubSurface parameters for the material.
  116511. */
  116512. readonly subSurface: PBRSubSurfaceConfiguration;
  116513. /**
  116514. * Custom callback helping to override the default shader used in the material.
  116515. */
  116516. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116517. protected _rebuildInParallel: boolean;
  116518. /**
  116519. * Instantiates a new PBRMaterial instance.
  116520. *
  116521. * @param name The material name
  116522. * @param scene The scene the material will be use in.
  116523. */
  116524. constructor(name: string, scene: Scene);
  116525. /**
  116526. * Gets a boolean indicating that current material needs to register RTT
  116527. */
  116528. readonly hasRenderTargetTextures: boolean;
  116529. /**
  116530. * Gets the name of the material class.
  116531. */
  116532. getClassName(): string;
  116533. /**
  116534. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116535. */
  116536. /**
  116537. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116538. */
  116539. useLogarithmicDepth: boolean;
  116540. /**
  116541. * Gets the current transparency mode.
  116542. */
  116543. /**
  116544. * Sets the transparency mode of the material.
  116545. *
  116546. * | Value | Type | Description |
  116547. * | ----- | ----------------------------------- | ----------- |
  116548. * | 0 | OPAQUE | |
  116549. * | 1 | ALPHATEST | |
  116550. * | 2 | ALPHABLEND | |
  116551. * | 3 | ALPHATESTANDBLEND | |
  116552. *
  116553. */
  116554. transparencyMode: Nullable<number>;
  116555. /**
  116556. * Returns true if alpha blending should be disabled.
  116557. */
  116558. private readonly _disableAlphaBlending;
  116559. /**
  116560. * Specifies whether or not this material should be rendered in alpha blend mode.
  116561. */
  116562. needAlphaBlending(): boolean;
  116563. /**
  116564. * Specifies if the mesh will require alpha blending.
  116565. * @param mesh - BJS mesh.
  116566. */
  116567. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116568. /**
  116569. * Specifies whether or not this material should be rendered in alpha test mode.
  116570. */
  116571. needAlphaTesting(): boolean;
  116572. /**
  116573. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116574. */
  116575. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116576. /**
  116577. * Gets the texture used for the alpha test.
  116578. */
  116579. getAlphaTestTexture(): Nullable<BaseTexture>;
  116580. /**
  116581. * Specifies that the submesh is ready to be used.
  116582. * @param mesh - BJS mesh.
  116583. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  116584. * @param useInstances - Specifies that instances should be used.
  116585. * @returns - boolean indicating that the submesh is ready or not.
  116586. */
  116587. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116588. /**
  116589. * Specifies if the material uses metallic roughness workflow.
  116590. * @returns boolean specifiying if the material uses metallic roughness workflow.
  116591. */
  116592. isMetallicWorkflow(): boolean;
  116593. private _prepareEffect;
  116594. private _prepareDefines;
  116595. /**
  116596. * Force shader compilation
  116597. */
  116598. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  116599. /**
  116600. * Initializes the uniform buffer layout for the shader.
  116601. */
  116602. buildUniformLayout(): void;
  116603. /**
  116604. * Unbinds the material from the mesh
  116605. */
  116606. unbind(): void;
  116607. /**
  116608. * Binds the submesh data.
  116609. * @param world - The world matrix.
  116610. * @param mesh - The BJS mesh.
  116611. * @param subMesh - A submesh of the BJS mesh.
  116612. */
  116613. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116614. /**
  116615. * Returns the animatable textures.
  116616. * @returns - Array of animatable textures.
  116617. */
  116618. getAnimatables(): IAnimatable[];
  116619. /**
  116620. * Returns the texture used for reflections.
  116621. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  116622. */
  116623. private _getReflectionTexture;
  116624. /**
  116625. * Returns an array of the actively used textures.
  116626. * @returns - Array of BaseTextures
  116627. */
  116628. getActiveTextures(): BaseTexture[];
  116629. /**
  116630. * Checks to see if a texture is used in the material.
  116631. * @param texture - Base texture to use.
  116632. * @returns - Boolean specifying if a texture is used in the material.
  116633. */
  116634. hasTexture(texture: BaseTexture): boolean;
  116635. /**
  116636. * Disposes the resources of the material.
  116637. * @param forceDisposeEffect - Forces the disposal of effects.
  116638. * @param forceDisposeTextures - Forces the disposal of all textures.
  116639. */
  116640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116641. }
  116642. }
  116643. declare module BABYLON {
  116644. /**
  116645. * The Physically based material of BJS.
  116646. *
  116647. * This offers the main features of a standard PBR material.
  116648. * For more information, please refer to the documentation :
  116649. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116650. */
  116651. export class PBRMaterial extends PBRBaseMaterial {
  116652. /**
  116653. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116654. */
  116655. static readonly PBRMATERIAL_OPAQUE: number;
  116656. /**
  116657. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116658. */
  116659. static readonly PBRMATERIAL_ALPHATEST: number;
  116660. /**
  116661. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116662. */
  116663. static readonly PBRMATERIAL_ALPHABLEND: number;
  116664. /**
  116665. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116666. * They are also discarded below the alpha cutoff threshold to improve performances.
  116667. */
  116668. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116669. /**
  116670. * Defines the default value of how much AO map is occluding the analytical lights
  116671. * (point spot...).
  116672. */
  116673. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116674. /**
  116675. * Intensity of the direct lights e.g. the four lights available in your scene.
  116676. * This impacts both the direct diffuse and specular highlights.
  116677. */
  116678. directIntensity: number;
  116679. /**
  116680. * Intensity of the emissive part of the material.
  116681. * This helps controlling the emissive effect without modifying the emissive color.
  116682. */
  116683. emissiveIntensity: number;
  116684. /**
  116685. * Intensity of the environment e.g. how much the environment will light the object
  116686. * either through harmonics for rough material or through the refelction for shiny ones.
  116687. */
  116688. environmentIntensity: number;
  116689. /**
  116690. * This is a special control allowing the reduction of the specular highlights coming from the
  116691. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116692. */
  116693. specularIntensity: number;
  116694. /**
  116695. * Debug Control allowing disabling the bump map on this material.
  116696. */
  116697. disableBumpMap: boolean;
  116698. /**
  116699. * AKA Diffuse Texture in standard nomenclature.
  116700. */
  116701. albedoTexture: BaseTexture;
  116702. /**
  116703. * AKA Occlusion Texture in other nomenclature.
  116704. */
  116705. ambientTexture: BaseTexture;
  116706. /**
  116707. * AKA Occlusion Texture Intensity in other nomenclature.
  116708. */
  116709. ambientTextureStrength: number;
  116710. /**
  116711. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116712. * 1 means it completely occludes it
  116713. * 0 mean it has no impact
  116714. */
  116715. ambientTextureImpactOnAnalyticalLights: number;
  116716. /**
  116717. * Stores the alpha values in a texture.
  116718. */
  116719. opacityTexture: BaseTexture;
  116720. /**
  116721. * Stores the reflection values in a texture.
  116722. */
  116723. reflectionTexture: Nullable<BaseTexture>;
  116724. /**
  116725. * Stores the emissive values in a texture.
  116726. */
  116727. emissiveTexture: BaseTexture;
  116728. /**
  116729. * AKA Specular texture in other nomenclature.
  116730. */
  116731. reflectivityTexture: BaseTexture;
  116732. /**
  116733. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116734. */
  116735. metallicTexture: BaseTexture;
  116736. /**
  116737. * Specifies the metallic scalar of the metallic/roughness workflow.
  116738. * Can also be used to scale the metalness values of the metallic texture.
  116739. */
  116740. metallic: Nullable<number>;
  116741. /**
  116742. * Specifies the roughness scalar of the metallic/roughness workflow.
  116743. * Can also be used to scale the roughness values of the metallic texture.
  116744. */
  116745. roughness: Nullable<number>;
  116746. /**
  116747. * Specifies the an F0 factor to help configuring the material F0.
  116748. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116749. * to 0.5 the previously hard coded value stays the same.
  116750. * Can also be used to scale the F0 values of the metallic texture.
  116751. */
  116752. metallicF0Factor: number;
  116753. /**
  116754. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116755. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116756. * your expectation as it multiplies with the texture data.
  116757. */
  116758. useMetallicF0FactorFromMetallicTexture: boolean;
  116759. /**
  116760. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116761. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116762. */
  116763. microSurfaceTexture: BaseTexture;
  116764. /**
  116765. * Stores surface normal data used to displace a mesh in a texture.
  116766. */
  116767. bumpTexture: BaseTexture;
  116768. /**
  116769. * Stores the pre-calculated light information of a mesh in a texture.
  116770. */
  116771. lightmapTexture: BaseTexture;
  116772. /**
  116773. * Stores the refracted light information in a texture.
  116774. */
  116775. refractionTexture: Nullable<BaseTexture>;
  116776. /**
  116777. * The color of a material in ambient lighting.
  116778. */
  116779. ambientColor: Color3;
  116780. /**
  116781. * AKA Diffuse Color in other nomenclature.
  116782. */
  116783. albedoColor: Color3;
  116784. /**
  116785. * AKA Specular Color in other nomenclature.
  116786. */
  116787. reflectivityColor: Color3;
  116788. /**
  116789. * The color reflected from the material.
  116790. */
  116791. reflectionColor: Color3;
  116792. /**
  116793. * The color emitted from the material.
  116794. */
  116795. emissiveColor: Color3;
  116796. /**
  116797. * AKA Glossiness in other nomenclature.
  116798. */
  116799. microSurface: number;
  116800. /**
  116801. * source material index of refraction (IOR)' / 'destination material IOR.
  116802. */
  116803. indexOfRefraction: number;
  116804. /**
  116805. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116806. */
  116807. invertRefractionY: boolean;
  116808. /**
  116809. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116810. * Materials half opaque for instance using refraction could benefit from this control.
  116811. */
  116812. linkRefractionWithTransparency: boolean;
  116813. /**
  116814. * If true, the light map contains occlusion information instead of lighting info.
  116815. */
  116816. useLightmapAsShadowmap: boolean;
  116817. /**
  116818. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116819. */
  116820. useAlphaFromAlbedoTexture: boolean;
  116821. /**
  116822. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116823. */
  116824. forceAlphaTest: boolean;
  116825. /**
  116826. * Defines the alpha limits in alpha test mode.
  116827. */
  116828. alphaCutOff: number;
  116829. /**
  116830. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  116831. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116832. */
  116833. useSpecularOverAlpha: boolean;
  116834. /**
  116835. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116836. */
  116837. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116838. /**
  116839. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116840. */
  116841. useRoughnessFromMetallicTextureAlpha: boolean;
  116842. /**
  116843. * Specifies if the metallic texture contains the roughness information in its green channel.
  116844. */
  116845. useRoughnessFromMetallicTextureGreen: boolean;
  116846. /**
  116847. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116848. */
  116849. useMetallnessFromMetallicTextureBlue: boolean;
  116850. /**
  116851. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116852. */
  116853. useAmbientOcclusionFromMetallicTextureRed: boolean;
  116854. /**
  116855. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116856. */
  116857. useAmbientInGrayScale: boolean;
  116858. /**
  116859. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116860. * The material will try to infer what glossiness each pixel should be.
  116861. */
  116862. useAutoMicroSurfaceFromReflectivityMap: boolean;
  116863. /**
  116864. * BJS is using an harcoded light falloff based on a manually sets up range.
  116865. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116866. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116867. */
  116868. /**
  116869. * BJS is using an harcoded light falloff based on a manually sets up range.
  116870. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116871. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116872. */
  116873. usePhysicalLightFalloff: boolean;
  116874. /**
  116875. * In order to support the falloff compatibility with gltf, a special mode has been added
  116876. * to reproduce the gltf light falloff.
  116877. */
  116878. /**
  116879. * In order to support the falloff compatibility with gltf, a special mode has been added
  116880. * to reproduce the gltf light falloff.
  116881. */
  116882. useGLTFLightFalloff: boolean;
  116883. /**
  116884. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116885. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116886. */
  116887. useRadianceOverAlpha: boolean;
  116888. /**
  116889. * Allows using an object space normal map (instead of tangent space).
  116890. */
  116891. useObjectSpaceNormalMap: boolean;
  116892. /**
  116893. * Allows using the bump map in parallax mode.
  116894. */
  116895. useParallax: boolean;
  116896. /**
  116897. * Allows using the bump map in parallax occlusion mode.
  116898. */
  116899. useParallaxOcclusion: boolean;
  116900. /**
  116901. * Controls the scale bias of the parallax mode.
  116902. */
  116903. parallaxScaleBias: number;
  116904. /**
  116905. * If sets to true, disables all the lights affecting the material.
  116906. */
  116907. disableLighting: boolean;
  116908. /**
  116909. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116910. */
  116911. forceIrradianceInFragment: boolean;
  116912. /**
  116913. * Number of Simultaneous lights allowed on the material.
  116914. */
  116915. maxSimultaneousLights: number;
  116916. /**
  116917. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116918. */
  116919. invertNormalMapX: boolean;
  116920. /**
  116921. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116922. */
  116923. invertNormalMapY: boolean;
  116924. /**
  116925. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116926. */
  116927. twoSidedLighting: boolean;
  116928. /**
  116929. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116930. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116931. */
  116932. useAlphaFresnel: boolean;
  116933. /**
  116934. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116935. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116936. */
  116937. useLinearAlphaFresnel: boolean;
  116938. /**
  116939. * Let user defines the brdf lookup texture used for IBL.
  116940. * A default 8bit version is embedded but you could point at :
  116941. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  116942. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116943. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  116944. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116945. */
  116946. environmentBRDFTexture: Nullable<BaseTexture>;
  116947. /**
  116948. * Force normal to face away from face.
  116949. */
  116950. forceNormalForward: boolean;
  116951. /**
  116952. * Enables specular anti aliasing in the PBR shader.
  116953. * It will both interacts on the Geometry for analytical and IBL lighting.
  116954. * It also prefilter the roughness map based on the bump values.
  116955. */
  116956. enableSpecularAntiAliasing: boolean;
  116957. /**
  116958. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116959. * makes the reflect vector face the model (under horizon).
  116960. */
  116961. useHorizonOcclusion: boolean;
  116962. /**
  116963. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116964. * too much the area relying on ambient texture to define their ambient occlusion.
  116965. */
  116966. useRadianceOcclusion: boolean;
  116967. /**
  116968. * If set to true, no lighting calculations will be applied.
  116969. */
  116970. unlit: boolean;
  116971. /**
  116972. * Gets the image processing configuration used either in this material.
  116973. */
  116974. /**
  116975. * Sets the Default image processing configuration used either in the this material.
  116976. *
  116977. * If sets to null, the scene one is in use.
  116978. */
  116979. imageProcessingConfiguration: ImageProcessingConfiguration;
  116980. /**
  116981. * Gets wether the color curves effect is enabled.
  116982. */
  116983. /**
  116984. * Sets wether the color curves effect is enabled.
  116985. */
  116986. cameraColorCurvesEnabled: boolean;
  116987. /**
  116988. * Gets wether the color grading effect is enabled.
  116989. */
  116990. /**
  116991. * Gets wether the color grading effect is enabled.
  116992. */
  116993. cameraColorGradingEnabled: boolean;
  116994. /**
  116995. * Gets wether tonemapping is enabled or not.
  116996. */
  116997. /**
  116998. * Sets wether tonemapping is enabled or not
  116999. */
  117000. cameraToneMappingEnabled: boolean;
  117001. /**
  117002. * The camera exposure used on this material.
  117003. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117004. * This corresponds to a photographic exposure.
  117005. */
  117006. /**
  117007. * The camera exposure used on this material.
  117008. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117009. * This corresponds to a photographic exposure.
  117010. */
  117011. cameraExposure: number;
  117012. /**
  117013. * Gets The camera contrast used on this material.
  117014. */
  117015. /**
  117016. * Sets The camera contrast used on this material.
  117017. */
  117018. cameraContrast: number;
  117019. /**
  117020. * Gets the Color Grading 2D Lookup Texture.
  117021. */
  117022. /**
  117023. * Sets the Color Grading 2D Lookup Texture.
  117024. */
  117025. cameraColorGradingTexture: Nullable<BaseTexture>;
  117026. /**
  117027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117029. * 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;
  117030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117031. */
  117032. /**
  117033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117035. * 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;
  117036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117037. */
  117038. cameraColorCurves: Nullable<ColorCurves>;
  117039. /**
  117040. * Instantiates a new PBRMaterial instance.
  117041. *
  117042. * @param name The material name
  117043. * @param scene The scene the material will be use in.
  117044. */
  117045. constructor(name: string, scene: Scene);
  117046. /**
  117047. * Returns the name of this material class.
  117048. */
  117049. getClassName(): string;
  117050. /**
  117051. * Makes a duplicate of the current material.
  117052. * @param name - name to use for the new material.
  117053. */
  117054. clone(name: string): PBRMaterial;
  117055. /**
  117056. * Serializes this PBR Material.
  117057. * @returns - An object with the serialized material.
  117058. */
  117059. serialize(): any;
  117060. /**
  117061. * Parses a PBR Material from a serialized object.
  117062. * @param source - Serialized object.
  117063. * @param scene - BJS scene instance.
  117064. * @param rootUrl - url for the scene object
  117065. * @returns - PBRMaterial
  117066. */
  117067. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117068. }
  117069. }
  117070. declare module BABYLON {
  117071. /**
  117072. * Direct draw surface info
  117073. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117074. */
  117075. export interface DDSInfo {
  117076. /**
  117077. * Width of the texture
  117078. */
  117079. width: number;
  117080. /**
  117081. * Width of the texture
  117082. */
  117083. height: number;
  117084. /**
  117085. * Number of Mipmaps for the texture
  117086. * @see https://en.wikipedia.org/wiki/Mipmap
  117087. */
  117088. mipmapCount: number;
  117089. /**
  117090. * If the textures format is a known fourCC format
  117091. * @see https://www.fourcc.org/
  117092. */
  117093. isFourCC: boolean;
  117094. /**
  117095. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117096. */
  117097. isRGB: boolean;
  117098. /**
  117099. * If the texture is a lumincance format
  117100. */
  117101. isLuminance: boolean;
  117102. /**
  117103. * If this is a cube texture
  117104. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117105. */
  117106. isCube: boolean;
  117107. /**
  117108. * If the texture is a compressed format eg. FOURCC_DXT1
  117109. */
  117110. isCompressed: boolean;
  117111. /**
  117112. * The dxgiFormat of the texture
  117113. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117114. */
  117115. dxgiFormat: number;
  117116. /**
  117117. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117118. */
  117119. textureType: number;
  117120. /**
  117121. * Sphericle polynomial created for the dds texture
  117122. */
  117123. sphericalPolynomial?: SphericalPolynomial;
  117124. }
  117125. /**
  117126. * Class used to provide DDS decompression tools
  117127. */
  117128. export class DDSTools {
  117129. /**
  117130. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117131. */
  117132. static StoreLODInAlphaChannel: boolean;
  117133. /**
  117134. * Gets DDS information from an array buffer
  117135. * @param arrayBuffer defines the array buffer to read data from
  117136. * @returns the DDS information
  117137. */
  117138. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117139. private static _FloatView;
  117140. private static _Int32View;
  117141. private static _ToHalfFloat;
  117142. private static _FromHalfFloat;
  117143. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117144. private static _GetHalfFloatRGBAArrayBuffer;
  117145. private static _GetFloatRGBAArrayBuffer;
  117146. private static _GetFloatAsUIntRGBAArrayBuffer;
  117147. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117148. private static _GetRGBAArrayBuffer;
  117149. private static _ExtractLongWordOrder;
  117150. private static _GetRGBArrayBuffer;
  117151. private static _GetLuminanceArrayBuffer;
  117152. /**
  117153. * Uploads DDS Levels to a Babylon Texture
  117154. * @hidden
  117155. */
  117156. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117157. }
  117158. interface ThinEngine {
  117159. /**
  117160. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117161. * @param rootUrl defines the url where the file to load is located
  117162. * @param scene defines the current scene
  117163. * @param lodScale defines scale to apply to the mip map selection
  117164. * @param lodOffset defines offset to apply to the mip map selection
  117165. * @param onLoad defines an optional callback raised when the texture is loaded
  117166. * @param onError defines an optional callback raised if there is an issue to load the texture
  117167. * @param format defines the format of the data
  117168. * @param forcedExtension defines the extension to use to pick the right loader
  117169. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117170. * @returns the cube texture as an InternalTexture
  117171. */
  117172. 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;
  117173. }
  117174. }
  117175. declare module BABYLON {
  117176. /**
  117177. * Implementation of the DDS Texture Loader.
  117178. * @hidden
  117179. */
  117180. export class _DDSTextureLoader implements IInternalTextureLoader {
  117181. /**
  117182. * Defines wether the loader supports cascade loading the different faces.
  117183. */
  117184. readonly supportCascades: boolean;
  117185. /**
  117186. * This returns if the loader support the current file information.
  117187. * @param extension defines the file extension of the file being loaded
  117188. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117189. * @param fallback defines the fallback internal texture if any
  117190. * @param isBase64 defines whether the texture is encoded as a base64
  117191. * @param isBuffer defines whether the texture data are stored as a buffer
  117192. * @returns true if the loader can load the specified file
  117193. */
  117194. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117195. /**
  117196. * Transform the url before loading if required.
  117197. * @param rootUrl the url of the texture
  117198. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117199. * @returns the transformed texture
  117200. */
  117201. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117202. /**
  117203. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117204. * @param rootUrl the url of the texture
  117205. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117206. * @returns the fallback texture
  117207. */
  117208. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117209. /**
  117210. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117211. * @param data contains the texture data
  117212. * @param texture defines the BabylonJS internal texture
  117213. * @param createPolynomials will be true if polynomials have been requested
  117214. * @param onLoad defines the callback to trigger once the texture is ready
  117215. * @param onError defines the callback to trigger in case of error
  117216. */
  117217. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117218. /**
  117219. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117220. * @param data contains the texture data
  117221. * @param texture defines the BabylonJS internal texture
  117222. * @param callback defines the method to call once ready to upload
  117223. */
  117224. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117225. }
  117226. }
  117227. declare module BABYLON {
  117228. /**
  117229. * Implementation of the ENV Texture Loader.
  117230. * @hidden
  117231. */
  117232. export class _ENVTextureLoader implements IInternalTextureLoader {
  117233. /**
  117234. * Defines wether the loader supports cascade loading the different faces.
  117235. */
  117236. readonly supportCascades: boolean;
  117237. /**
  117238. * This returns if the loader support the current file information.
  117239. * @param extension defines the file extension of the file being loaded
  117240. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117241. * @param fallback defines the fallback internal texture if any
  117242. * @param isBase64 defines whether the texture is encoded as a base64
  117243. * @param isBuffer defines whether the texture data are stored as a buffer
  117244. * @returns true if the loader can load the specified file
  117245. */
  117246. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117247. /**
  117248. * Transform the url before loading if required.
  117249. * @param rootUrl the url of the texture
  117250. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117251. * @returns the transformed texture
  117252. */
  117253. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117254. /**
  117255. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117256. * @param rootUrl the url of the texture
  117257. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117258. * @returns the fallback texture
  117259. */
  117260. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117261. /**
  117262. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117263. * @param data contains the texture data
  117264. * @param texture defines the BabylonJS internal texture
  117265. * @param createPolynomials will be true if polynomials have been requested
  117266. * @param onLoad defines the callback to trigger once the texture is ready
  117267. * @param onError defines the callback to trigger in case of error
  117268. */
  117269. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117270. /**
  117271. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117272. * @param data contains the texture data
  117273. * @param texture defines the BabylonJS internal texture
  117274. * @param callback defines the method to call once ready to upload
  117275. */
  117276. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117277. }
  117278. }
  117279. declare module BABYLON {
  117280. /**
  117281. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117282. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117283. */
  117284. export class KhronosTextureContainer {
  117285. /** contents of the KTX container file */
  117286. arrayBuffer: any;
  117287. private static HEADER_LEN;
  117288. private static COMPRESSED_2D;
  117289. private static COMPRESSED_3D;
  117290. private static TEX_2D;
  117291. private static TEX_3D;
  117292. /**
  117293. * Gets the openGL type
  117294. */
  117295. glType: number;
  117296. /**
  117297. * Gets the openGL type size
  117298. */
  117299. glTypeSize: number;
  117300. /**
  117301. * Gets the openGL format
  117302. */
  117303. glFormat: number;
  117304. /**
  117305. * Gets the openGL internal format
  117306. */
  117307. glInternalFormat: number;
  117308. /**
  117309. * Gets the base internal format
  117310. */
  117311. glBaseInternalFormat: number;
  117312. /**
  117313. * Gets image width in pixel
  117314. */
  117315. pixelWidth: number;
  117316. /**
  117317. * Gets image height in pixel
  117318. */
  117319. pixelHeight: number;
  117320. /**
  117321. * Gets image depth in pixels
  117322. */
  117323. pixelDepth: number;
  117324. /**
  117325. * Gets the number of array elements
  117326. */
  117327. numberOfArrayElements: number;
  117328. /**
  117329. * Gets the number of faces
  117330. */
  117331. numberOfFaces: number;
  117332. /**
  117333. * Gets the number of mipmap levels
  117334. */
  117335. numberOfMipmapLevels: number;
  117336. /**
  117337. * Gets the bytes of key value data
  117338. */
  117339. bytesOfKeyValueData: number;
  117340. /**
  117341. * Gets the load type
  117342. */
  117343. loadType: number;
  117344. /**
  117345. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117346. */
  117347. isInvalid: boolean;
  117348. /**
  117349. * Creates a new KhronosTextureContainer
  117350. * @param arrayBuffer contents of the KTX container file
  117351. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117352. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117353. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117354. */
  117355. constructor(
  117356. /** contents of the KTX container file */
  117357. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117358. /**
  117359. * Uploads KTX content to a Babylon Texture.
  117360. * It is assumed that the texture has already been created & is currently bound
  117361. * @hidden
  117362. */
  117363. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117364. private _upload2DCompressedLevels;
  117365. }
  117366. }
  117367. declare module BABYLON {
  117368. /**
  117369. * Implementation of the KTX Texture Loader.
  117370. * @hidden
  117371. */
  117372. export class _KTXTextureLoader implements IInternalTextureLoader {
  117373. /**
  117374. * Defines wether the loader supports cascade loading the different faces.
  117375. */
  117376. readonly supportCascades: boolean;
  117377. /**
  117378. * This returns if the loader support the current file information.
  117379. * @param extension defines the file extension of the file being loaded
  117380. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117381. * @param fallback defines the fallback internal texture if any
  117382. * @param isBase64 defines whether the texture is encoded as a base64
  117383. * @param isBuffer defines whether the texture data are stored as a buffer
  117384. * @returns true if the loader can load the specified file
  117385. */
  117386. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117387. /**
  117388. * Transform the url before loading if required.
  117389. * @param rootUrl the url of the texture
  117390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117391. * @returns the transformed texture
  117392. */
  117393. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117394. /**
  117395. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117396. * @param rootUrl the url of the texture
  117397. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117398. * @returns the fallback texture
  117399. */
  117400. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117401. /**
  117402. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117403. * @param data contains the texture data
  117404. * @param texture defines the BabylonJS internal texture
  117405. * @param createPolynomials will be true if polynomials have been requested
  117406. * @param onLoad defines the callback to trigger once the texture is ready
  117407. * @param onError defines the callback to trigger in case of error
  117408. */
  117409. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117410. /**
  117411. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117412. * @param data contains the texture data
  117413. * @param texture defines the BabylonJS internal texture
  117414. * @param callback defines the method to call once ready to upload
  117415. */
  117416. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117417. }
  117418. }
  117419. declare module BABYLON {
  117420. /**
  117421. * Options for the default xr helper
  117422. */
  117423. export class WebXRDefaultExperienceOptions {
  117424. /**
  117425. * Floor meshes that should be used for teleporting
  117426. */
  117427. floorMeshes: Array<AbstractMesh>;
  117428. /**
  117429. * Enable or disable default UI to enter XR
  117430. */
  117431. disableDefaultUI: boolean;
  117432. }
  117433. /**
  117434. * Default experience which provides a similar setup to the previous webVRExperience
  117435. */
  117436. export class WebXRDefaultExperience {
  117437. /**
  117438. * Base experience
  117439. */
  117440. baseExperience: WebXRExperienceHelper;
  117441. /**
  117442. * Input experience extension
  117443. */
  117444. input: WebXRInput;
  117445. /**
  117446. * Loads the controller models
  117447. */
  117448. controllerModelLoader: WebXRControllerModelLoader;
  117449. /**
  117450. * Enables laser pointer and selection
  117451. */
  117452. pointerSelection: WebXRControllerPointerSelection;
  117453. /**
  117454. * Enables teleportation
  117455. */
  117456. teleportation: WebXRControllerTeleportation;
  117457. /**
  117458. * Enables ui for enetering/exiting xr
  117459. */
  117460. enterExitUI: WebXREnterExitUI;
  117461. /**
  117462. * Default target xr should render to
  117463. */
  117464. renderTarget: WebXRRenderTarget;
  117465. /**
  117466. * Creates the default xr experience
  117467. * @param scene scene
  117468. * @param options options for basic configuration
  117469. * @returns resulting WebXRDefaultExperience
  117470. */
  117471. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117472. private constructor();
  117473. /**
  117474. * DIsposes of the experience helper
  117475. */
  117476. dispose(): void;
  117477. }
  117478. }
  117479. declare module BABYLON {
  117480. /** @hidden */
  117481. export var _forceSceneHelpersToBundle: boolean;
  117482. interface Scene {
  117483. /**
  117484. * Creates a default light for the scene.
  117485. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117486. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117487. */
  117488. createDefaultLight(replace?: boolean): void;
  117489. /**
  117490. * Creates a default camera for the scene.
  117491. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117492. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117493. * @param replace has default false, when true replaces the active camera in the scene
  117494. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117495. */
  117496. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117497. /**
  117498. * Creates a default camera and a default light.
  117499. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117500. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117501. * @param replace has the default false, when true replaces the active camera/light in the scene
  117502. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117503. */
  117504. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117505. /**
  117506. * Creates a new sky box
  117507. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117508. * @param environmentTexture defines the texture to use as environment texture
  117509. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117510. * @param scale defines the overall scale of the skybox
  117511. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117512. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117513. * @returns a new mesh holding the sky box
  117514. */
  117515. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117516. /**
  117517. * Creates a new environment
  117518. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117519. * @param options defines the options you can use to configure the environment
  117520. * @returns the new EnvironmentHelper
  117521. */
  117522. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117523. /**
  117524. * Creates a new VREXperienceHelper
  117525. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117526. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117527. * @returns a new VREXperienceHelper
  117528. */
  117529. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117530. /**
  117531. * Creates a new WebXRDefaultExperience
  117532. * @see http://doc.babylonjs.com/how_to/webxr
  117533. * @param options experience options
  117534. * @returns a promise for a new WebXRDefaultExperience
  117535. */
  117536. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117537. }
  117538. }
  117539. declare module BABYLON {
  117540. /**
  117541. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117542. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117543. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117544. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117545. */
  117546. export class VideoDome extends TransformNode {
  117547. /**
  117548. * Define the video source as a Monoscopic panoramic 360 video.
  117549. */
  117550. static readonly MODE_MONOSCOPIC: number;
  117551. /**
  117552. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117553. */
  117554. static readonly MODE_TOPBOTTOM: number;
  117555. /**
  117556. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117557. */
  117558. static readonly MODE_SIDEBYSIDE: number;
  117559. private _halfDome;
  117560. private _useDirectMapping;
  117561. /**
  117562. * The video texture being displayed on the sphere
  117563. */
  117564. protected _videoTexture: VideoTexture;
  117565. /**
  117566. * Gets the video texture being displayed on the sphere
  117567. */
  117568. readonly videoTexture: VideoTexture;
  117569. /**
  117570. * The skybox material
  117571. */
  117572. protected _material: BackgroundMaterial;
  117573. /**
  117574. * The surface used for the skybox
  117575. */
  117576. protected _mesh: Mesh;
  117577. /**
  117578. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117579. */
  117580. private _halfDomeMask;
  117581. /**
  117582. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117583. * Also see the options.resolution property.
  117584. */
  117585. fovMultiplier: number;
  117586. private _videoMode;
  117587. /**
  117588. * Gets or set the current video mode for the video. It can be:
  117589. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117590. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117591. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117592. */
  117593. videoMode: number;
  117594. /**
  117595. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117596. *
  117597. */
  117598. /**
  117599. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117600. */
  117601. halfDome: boolean;
  117602. /**
  117603. * Oberserver used in Stereoscopic VR Mode.
  117604. */
  117605. private _onBeforeCameraRenderObserver;
  117606. /**
  117607. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117608. * @param name Element's name, child elements will append suffixes for their own names.
  117609. * @param urlsOrVideo defines the url(s) or the video element to use
  117610. * @param options An object containing optional or exposed sub element properties
  117611. */
  117612. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117613. resolution?: number;
  117614. clickToPlay?: boolean;
  117615. autoPlay?: boolean;
  117616. loop?: boolean;
  117617. size?: number;
  117618. poster?: string;
  117619. faceForward?: boolean;
  117620. useDirectMapping?: boolean;
  117621. halfDomeMode?: boolean;
  117622. }, scene: Scene);
  117623. private _changeVideoMode;
  117624. /**
  117625. * Releases resources associated with this node.
  117626. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117627. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117628. */
  117629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117630. }
  117631. }
  117632. declare module BABYLON {
  117633. /**
  117634. * This class can be used to get instrumentation data from a Babylon engine
  117635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117636. */
  117637. export class EngineInstrumentation implements IDisposable {
  117638. /**
  117639. * Define the instrumented engine.
  117640. */
  117641. engine: Engine;
  117642. private _captureGPUFrameTime;
  117643. private _gpuFrameTimeToken;
  117644. private _gpuFrameTime;
  117645. private _captureShaderCompilationTime;
  117646. private _shaderCompilationTime;
  117647. private _onBeginFrameObserver;
  117648. private _onEndFrameObserver;
  117649. private _onBeforeShaderCompilationObserver;
  117650. private _onAfterShaderCompilationObserver;
  117651. /**
  117652. * Gets the perf counter used for GPU frame time
  117653. */
  117654. readonly gpuFrameTimeCounter: PerfCounter;
  117655. /**
  117656. * Gets the GPU frame time capture status
  117657. */
  117658. /**
  117659. * Enable or disable the GPU frame time capture
  117660. */
  117661. captureGPUFrameTime: boolean;
  117662. /**
  117663. * Gets the perf counter used for shader compilation time
  117664. */
  117665. readonly shaderCompilationTimeCounter: PerfCounter;
  117666. /**
  117667. * Gets the shader compilation time capture status
  117668. */
  117669. /**
  117670. * Enable or disable the shader compilation time capture
  117671. */
  117672. captureShaderCompilationTime: boolean;
  117673. /**
  117674. * Instantiates a new engine instrumentation.
  117675. * This class can be used to get instrumentation data from a Babylon engine
  117676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117677. * @param engine Defines the engine to instrument
  117678. */
  117679. constructor(
  117680. /**
  117681. * Define the instrumented engine.
  117682. */
  117683. engine: Engine);
  117684. /**
  117685. * Dispose and release associated resources.
  117686. */
  117687. dispose(): void;
  117688. }
  117689. }
  117690. declare module BABYLON {
  117691. /**
  117692. * This class can be used to get instrumentation data from a Babylon engine
  117693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117694. */
  117695. export class SceneInstrumentation implements IDisposable {
  117696. /**
  117697. * Defines the scene to instrument
  117698. */
  117699. scene: Scene;
  117700. private _captureActiveMeshesEvaluationTime;
  117701. private _activeMeshesEvaluationTime;
  117702. private _captureRenderTargetsRenderTime;
  117703. private _renderTargetsRenderTime;
  117704. private _captureFrameTime;
  117705. private _frameTime;
  117706. private _captureRenderTime;
  117707. private _renderTime;
  117708. private _captureInterFrameTime;
  117709. private _interFrameTime;
  117710. private _captureParticlesRenderTime;
  117711. private _particlesRenderTime;
  117712. private _captureSpritesRenderTime;
  117713. private _spritesRenderTime;
  117714. private _capturePhysicsTime;
  117715. private _physicsTime;
  117716. private _captureAnimationsTime;
  117717. private _animationsTime;
  117718. private _captureCameraRenderTime;
  117719. private _cameraRenderTime;
  117720. private _onBeforeActiveMeshesEvaluationObserver;
  117721. private _onAfterActiveMeshesEvaluationObserver;
  117722. private _onBeforeRenderTargetsRenderObserver;
  117723. private _onAfterRenderTargetsRenderObserver;
  117724. private _onAfterRenderObserver;
  117725. private _onBeforeDrawPhaseObserver;
  117726. private _onAfterDrawPhaseObserver;
  117727. private _onBeforeAnimationsObserver;
  117728. private _onBeforeParticlesRenderingObserver;
  117729. private _onAfterParticlesRenderingObserver;
  117730. private _onBeforeSpritesRenderingObserver;
  117731. private _onAfterSpritesRenderingObserver;
  117732. private _onBeforePhysicsObserver;
  117733. private _onAfterPhysicsObserver;
  117734. private _onAfterAnimationsObserver;
  117735. private _onBeforeCameraRenderObserver;
  117736. private _onAfterCameraRenderObserver;
  117737. /**
  117738. * Gets the perf counter used for active meshes evaluation time
  117739. */
  117740. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  117741. /**
  117742. * Gets the active meshes evaluation time capture status
  117743. */
  117744. /**
  117745. * Enable or disable the active meshes evaluation time capture
  117746. */
  117747. captureActiveMeshesEvaluationTime: boolean;
  117748. /**
  117749. * Gets the perf counter used for render targets render time
  117750. */
  117751. readonly renderTargetsRenderTimeCounter: PerfCounter;
  117752. /**
  117753. * Gets the render targets render time capture status
  117754. */
  117755. /**
  117756. * Enable or disable the render targets render time capture
  117757. */
  117758. captureRenderTargetsRenderTime: boolean;
  117759. /**
  117760. * Gets the perf counter used for particles render time
  117761. */
  117762. readonly particlesRenderTimeCounter: PerfCounter;
  117763. /**
  117764. * Gets the particles render time capture status
  117765. */
  117766. /**
  117767. * Enable or disable the particles render time capture
  117768. */
  117769. captureParticlesRenderTime: boolean;
  117770. /**
  117771. * Gets the perf counter used for sprites render time
  117772. */
  117773. readonly spritesRenderTimeCounter: PerfCounter;
  117774. /**
  117775. * Gets the sprites render time capture status
  117776. */
  117777. /**
  117778. * Enable or disable the sprites render time capture
  117779. */
  117780. captureSpritesRenderTime: boolean;
  117781. /**
  117782. * Gets the perf counter used for physics time
  117783. */
  117784. readonly physicsTimeCounter: PerfCounter;
  117785. /**
  117786. * Gets the physics time capture status
  117787. */
  117788. /**
  117789. * Enable or disable the physics time capture
  117790. */
  117791. capturePhysicsTime: boolean;
  117792. /**
  117793. * Gets the perf counter used for animations time
  117794. */
  117795. readonly animationsTimeCounter: PerfCounter;
  117796. /**
  117797. * Gets the animations time capture status
  117798. */
  117799. /**
  117800. * Enable or disable the animations time capture
  117801. */
  117802. captureAnimationsTime: boolean;
  117803. /**
  117804. * Gets the perf counter used for frame time capture
  117805. */
  117806. readonly frameTimeCounter: PerfCounter;
  117807. /**
  117808. * Gets the frame time capture status
  117809. */
  117810. /**
  117811. * Enable or disable the frame time capture
  117812. */
  117813. captureFrameTime: boolean;
  117814. /**
  117815. * Gets the perf counter used for inter-frames time capture
  117816. */
  117817. readonly interFrameTimeCounter: PerfCounter;
  117818. /**
  117819. * Gets the inter-frames time capture status
  117820. */
  117821. /**
  117822. * Enable or disable the inter-frames time capture
  117823. */
  117824. captureInterFrameTime: boolean;
  117825. /**
  117826. * Gets the perf counter used for render time capture
  117827. */
  117828. readonly renderTimeCounter: PerfCounter;
  117829. /**
  117830. * Gets the render time capture status
  117831. */
  117832. /**
  117833. * Enable or disable the render time capture
  117834. */
  117835. captureRenderTime: boolean;
  117836. /**
  117837. * Gets the perf counter used for camera render time capture
  117838. */
  117839. readonly cameraRenderTimeCounter: PerfCounter;
  117840. /**
  117841. * Gets the camera render time capture status
  117842. */
  117843. /**
  117844. * Enable or disable the camera render time capture
  117845. */
  117846. captureCameraRenderTime: boolean;
  117847. /**
  117848. * Gets the perf counter used for draw calls
  117849. */
  117850. readonly drawCallsCounter: PerfCounter;
  117851. /**
  117852. * Instantiates a new scene instrumentation.
  117853. * This class can be used to get instrumentation data from a Babylon engine
  117854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117855. * @param scene Defines the scene to instrument
  117856. */
  117857. constructor(
  117858. /**
  117859. * Defines the scene to instrument
  117860. */
  117861. scene: Scene);
  117862. /**
  117863. * Dispose and release associated resources.
  117864. */
  117865. dispose(): void;
  117866. }
  117867. }
  117868. declare module BABYLON {
  117869. /** @hidden */
  117870. export var glowMapGenerationPixelShader: {
  117871. name: string;
  117872. shader: string;
  117873. };
  117874. }
  117875. declare module BABYLON {
  117876. /** @hidden */
  117877. export var glowMapGenerationVertexShader: {
  117878. name: string;
  117879. shader: string;
  117880. };
  117881. }
  117882. declare module BABYLON {
  117883. /**
  117884. * Effect layer options. This helps customizing the behaviour
  117885. * of the effect layer.
  117886. */
  117887. export interface IEffectLayerOptions {
  117888. /**
  117889. * Multiplication factor apply to the canvas size to compute the render target size
  117890. * used to generated the objects (the smaller the faster).
  117891. */
  117892. mainTextureRatio: number;
  117893. /**
  117894. * Enforces a fixed size texture to ensure effect stability across devices.
  117895. */
  117896. mainTextureFixedSize?: number;
  117897. /**
  117898. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  117899. */
  117900. alphaBlendingMode: number;
  117901. /**
  117902. * The camera attached to the layer.
  117903. */
  117904. camera: Nullable<Camera>;
  117905. /**
  117906. * The rendering group to draw the layer in.
  117907. */
  117908. renderingGroupId: number;
  117909. }
  117910. /**
  117911. * The effect layer Helps adding post process effect blended with the main pass.
  117912. *
  117913. * This can be for instance use to generate glow or higlight effects on the scene.
  117914. *
  117915. * The effect layer class can not be used directly and is intented to inherited from to be
  117916. * customized per effects.
  117917. */
  117918. export abstract class EffectLayer {
  117919. private _vertexBuffers;
  117920. private _indexBuffer;
  117921. private _cachedDefines;
  117922. private _effectLayerMapGenerationEffect;
  117923. private _effectLayerOptions;
  117924. private _mergeEffect;
  117925. protected _scene: Scene;
  117926. protected _engine: Engine;
  117927. protected _maxSize: number;
  117928. protected _mainTextureDesiredSize: ISize;
  117929. protected _mainTexture: RenderTargetTexture;
  117930. protected _shouldRender: boolean;
  117931. protected _postProcesses: PostProcess[];
  117932. protected _textures: BaseTexture[];
  117933. protected _emissiveTextureAndColor: {
  117934. texture: Nullable<BaseTexture>;
  117935. color: Color4;
  117936. };
  117937. /**
  117938. * The name of the layer
  117939. */
  117940. name: string;
  117941. /**
  117942. * The clear color of the texture used to generate the glow map.
  117943. */
  117944. neutralColor: Color4;
  117945. /**
  117946. * Specifies wether the highlight layer is enabled or not.
  117947. */
  117948. isEnabled: boolean;
  117949. /**
  117950. * Gets the camera attached to the layer.
  117951. */
  117952. readonly camera: Nullable<Camera>;
  117953. /**
  117954. * Gets the rendering group id the layer should render in.
  117955. */
  117956. renderingGroupId: number;
  117957. /**
  117958. * An event triggered when the effect layer has been disposed.
  117959. */
  117960. onDisposeObservable: Observable<EffectLayer>;
  117961. /**
  117962. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  117963. */
  117964. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  117965. /**
  117966. * An event triggered when the generated texture is being merged in the scene.
  117967. */
  117968. onBeforeComposeObservable: Observable<EffectLayer>;
  117969. /**
  117970. * An event triggered when the mesh is rendered into the effect render target.
  117971. */
  117972. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  117973. /**
  117974. * An event triggered after the mesh has been rendered into the effect render target.
  117975. */
  117976. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  117977. /**
  117978. * An event triggered when the generated texture has been merged in the scene.
  117979. */
  117980. onAfterComposeObservable: Observable<EffectLayer>;
  117981. /**
  117982. * An event triggered when the efffect layer changes its size.
  117983. */
  117984. onSizeChangedObservable: Observable<EffectLayer>;
  117985. /** @hidden */
  117986. static _SceneComponentInitialization: (scene: Scene) => void;
  117987. /**
  117988. * Instantiates a new effect Layer and references it in the scene.
  117989. * @param name The name of the layer
  117990. * @param scene The scene to use the layer in
  117991. */
  117992. constructor(
  117993. /** The Friendly of the effect in the scene */
  117994. name: string, scene: Scene);
  117995. /**
  117996. * Get the effect name of the layer.
  117997. * @return The effect name
  117998. */
  117999. abstract getEffectName(): string;
  118000. /**
  118001. * Checks for the readiness of the element composing the layer.
  118002. * @param subMesh the mesh to check for
  118003. * @param useInstances specify wether or not to use instances to render the mesh
  118004. * @return true if ready otherwise, false
  118005. */
  118006. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118007. /**
  118008. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118009. * @returns true if the effect requires stencil during the main canvas render pass.
  118010. */
  118011. abstract needStencil(): boolean;
  118012. /**
  118013. * Create the merge effect. This is the shader use to blit the information back
  118014. * to the main canvas at the end of the scene rendering.
  118015. * @returns The effect containing the shader used to merge the effect on the main canvas
  118016. */
  118017. protected abstract _createMergeEffect(): Effect;
  118018. /**
  118019. * Creates the render target textures and post processes used in the effect layer.
  118020. */
  118021. protected abstract _createTextureAndPostProcesses(): void;
  118022. /**
  118023. * Implementation specific of rendering the generating effect on the main canvas.
  118024. * @param effect The effect used to render through
  118025. */
  118026. protected abstract _internalRender(effect: Effect): void;
  118027. /**
  118028. * Sets the required values for both the emissive texture and and the main color.
  118029. */
  118030. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118031. /**
  118032. * Free any resources and references associated to a mesh.
  118033. * Internal use
  118034. * @param mesh The mesh to free.
  118035. */
  118036. abstract _disposeMesh(mesh: Mesh): void;
  118037. /**
  118038. * Serializes this layer (Glow or Highlight for example)
  118039. * @returns a serialized layer object
  118040. */
  118041. abstract serialize?(): any;
  118042. /**
  118043. * Initializes the effect layer with the required options.
  118044. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118045. */
  118046. protected _init(options: Partial<IEffectLayerOptions>): void;
  118047. /**
  118048. * Generates the index buffer of the full screen quad blending to the main canvas.
  118049. */
  118050. private _generateIndexBuffer;
  118051. /**
  118052. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118053. */
  118054. private _generateVertexBuffer;
  118055. /**
  118056. * Sets the main texture desired size which is the closest power of two
  118057. * of the engine canvas size.
  118058. */
  118059. private _setMainTextureSize;
  118060. /**
  118061. * Creates the main texture for the effect layer.
  118062. */
  118063. protected _createMainTexture(): void;
  118064. /**
  118065. * Adds specific effects defines.
  118066. * @param defines The defines to add specifics to.
  118067. */
  118068. protected _addCustomEffectDefines(defines: string[]): void;
  118069. /**
  118070. * Checks for the readiness of the element composing the layer.
  118071. * @param subMesh the mesh to check for
  118072. * @param useInstances specify wether or not to use instances to render the mesh
  118073. * @param emissiveTexture the associated emissive texture used to generate the glow
  118074. * @return true if ready otherwise, false
  118075. */
  118076. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118077. /**
  118078. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118079. */
  118080. render(): void;
  118081. /**
  118082. * Determine if a given mesh will be used in the current effect.
  118083. * @param mesh mesh to test
  118084. * @returns true if the mesh will be used
  118085. */
  118086. hasMesh(mesh: AbstractMesh): boolean;
  118087. /**
  118088. * Returns true if the layer contains information to display, otherwise false.
  118089. * @returns true if the glow layer should be rendered
  118090. */
  118091. shouldRender(): boolean;
  118092. /**
  118093. * Returns true if the mesh should render, otherwise false.
  118094. * @param mesh The mesh to render
  118095. * @returns true if it should render otherwise false
  118096. */
  118097. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118098. /**
  118099. * Returns true if the mesh can be rendered, otherwise false.
  118100. * @param mesh The mesh to render
  118101. * @param material The material used on the mesh
  118102. * @returns true if it can be rendered otherwise false
  118103. */
  118104. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118105. /**
  118106. * Returns true if the mesh should render, otherwise false.
  118107. * @param mesh The mesh to render
  118108. * @returns true if it should render otherwise false
  118109. */
  118110. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118111. /**
  118112. * Renders the submesh passed in parameter to the generation map.
  118113. */
  118114. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118115. /**
  118116. * Defines wether the current material of the mesh should be use to render the effect.
  118117. * @param mesh defines the current mesh to render
  118118. */
  118119. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118120. /**
  118121. * Rebuild the required buffers.
  118122. * @hidden Internal use only.
  118123. */
  118124. _rebuild(): void;
  118125. /**
  118126. * Dispose only the render target textures and post process.
  118127. */
  118128. private _disposeTextureAndPostProcesses;
  118129. /**
  118130. * Dispose the highlight layer and free resources.
  118131. */
  118132. dispose(): void;
  118133. /**
  118134. * Gets the class name of the effect layer
  118135. * @returns the string with the class name of the effect layer
  118136. */
  118137. getClassName(): string;
  118138. /**
  118139. * Creates an effect layer from parsed effect layer data
  118140. * @param parsedEffectLayer defines effect layer data
  118141. * @param scene defines the current scene
  118142. * @param rootUrl defines the root URL containing the effect layer information
  118143. * @returns a parsed effect Layer
  118144. */
  118145. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118146. }
  118147. }
  118148. declare module BABYLON {
  118149. interface AbstractScene {
  118150. /**
  118151. * The list of effect layers (highlights/glow) added to the scene
  118152. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118153. * @see http://doc.babylonjs.com/how_to/glow_layer
  118154. */
  118155. effectLayers: Array<EffectLayer>;
  118156. /**
  118157. * Removes the given effect layer from this scene.
  118158. * @param toRemove defines the effect layer to remove
  118159. * @returns the index of the removed effect layer
  118160. */
  118161. removeEffectLayer(toRemove: EffectLayer): number;
  118162. /**
  118163. * Adds the given effect layer to this scene
  118164. * @param newEffectLayer defines the effect layer to add
  118165. */
  118166. addEffectLayer(newEffectLayer: EffectLayer): void;
  118167. }
  118168. /**
  118169. * Defines the layer scene component responsible to manage any effect layers
  118170. * in a given scene.
  118171. */
  118172. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118173. /**
  118174. * The component name helpfull to identify the component in the list of scene components.
  118175. */
  118176. readonly name: string;
  118177. /**
  118178. * The scene the component belongs to.
  118179. */
  118180. scene: Scene;
  118181. private _engine;
  118182. private _renderEffects;
  118183. private _needStencil;
  118184. private _previousStencilState;
  118185. /**
  118186. * Creates a new instance of the component for the given scene
  118187. * @param scene Defines the scene to register the component in
  118188. */
  118189. constructor(scene: Scene);
  118190. /**
  118191. * Registers the component in a given scene
  118192. */
  118193. register(): void;
  118194. /**
  118195. * Rebuilds the elements related to this component in case of
  118196. * context lost for instance.
  118197. */
  118198. rebuild(): void;
  118199. /**
  118200. * Serializes the component data to the specified json object
  118201. * @param serializationObject The object to serialize to
  118202. */
  118203. serialize(serializationObject: any): void;
  118204. /**
  118205. * Adds all the elements from the container to the scene
  118206. * @param container the container holding the elements
  118207. */
  118208. addFromContainer(container: AbstractScene): void;
  118209. /**
  118210. * Removes all the elements in the container from the scene
  118211. * @param container contains the elements to remove
  118212. * @param dispose if the removed element should be disposed (default: false)
  118213. */
  118214. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118215. /**
  118216. * Disposes the component and the associated ressources.
  118217. */
  118218. dispose(): void;
  118219. private _isReadyForMesh;
  118220. private _renderMainTexture;
  118221. private _setStencil;
  118222. private _setStencilBack;
  118223. private _draw;
  118224. private _drawCamera;
  118225. private _drawRenderingGroup;
  118226. }
  118227. }
  118228. declare module BABYLON {
  118229. /** @hidden */
  118230. export var glowMapMergePixelShader: {
  118231. name: string;
  118232. shader: string;
  118233. };
  118234. }
  118235. declare module BABYLON {
  118236. /** @hidden */
  118237. export var glowMapMergeVertexShader: {
  118238. name: string;
  118239. shader: string;
  118240. };
  118241. }
  118242. declare module BABYLON {
  118243. interface AbstractScene {
  118244. /**
  118245. * Return a the first highlight layer of the scene with a given name.
  118246. * @param name The name of the highlight layer to look for.
  118247. * @return The highlight layer if found otherwise null.
  118248. */
  118249. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118250. }
  118251. /**
  118252. * Glow layer options. This helps customizing the behaviour
  118253. * of the glow layer.
  118254. */
  118255. export interface IGlowLayerOptions {
  118256. /**
  118257. * Multiplication factor apply to the canvas size to compute the render target size
  118258. * used to generated the glowing objects (the smaller the faster).
  118259. */
  118260. mainTextureRatio: number;
  118261. /**
  118262. * Enforces a fixed size texture to ensure resize independant blur.
  118263. */
  118264. mainTextureFixedSize?: number;
  118265. /**
  118266. * How big is the kernel of the blur texture.
  118267. */
  118268. blurKernelSize: number;
  118269. /**
  118270. * The camera attached to the layer.
  118271. */
  118272. camera: Nullable<Camera>;
  118273. /**
  118274. * Enable MSAA by chosing the number of samples.
  118275. */
  118276. mainTextureSamples?: number;
  118277. /**
  118278. * The rendering group to draw the layer in.
  118279. */
  118280. renderingGroupId: number;
  118281. }
  118282. /**
  118283. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118284. *
  118285. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118286. *
  118287. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118288. */
  118289. export class GlowLayer extends EffectLayer {
  118290. /**
  118291. * Effect Name of the layer.
  118292. */
  118293. static readonly EffectName: string;
  118294. /**
  118295. * The default blur kernel size used for the glow.
  118296. */
  118297. static DefaultBlurKernelSize: number;
  118298. /**
  118299. * The default texture size ratio used for the glow.
  118300. */
  118301. static DefaultTextureRatio: number;
  118302. /**
  118303. * Sets the kernel size of the blur.
  118304. */
  118305. /**
  118306. * Gets the kernel size of the blur.
  118307. */
  118308. blurKernelSize: number;
  118309. /**
  118310. * Sets the glow intensity.
  118311. */
  118312. /**
  118313. * Gets the glow intensity.
  118314. */
  118315. intensity: number;
  118316. private _options;
  118317. private _intensity;
  118318. private _horizontalBlurPostprocess1;
  118319. private _verticalBlurPostprocess1;
  118320. private _horizontalBlurPostprocess2;
  118321. private _verticalBlurPostprocess2;
  118322. private _blurTexture1;
  118323. private _blurTexture2;
  118324. private _postProcesses1;
  118325. private _postProcesses2;
  118326. private _includedOnlyMeshes;
  118327. private _excludedMeshes;
  118328. private _meshesUsingTheirOwnMaterials;
  118329. /**
  118330. * Callback used to let the user override the color selection on a per mesh basis
  118331. */
  118332. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118333. /**
  118334. * Callback used to let the user override the texture selection on a per mesh basis
  118335. */
  118336. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118337. /**
  118338. * Instantiates a new glow Layer and references it to the scene.
  118339. * @param name The name of the layer
  118340. * @param scene The scene to use the layer in
  118341. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118342. */
  118343. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118344. /**
  118345. * Get the effect name of the layer.
  118346. * @return The effect name
  118347. */
  118348. getEffectName(): string;
  118349. /**
  118350. * Create the merge effect. This is the shader use to blit the information back
  118351. * to the main canvas at the end of the scene rendering.
  118352. */
  118353. protected _createMergeEffect(): Effect;
  118354. /**
  118355. * Creates the render target textures and post processes used in the glow layer.
  118356. */
  118357. protected _createTextureAndPostProcesses(): void;
  118358. /**
  118359. * Checks for the readiness of the element composing the layer.
  118360. * @param subMesh the mesh to check for
  118361. * @param useInstances specify wether or not to use instances to render the mesh
  118362. * @param emissiveTexture the associated emissive texture used to generate the glow
  118363. * @return true if ready otherwise, false
  118364. */
  118365. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118366. /**
  118367. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118368. */
  118369. needStencil(): boolean;
  118370. /**
  118371. * Returns true if the mesh can be rendered, otherwise false.
  118372. * @param mesh The mesh to render
  118373. * @param material The material used on the mesh
  118374. * @returns true if it can be rendered otherwise false
  118375. */
  118376. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118377. /**
  118378. * Implementation specific of rendering the generating effect on the main canvas.
  118379. * @param effect The effect used to render through
  118380. */
  118381. protected _internalRender(effect: Effect): void;
  118382. /**
  118383. * Sets the required values for both the emissive texture and and the main color.
  118384. */
  118385. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118386. /**
  118387. * Returns true if the mesh should render, otherwise false.
  118388. * @param mesh The mesh to render
  118389. * @returns true if it should render otherwise false
  118390. */
  118391. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118392. /**
  118393. * Adds specific effects defines.
  118394. * @param defines The defines to add specifics to.
  118395. */
  118396. protected _addCustomEffectDefines(defines: string[]): void;
  118397. /**
  118398. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118399. * @param mesh The mesh to exclude from the glow layer
  118400. */
  118401. addExcludedMesh(mesh: Mesh): void;
  118402. /**
  118403. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118404. * @param mesh The mesh to remove
  118405. */
  118406. removeExcludedMesh(mesh: Mesh): void;
  118407. /**
  118408. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118409. * @param mesh The mesh to include in the glow layer
  118410. */
  118411. addIncludedOnlyMesh(mesh: Mesh): void;
  118412. /**
  118413. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118414. * @param mesh The mesh to remove
  118415. */
  118416. removeIncludedOnlyMesh(mesh: Mesh): void;
  118417. /**
  118418. * Determine if a given mesh will be used in the glow layer
  118419. * @param mesh The mesh to test
  118420. * @returns true if the mesh will be highlighted by the current glow layer
  118421. */
  118422. hasMesh(mesh: AbstractMesh): boolean;
  118423. /**
  118424. * Defines wether the current material of the mesh should be use to render the effect.
  118425. * @param mesh defines the current mesh to render
  118426. */
  118427. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118428. /**
  118429. * Add a mesh to be rendered through its own material and not with emissive only.
  118430. * @param mesh The mesh for which we need to use its material
  118431. */
  118432. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118433. /**
  118434. * Remove a mesh from being rendered through its own material and not with emissive only.
  118435. * @param mesh The mesh for which we need to not use its material
  118436. */
  118437. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118438. /**
  118439. * Free any resources and references associated to a mesh.
  118440. * Internal use
  118441. * @param mesh The mesh to free.
  118442. * @hidden
  118443. */
  118444. _disposeMesh(mesh: Mesh): void;
  118445. /**
  118446. * Gets the class name of the effect layer
  118447. * @returns the string with the class name of the effect layer
  118448. */
  118449. getClassName(): string;
  118450. /**
  118451. * Serializes this glow layer
  118452. * @returns a serialized glow layer object
  118453. */
  118454. serialize(): any;
  118455. /**
  118456. * Creates a Glow Layer from parsed glow layer data
  118457. * @param parsedGlowLayer defines glow layer data
  118458. * @param scene defines the current scene
  118459. * @param rootUrl defines the root URL containing the glow layer information
  118460. * @returns a parsed Glow Layer
  118461. */
  118462. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118463. }
  118464. }
  118465. declare module BABYLON {
  118466. /** @hidden */
  118467. export var glowBlurPostProcessPixelShader: {
  118468. name: string;
  118469. shader: string;
  118470. };
  118471. }
  118472. declare module BABYLON {
  118473. interface AbstractScene {
  118474. /**
  118475. * Return a the first highlight layer of the scene with a given name.
  118476. * @param name The name of the highlight layer to look for.
  118477. * @return The highlight layer if found otherwise null.
  118478. */
  118479. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118480. }
  118481. /**
  118482. * Highlight layer options. This helps customizing the behaviour
  118483. * of the highlight layer.
  118484. */
  118485. export interface IHighlightLayerOptions {
  118486. /**
  118487. * Multiplication factor apply to the canvas size to compute the render target size
  118488. * used to generated the glowing objects (the smaller the faster).
  118489. */
  118490. mainTextureRatio: number;
  118491. /**
  118492. * Enforces a fixed size texture to ensure resize independant blur.
  118493. */
  118494. mainTextureFixedSize?: number;
  118495. /**
  118496. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118497. * of the picture to blur (the smaller the faster).
  118498. */
  118499. blurTextureSizeRatio: number;
  118500. /**
  118501. * How big in texel of the blur texture is the vertical blur.
  118502. */
  118503. blurVerticalSize: number;
  118504. /**
  118505. * How big in texel of the blur texture is the horizontal blur.
  118506. */
  118507. blurHorizontalSize: number;
  118508. /**
  118509. * Alpha blending mode used to apply the blur. Default is combine.
  118510. */
  118511. alphaBlendingMode: number;
  118512. /**
  118513. * The camera attached to the layer.
  118514. */
  118515. camera: Nullable<Camera>;
  118516. /**
  118517. * Should we display highlight as a solid stroke?
  118518. */
  118519. isStroke?: boolean;
  118520. /**
  118521. * The rendering group to draw the layer in.
  118522. */
  118523. renderingGroupId: number;
  118524. }
  118525. /**
  118526. * The highlight layer Helps adding a glow effect around a mesh.
  118527. *
  118528. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118529. * glowy meshes to your scene.
  118530. *
  118531. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118532. */
  118533. export class HighlightLayer extends EffectLayer {
  118534. name: string;
  118535. /**
  118536. * Effect Name of the highlight layer.
  118537. */
  118538. static readonly EffectName: string;
  118539. /**
  118540. * The neutral color used during the preparation of the glow effect.
  118541. * This is black by default as the blend operation is a blend operation.
  118542. */
  118543. static NeutralColor: Color4;
  118544. /**
  118545. * Stencil value used for glowing meshes.
  118546. */
  118547. static GlowingMeshStencilReference: number;
  118548. /**
  118549. * Stencil value used for the other meshes in the scene.
  118550. */
  118551. static NormalMeshStencilReference: number;
  118552. /**
  118553. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118554. */
  118555. innerGlow: boolean;
  118556. /**
  118557. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118558. */
  118559. outerGlow: boolean;
  118560. /**
  118561. * Specifies the horizontal size of the blur.
  118562. */
  118563. /**
  118564. * Gets the horizontal size of the blur.
  118565. */
  118566. blurHorizontalSize: number;
  118567. /**
  118568. * Specifies the vertical size of the blur.
  118569. */
  118570. /**
  118571. * Gets the vertical size of the blur.
  118572. */
  118573. blurVerticalSize: number;
  118574. /**
  118575. * An event triggered when the highlight layer is being blurred.
  118576. */
  118577. onBeforeBlurObservable: Observable<HighlightLayer>;
  118578. /**
  118579. * An event triggered when the highlight layer has been blurred.
  118580. */
  118581. onAfterBlurObservable: Observable<HighlightLayer>;
  118582. private _instanceGlowingMeshStencilReference;
  118583. private _options;
  118584. private _downSamplePostprocess;
  118585. private _horizontalBlurPostprocess;
  118586. private _verticalBlurPostprocess;
  118587. private _blurTexture;
  118588. private _meshes;
  118589. private _excludedMeshes;
  118590. /**
  118591. * Instantiates a new highlight Layer and references it to the scene..
  118592. * @param name The name of the layer
  118593. * @param scene The scene to use the layer in
  118594. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118595. */
  118596. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118597. /**
  118598. * Get the effect name of the layer.
  118599. * @return The effect name
  118600. */
  118601. getEffectName(): string;
  118602. /**
  118603. * Create the merge effect. This is the shader use to blit the information back
  118604. * to the main canvas at the end of the scene rendering.
  118605. */
  118606. protected _createMergeEffect(): Effect;
  118607. /**
  118608. * Creates the render target textures and post processes used in the highlight layer.
  118609. */
  118610. protected _createTextureAndPostProcesses(): void;
  118611. /**
  118612. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118613. */
  118614. needStencil(): boolean;
  118615. /**
  118616. * Checks for the readiness of the element composing the layer.
  118617. * @param subMesh the mesh to check for
  118618. * @param useInstances specify wether or not to use instances to render the mesh
  118619. * @param emissiveTexture the associated emissive texture used to generate the glow
  118620. * @return true if ready otherwise, false
  118621. */
  118622. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118623. /**
  118624. * Implementation specific of rendering the generating effect on the main canvas.
  118625. * @param effect The effect used to render through
  118626. */
  118627. protected _internalRender(effect: Effect): void;
  118628. /**
  118629. * Returns true if the layer contains information to display, otherwise false.
  118630. */
  118631. shouldRender(): boolean;
  118632. /**
  118633. * Returns true if the mesh should render, otherwise false.
  118634. * @param mesh The mesh to render
  118635. * @returns true if it should render otherwise false
  118636. */
  118637. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118638. /**
  118639. * Sets the required values for both the emissive texture and and the main color.
  118640. */
  118641. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118642. /**
  118643. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  118644. * @param mesh The mesh to exclude from the highlight layer
  118645. */
  118646. addExcludedMesh(mesh: Mesh): void;
  118647. /**
  118648. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  118649. * @param mesh The mesh to highlight
  118650. */
  118651. removeExcludedMesh(mesh: Mesh): void;
  118652. /**
  118653. * Determine if a given mesh will be highlighted by the current HighlightLayer
  118654. * @param mesh mesh to test
  118655. * @returns true if the mesh will be highlighted by the current HighlightLayer
  118656. */
  118657. hasMesh(mesh: AbstractMesh): boolean;
  118658. /**
  118659. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  118660. * @param mesh The mesh to highlight
  118661. * @param color The color of the highlight
  118662. * @param glowEmissiveOnly Extract the glow from the emissive texture
  118663. */
  118664. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  118665. /**
  118666. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118667. * @param mesh The mesh to highlight
  118668. */
  118669. removeMesh(mesh: Mesh): void;
  118670. /**
  118671. * Force the stencil to the normal expected value for none glowing parts
  118672. */
  118673. private _defaultStencilReference;
  118674. /**
  118675. * Free any resources and references associated to a mesh.
  118676. * Internal use
  118677. * @param mesh The mesh to free.
  118678. * @hidden
  118679. */
  118680. _disposeMesh(mesh: Mesh): void;
  118681. /**
  118682. * Dispose the highlight layer and free resources.
  118683. */
  118684. dispose(): void;
  118685. /**
  118686. * Gets the class name of the effect layer
  118687. * @returns the string with the class name of the effect layer
  118688. */
  118689. getClassName(): string;
  118690. /**
  118691. * Serializes this Highlight layer
  118692. * @returns a serialized Highlight layer object
  118693. */
  118694. serialize(): any;
  118695. /**
  118696. * Creates a Highlight layer from parsed Highlight layer data
  118697. * @param parsedHightlightLayer defines the Highlight layer data
  118698. * @param scene defines the current scene
  118699. * @param rootUrl defines the root URL containing the Highlight layer information
  118700. * @returns a parsed Highlight layer
  118701. */
  118702. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118703. }
  118704. }
  118705. declare module BABYLON {
  118706. interface AbstractScene {
  118707. /**
  118708. * The list of layers (background and foreground) of the scene
  118709. */
  118710. layers: Array<Layer>;
  118711. }
  118712. /**
  118713. * Defines the layer scene component responsible to manage any layers
  118714. * in a given scene.
  118715. */
  118716. export class LayerSceneComponent implements ISceneComponent {
  118717. /**
  118718. * The component name helpfull to identify the component in the list of scene components.
  118719. */
  118720. readonly name: string;
  118721. /**
  118722. * The scene the component belongs to.
  118723. */
  118724. scene: Scene;
  118725. private _engine;
  118726. /**
  118727. * Creates a new instance of the component for the given scene
  118728. * @param scene Defines the scene to register the component in
  118729. */
  118730. constructor(scene: Scene);
  118731. /**
  118732. * Registers the component in a given scene
  118733. */
  118734. register(): void;
  118735. /**
  118736. * Rebuilds the elements related to this component in case of
  118737. * context lost for instance.
  118738. */
  118739. rebuild(): void;
  118740. /**
  118741. * Disposes the component and the associated ressources.
  118742. */
  118743. dispose(): void;
  118744. private _draw;
  118745. private _drawCameraPredicate;
  118746. private _drawCameraBackground;
  118747. private _drawCameraForeground;
  118748. private _drawRenderTargetPredicate;
  118749. private _drawRenderTargetBackground;
  118750. private _drawRenderTargetForeground;
  118751. /**
  118752. * Adds all the elements from the container to the scene
  118753. * @param container the container holding the elements
  118754. */
  118755. addFromContainer(container: AbstractScene): void;
  118756. /**
  118757. * Removes all the elements in the container from the scene
  118758. * @param container contains the elements to remove
  118759. * @param dispose if the removed element should be disposed (default: false)
  118760. */
  118761. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118762. }
  118763. }
  118764. declare module BABYLON {
  118765. /** @hidden */
  118766. export var layerPixelShader: {
  118767. name: string;
  118768. shader: string;
  118769. };
  118770. }
  118771. declare module BABYLON {
  118772. /** @hidden */
  118773. export var layerVertexShader: {
  118774. name: string;
  118775. shader: string;
  118776. };
  118777. }
  118778. declare module BABYLON {
  118779. /**
  118780. * This represents a full screen 2d layer.
  118781. * This can be useful to display a picture in the background of your scene for instance.
  118782. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118783. */
  118784. export class Layer {
  118785. /**
  118786. * Define the name of the layer.
  118787. */
  118788. name: string;
  118789. /**
  118790. * Define the texture the layer should display.
  118791. */
  118792. texture: Nullable<Texture>;
  118793. /**
  118794. * Is the layer in background or foreground.
  118795. */
  118796. isBackground: boolean;
  118797. /**
  118798. * Define the color of the layer (instead of texture).
  118799. */
  118800. color: Color4;
  118801. /**
  118802. * Define the scale of the layer in order to zoom in out of the texture.
  118803. */
  118804. scale: Vector2;
  118805. /**
  118806. * Define an offset for the layer in order to shift the texture.
  118807. */
  118808. offset: Vector2;
  118809. /**
  118810. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  118811. */
  118812. alphaBlendingMode: number;
  118813. /**
  118814. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  118815. * Alpha test will not mix with the background color in case of transparency.
  118816. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  118817. */
  118818. alphaTest: boolean;
  118819. /**
  118820. * Define a mask to restrict the layer to only some of the scene cameras.
  118821. */
  118822. layerMask: number;
  118823. /**
  118824. * Define the list of render target the layer is visible into.
  118825. */
  118826. renderTargetTextures: RenderTargetTexture[];
  118827. /**
  118828. * Define if the layer is only used in renderTarget or if it also
  118829. * renders in the main frame buffer of the canvas.
  118830. */
  118831. renderOnlyInRenderTargetTextures: boolean;
  118832. private _scene;
  118833. private _vertexBuffers;
  118834. private _indexBuffer;
  118835. private _effect;
  118836. private _alphaTestEffect;
  118837. /**
  118838. * An event triggered when the layer is disposed.
  118839. */
  118840. onDisposeObservable: Observable<Layer>;
  118841. private _onDisposeObserver;
  118842. /**
  118843. * Back compatibility with callback before the onDisposeObservable existed.
  118844. * The set callback will be triggered when the layer has been disposed.
  118845. */
  118846. onDispose: () => void;
  118847. /**
  118848. * An event triggered before rendering the scene
  118849. */
  118850. onBeforeRenderObservable: Observable<Layer>;
  118851. private _onBeforeRenderObserver;
  118852. /**
  118853. * Back compatibility with callback before the onBeforeRenderObservable existed.
  118854. * The set callback will be triggered just before rendering the layer.
  118855. */
  118856. onBeforeRender: () => void;
  118857. /**
  118858. * An event triggered after rendering the scene
  118859. */
  118860. onAfterRenderObservable: Observable<Layer>;
  118861. private _onAfterRenderObserver;
  118862. /**
  118863. * Back compatibility with callback before the onAfterRenderObservable existed.
  118864. * The set callback will be triggered just after rendering the layer.
  118865. */
  118866. onAfterRender: () => void;
  118867. /**
  118868. * Instantiates a new layer.
  118869. * This represents a full screen 2d layer.
  118870. * This can be useful to display a picture in the background of your scene for instance.
  118871. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118872. * @param name Define the name of the layer in the scene
  118873. * @param imgUrl Define the url of the texture to display in the layer
  118874. * @param scene Define the scene the layer belongs to
  118875. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  118876. * @param color Defines a color for the layer
  118877. */
  118878. constructor(
  118879. /**
  118880. * Define the name of the layer.
  118881. */
  118882. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  118883. private _createIndexBuffer;
  118884. /** @hidden */
  118885. _rebuild(): void;
  118886. /**
  118887. * Renders the layer in the scene.
  118888. */
  118889. render(): void;
  118890. /**
  118891. * Disposes and releases the associated ressources.
  118892. */
  118893. dispose(): void;
  118894. }
  118895. }
  118896. declare module BABYLON {
  118897. /** @hidden */
  118898. export var lensFlarePixelShader: {
  118899. name: string;
  118900. shader: string;
  118901. };
  118902. }
  118903. declare module BABYLON {
  118904. /** @hidden */
  118905. export var lensFlareVertexShader: {
  118906. name: string;
  118907. shader: string;
  118908. };
  118909. }
  118910. declare module BABYLON {
  118911. /**
  118912. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118913. * It is usually composed of several `lensFlare`.
  118914. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118915. */
  118916. export class LensFlareSystem {
  118917. /**
  118918. * Define the name of the lens flare system
  118919. */
  118920. name: string;
  118921. /**
  118922. * List of lens flares used in this system.
  118923. */
  118924. lensFlares: LensFlare[];
  118925. /**
  118926. * Define a limit from the border the lens flare can be visible.
  118927. */
  118928. borderLimit: number;
  118929. /**
  118930. * Define a viewport border we do not want to see the lens flare in.
  118931. */
  118932. viewportBorder: number;
  118933. /**
  118934. * Define a predicate which could limit the list of meshes able to occlude the effect.
  118935. */
  118936. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118937. /**
  118938. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  118939. */
  118940. layerMask: number;
  118941. /**
  118942. * Define the id of the lens flare system in the scene.
  118943. * (equal to name by default)
  118944. */
  118945. id: string;
  118946. private _scene;
  118947. private _emitter;
  118948. private _vertexBuffers;
  118949. private _indexBuffer;
  118950. private _effect;
  118951. private _positionX;
  118952. private _positionY;
  118953. private _isEnabled;
  118954. /** @hidden */
  118955. static _SceneComponentInitialization: (scene: Scene) => void;
  118956. /**
  118957. * Instantiates a lens flare system.
  118958. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118959. * It is usually composed of several `lensFlare`.
  118960. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118961. * @param name Define the name of the lens flare system in the scene
  118962. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  118963. * @param scene Define the scene the lens flare system belongs to
  118964. */
  118965. constructor(
  118966. /**
  118967. * Define the name of the lens flare system
  118968. */
  118969. name: string, emitter: any, scene: Scene);
  118970. /**
  118971. * Define if the lens flare system is enabled.
  118972. */
  118973. isEnabled: boolean;
  118974. /**
  118975. * Get the scene the effects belongs to.
  118976. * @returns the scene holding the lens flare system
  118977. */
  118978. getScene(): Scene;
  118979. /**
  118980. * Get the emitter of the lens flare system.
  118981. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118982. * @returns the emitter of the lens flare system
  118983. */
  118984. getEmitter(): any;
  118985. /**
  118986. * Set the emitter of the lens flare system.
  118987. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118988. * @param newEmitter Define the new emitter of the system
  118989. */
  118990. setEmitter(newEmitter: any): void;
  118991. /**
  118992. * Get the lens flare system emitter position.
  118993. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  118994. * @returns the position
  118995. */
  118996. getEmitterPosition(): Vector3;
  118997. /**
  118998. * @hidden
  118999. */
  119000. computeEffectivePosition(globalViewport: Viewport): boolean;
  119001. /** @hidden */
  119002. _isVisible(): boolean;
  119003. /**
  119004. * @hidden
  119005. */
  119006. render(): boolean;
  119007. /**
  119008. * Dispose and release the lens flare with its associated resources.
  119009. */
  119010. dispose(): void;
  119011. /**
  119012. * Parse a lens flare system from a JSON repressentation
  119013. * @param parsedLensFlareSystem Define the JSON to parse
  119014. * @param scene Define the scene the parsed system should be instantiated in
  119015. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119016. * @returns the parsed system
  119017. */
  119018. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119019. /**
  119020. * Serialize the current Lens Flare System into a JSON representation.
  119021. * @returns the serialized JSON
  119022. */
  119023. serialize(): any;
  119024. }
  119025. }
  119026. declare module BABYLON {
  119027. /**
  119028. * This represents one of the lens effect in a `lensFlareSystem`.
  119029. * It controls one of the indiviual texture used in the effect.
  119030. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119031. */
  119032. export class LensFlare {
  119033. /**
  119034. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119035. */
  119036. size: number;
  119037. /**
  119038. * 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.
  119039. */
  119040. position: number;
  119041. /**
  119042. * Define the lens color.
  119043. */
  119044. color: Color3;
  119045. /**
  119046. * Define the lens texture.
  119047. */
  119048. texture: Nullable<Texture>;
  119049. /**
  119050. * Define the alpha mode to render this particular lens.
  119051. */
  119052. alphaMode: number;
  119053. private _system;
  119054. /**
  119055. * Creates a new Lens Flare.
  119056. * This represents one of the lens effect in a `lensFlareSystem`.
  119057. * It controls one of the indiviual texture used in the effect.
  119058. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119059. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119060. * @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.
  119061. * @param color Define the lens color
  119062. * @param imgUrl Define the lens texture url
  119063. * @param system Define the `lensFlareSystem` this flare is part of
  119064. * @returns The newly created Lens Flare
  119065. */
  119066. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119067. /**
  119068. * Instantiates a new Lens Flare.
  119069. * This represents one of the lens effect in a `lensFlareSystem`.
  119070. * It controls one of the indiviual texture used in the effect.
  119071. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119072. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119073. * @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.
  119074. * @param color Define the lens color
  119075. * @param imgUrl Define the lens texture url
  119076. * @param system Define the `lensFlareSystem` this flare is part of
  119077. */
  119078. constructor(
  119079. /**
  119080. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119081. */
  119082. size: number,
  119083. /**
  119084. * 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.
  119085. */
  119086. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119087. /**
  119088. * Dispose and release the lens flare with its associated resources.
  119089. */
  119090. dispose(): void;
  119091. }
  119092. }
  119093. declare module BABYLON {
  119094. interface AbstractScene {
  119095. /**
  119096. * The list of lens flare system added to the scene
  119097. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119098. */
  119099. lensFlareSystems: Array<LensFlareSystem>;
  119100. /**
  119101. * Removes the given lens flare system from this scene.
  119102. * @param toRemove The lens flare system to remove
  119103. * @returns The index of the removed lens flare system
  119104. */
  119105. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119106. /**
  119107. * Adds the given lens flare system to this scene
  119108. * @param newLensFlareSystem The lens flare system to add
  119109. */
  119110. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119111. /**
  119112. * Gets a lens flare system using its name
  119113. * @param name defines the name to look for
  119114. * @returns the lens flare system or null if not found
  119115. */
  119116. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119117. /**
  119118. * Gets a lens flare system using its id
  119119. * @param id defines the id to look for
  119120. * @returns the lens flare system or null if not found
  119121. */
  119122. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119123. }
  119124. /**
  119125. * Defines the lens flare scene component responsible to manage any lens flares
  119126. * in a given scene.
  119127. */
  119128. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119129. /**
  119130. * The component name helpfull to identify the component in the list of scene components.
  119131. */
  119132. readonly name: string;
  119133. /**
  119134. * The scene the component belongs to.
  119135. */
  119136. scene: Scene;
  119137. /**
  119138. * Creates a new instance of the component for the given scene
  119139. * @param scene Defines the scene to register the component in
  119140. */
  119141. constructor(scene: Scene);
  119142. /**
  119143. * Registers the component in a given scene
  119144. */
  119145. register(): void;
  119146. /**
  119147. * Rebuilds the elements related to this component in case of
  119148. * context lost for instance.
  119149. */
  119150. rebuild(): void;
  119151. /**
  119152. * Adds all the elements from the container to the scene
  119153. * @param container the container holding the elements
  119154. */
  119155. addFromContainer(container: AbstractScene): void;
  119156. /**
  119157. * Removes all the elements in the container from the scene
  119158. * @param container contains the elements to remove
  119159. * @param dispose if the removed element should be disposed (default: false)
  119160. */
  119161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119162. /**
  119163. * Serializes the component data to the specified json object
  119164. * @param serializationObject The object to serialize to
  119165. */
  119166. serialize(serializationObject: any): void;
  119167. /**
  119168. * Disposes the component and the associated ressources.
  119169. */
  119170. dispose(): void;
  119171. private _draw;
  119172. }
  119173. }
  119174. declare module BABYLON {
  119175. /**
  119176. * Defines the shadow generator component responsible to manage any shadow generators
  119177. * in a given scene.
  119178. */
  119179. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119180. /**
  119181. * The component name helpfull to identify the component in the list of scene components.
  119182. */
  119183. readonly name: string;
  119184. /**
  119185. * The scene the component belongs to.
  119186. */
  119187. scene: Scene;
  119188. /**
  119189. * Creates a new instance of the component for the given scene
  119190. * @param scene Defines the scene to register the component in
  119191. */
  119192. constructor(scene: Scene);
  119193. /**
  119194. * Registers the component in a given scene
  119195. */
  119196. register(): void;
  119197. /**
  119198. * Rebuilds the elements related to this component in case of
  119199. * context lost for instance.
  119200. */
  119201. rebuild(): void;
  119202. /**
  119203. * Serializes the component data to the specified json object
  119204. * @param serializationObject The object to serialize to
  119205. */
  119206. serialize(serializationObject: any): void;
  119207. /**
  119208. * Adds all the elements from the container to the scene
  119209. * @param container the container holding the elements
  119210. */
  119211. addFromContainer(container: AbstractScene): void;
  119212. /**
  119213. * Removes all the elements in the container from the scene
  119214. * @param container contains the elements to remove
  119215. * @param dispose if the removed element should be disposed (default: false)
  119216. */
  119217. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119218. /**
  119219. * Rebuilds the elements related to this component in case of
  119220. * context lost for instance.
  119221. */
  119222. dispose(): void;
  119223. private _gatherRenderTargets;
  119224. }
  119225. }
  119226. declare module BABYLON {
  119227. /**
  119228. * A point light is a light defined by an unique point in world space.
  119229. * The light is emitted in every direction from this point.
  119230. * A good example of a point light is a standard light bulb.
  119231. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119232. */
  119233. export class PointLight extends ShadowLight {
  119234. private _shadowAngle;
  119235. /**
  119236. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119237. * This specifies what angle the shadow will use to be created.
  119238. *
  119239. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119240. */
  119241. /**
  119242. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119243. * This specifies what angle the shadow will use to be created.
  119244. *
  119245. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119246. */
  119247. shadowAngle: number;
  119248. /**
  119249. * Gets the direction if it has been set.
  119250. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119251. */
  119252. /**
  119253. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119254. */
  119255. direction: Vector3;
  119256. /**
  119257. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119258. * A PointLight emits the light in every direction.
  119259. * It can cast shadows.
  119260. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119261. * ```javascript
  119262. * var pointLight = new PointLight("pl", camera.position, scene);
  119263. * ```
  119264. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119265. * @param name The light friendly name
  119266. * @param position The position of the point light in the scene
  119267. * @param scene The scene the lights belongs to
  119268. */
  119269. constructor(name: string, position: Vector3, scene: Scene);
  119270. /**
  119271. * Returns the string "PointLight"
  119272. * @returns the class name
  119273. */
  119274. getClassName(): string;
  119275. /**
  119276. * Returns the integer 0.
  119277. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119278. */
  119279. getTypeID(): number;
  119280. /**
  119281. * Specifies wether or not the shadowmap should be a cube texture.
  119282. * @returns true if the shadowmap needs to be a cube texture.
  119283. */
  119284. needCube(): boolean;
  119285. /**
  119286. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119287. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119288. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119289. */
  119290. getShadowDirection(faceIndex?: number): Vector3;
  119291. /**
  119292. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119293. * - fov = PI / 2
  119294. * - aspect ratio : 1.0
  119295. * - z-near and far equal to the active camera minZ and maxZ.
  119296. * Returns the PointLight.
  119297. */
  119298. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119299. protected _buildUniformLayout(): void;
  119300. /**
  119301. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119302. * @param effect The effect to update
  119303. * @param lightIndex The index of the light in the effect to update
  119304. * @returns The point light
  119305. */
  119306. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119307. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119308. /**
  119309. * Prepares the list of defines specific to the light type.
  119310. * @param defines the list of defines
  119311. * @param lightIndex defines the index of the light for the effect
  119312. */
  119313. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119314. }
  119315. }
  119316. declare module BABYLON {
  119317. /**
  119318. * Header information of HDR texture files.
  119319. */
  119320. export interface HDRInfo {
  119321. /**
  119322. * The height of the texture in pixels.
  119323. */
  119324. height: number;
  119325. /**
  119326. * The width of the texture in pixels.
  119327. */
  119328. width: number;
  119329. /**
  119330. * The index of the beginning of the data in the binary file.
  119331. */
  119332. dataPosition: number;
  119333. }
  119334. /**
  119335. * This groups tools to convert HDR texture to native colors array.
  119336. */
  119337. export class HDRTools {
  119338. private static Ldexp;
  119339. private static Rgbe2float;
  119340. private static readStringLine;
  119341. /**
  119342. * Reads header information from an RGBE texture stored in a native array.
  119343. * More information on this format are available here:
  119344. * https://en.wikipedia.org/wiki/RGBE_image_format
  119345. *
  119346. * @param uint8array The binary file stored in native array.
  119347. * @return The header information.
  119348. */
  119349. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119350. /**
  119351. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119352. * This RGBE texture needs to store the information as a panorama.
  119353. *
  119354. * More information on this format are available here:
  119355. * https://en.wikipedia.org/wiki/RGBE_image_format
  119356. *
  119357. * @param buffer The binary file stored in an array buffer.
  119358. * @param size The expected size of the extracted cubemap.
  119359. * @return The Cube Map information.
  119360. */
  119361. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119362. /**
  119363. * Returns the pixels data extracted from an RGBE texture.
  119364. * This pixels will be stored left to right up to down in the R G B order in one array.
  119365. *
  119366. * More information on this format are available here:
  119367. * https://en.wikipedia.org/wiki/RGBE_image_format
  119368. *
  119369. * @param uint8array The binary file stored in an array buffer.
  119370. * @param hdrInfo The header information of the file.
  119371. * @return The pixels data in RGB right to left up to down order.
  119372. */
  119373. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119374. private static RGBE_ReadPixels_RLE;
  119375. }
  119376. }
  119377. declare module BABYLON {
  119378. /**
  119379. * This represents a texture coming from an HDR input.
  119380. *
  119381. * The only supported format is currently panorama picture stored in RGBE format.
  119382. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119383. */
  119384. export class HDRCubeTexture extends BaseTexture {
  119385. private static _facesMapping;
  119386. private _generateHarmonics;
  119387. private _noMipmap;
  119388. private _textureMatrix;
  119389. private _size;
  119390. private _onLoad;
  119391. private _onError;
  119392. /**
  119393. * The texture URL.
  119394. */
  119395. url: string;
  119396. /**
  119397. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119398. */
  119399. coordinatesMode: number;
  119400. protected _isBlocking: boolean;
  119401. /**
  119402. * Sets wether or not the texture is blocking during loading.
  119403. */
  119404. /**
  119405. * Gets wether or not the texture is blocking during loading.
  119406. */
  119407. isBlocking: boolean;
  119408. protected _rotationY: number;
  119409. /**
  119410. * Sets texture matrix rotation angle around Y axis in radians.
  119411. */
  119412. /**
  119413. * Gets texture matrix rotation angle around Y axis radians.
  119414. */
  119415. rotationY: number;
  119416. /**
  119417. * Gets or sets the center of the bounding box associated with the cube texture
  119418. * It must define where the camera used to render the texture was set
  119419. */
  119420. boundingBoxPosition: Vector3;
  119421. private _boundingBoxSize;
  119422. /**
  119423. * Gets or sets the size of the bounding box associated with the cube texture
  119424. * When defined, the cubemap will switch to local mode
  119425. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119426. * @example https://www.babylonjs-playground.com/#RNASML
  119427. */
  119428. boundingBoxSize: Vector3;
  119429. /**
  119430. * Instantiates an HDRTexture from the following parameters.
  119431. *
  119432. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119433. * @param scene The scene the texture will be used in
  119434. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119435. * @param noMipmap Forces to not generate the mipmap if true
  119436. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119437. * @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)
  119438. * @param reserved Reserved flag for internal use.
  119439. */
  119440. 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>);
  119441. /**
  119442. * Get the current class name of the texture useful for serialization or dynamic coding.
  119443. * @returns "HDRCubeTexture"
  119444. */
  119445. getClassName(): string;
  119446. /**
  119447. * Occurs when the file is raw .hdr file.
  119448. */
  119449. private loadTexture;
  119450. clone(): HDRCubeTexture;
  119451. delayLoad(): void;
  119452. /**
  119453. * Get the texture reflection matrix used to rotate/transform the reflection.
  119454. * @returns the reflection matrix
  119455. */
  119456. getReflectionTextureMatrix(): Matrix;
  119457. /**
  119458. * Set the texture reflection matrix used to rotate/transform the reflection.
  119459. * @param value Define the reflection matrix to set
  119460. */
  119461. setReflectionTextureMatrix(value: Matrix): void;
  119462. /**
  119463. * Parses a JSON representation of an HDR Texture in order to create the texture
  119464. * @param parsedTexture Define the JSON representation
  119465. * @param scene Define the scene the texture should be created in
  119466. * @param rootUrl Define the root url in case we need to load relative dependencies
  119467. * @returns the newly created texture after parsing
  119468. */
  119469. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119470. serialize(): any;
  119471. }
  119472. }
  119473. declare module BABYLON {
  119474. /**
  119475. * Class used to control physics engine
  119476. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119477. */
  119478. export class PhysicsEngine implements IPhysicsEngine {
  119479. private _physicsPlugin;
  119480. /**
  119481. * Global value used to control the smallest number supported by the simulation
  119482. */
  119483. static Epsilon: number;
  119484. private _impostors;
  119485. private _joints;
  119486. /**
  119487. * Gets the gravity vector used by the simulation
  119488. */
  119489. gravity: Vector3;
  119490. /**
  119491. * Factory used to create the default physics plugin.
  119492. * @returns The default physics plugin
  119493. */
  119494. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119495. /**
  119496. * Creates a new Physics Engine
  119497. * @param gravity defines the gravity vector used by the simulation
  119498. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119499. */
  119500. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119501. /**
  119502. * Sets the gravity vector used by the simulation
  119503. * @param gravity defines the gravity vector to use
  119504. */
  119505. setGravity(gravity: Vector3): void;
  119506. /**
  119507. * Set the time step of the physics engine.
  119508. * Default is 1/60.
  119509. * To slow it down, enter 1/600 for example.
  119510. * To speed it up, 1/30
  119511. * @param newTimeStep defines the new timestep to apply to this world.
  119512. */
  119513. setTimeStep(newTimeStep?: number): void;
  119514. /**
  119515. * Get the time step of the physics engine.
  119516. * @returns the current time step
  119517. */
  119518. getTimeStep(): number;
  119519. /**
  119520. * Release all resources
  119521. */
  119522. dispose(): void;
  119523. /**
  119524. * Gets the name of the current physics plugin
  119525. * @returns the name of the plugin
  119526. */
  119527. getPhysicsPluginName(): string;
  119528. /**
  119529. * Adding a new impostor for the impostor tracking.
  119530. * This will be done by the impostor itself.
  119531. * @param impostor the impostor to add
  119532. */
  119533. addImpostor(impostor: PhysicsImpostor): void;
  119534. /**
  119535. * Remove an impostor from the engine.
  119536. * This impostor and its mesh will not longer be updated by the physics engine.
  119537. * @param impostor the impostor to remove
  119538. */
  119539. removeImpostor(impostor: PhysicsImpostor): void;
  119540. /**
  119541. * Add a joint to the physics engine
  119542. * @param mainImpostor defines the main impostor to which the joint is added.
  119543. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119544. * @param joint defines the joint that will connect both impostors.
  119545. */
  119546. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119547. /**
  119548. * Removes a joint from the simulation
  119549. * @param mainImpostor defines the impostor used with the joint
  119550. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119551. * @param joint defines the joint to remove
  119552. */
  119553. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119554. /**
  119555. * Called by the scene. No need to call it.
  119556. * @param delta defines the timespam between frames
  119557. */
  119558. _step(delta: number): void;
  119559. /**
  119560. * Gets the current plugin used to run the simulation
  119561. * @returns current plugin
  119562. */
  119563. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119564. /**
  119565. * Gets the list of physic impostors
  119566. * @returns an array of PhysicsImpostor
  119567. */
  119568. getImpostors(): Array<PhysicsImpostor>;
  119569. /**
  119570. * Gets the impostor for a physics enabled object
  119571. * @param object defines the object impersonated by the impostor
  119572. * @returns the PhysicsImpostor or null if not found
  119573. */
  119574. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119575. /**
  119576. * Gets the impostor for a physics body object
  119577. * @param body defines physics body used by the impostor
  119578. * @returns the PhysicsImpostor or null if not found
  119579. */
  119580. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119581. /**
  119582. * Does a raycast in the physics world
  119583. * @param from when should the ray start?
  119584. * @param to when should the ray end?
  119585. * @returns PhysicsRaycastResult
  119586. */
  119587. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119588. }
  119589. }
  119590. declare module BABYLON {
  119591. /** @hidden */
  119592. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119593. private _useDeltaForWorldStep;
  119594. world: any;
  119595. name: string;
  119596. private _physicsMaterials;
  119597. private _fixedTimeStep;
  119598. private _cannonRaycastResult;
  119599. private _raycastResult;
  119600. private _physicsBodysToRemoveAfterStep;
  119601. BJSCANNON: any;
  119602. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119603. setGravity(gravity: Vector3): void;
  119604. setTimeStep(timeStep: number): void;
  119605. getTimeStep(): number;
  119606. executeStep(delta: number): void;
  119607. private _removeMarkedPhysicsBodiesFromWorld;
  119608. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119609. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119610. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119611. private _processChildMeshes;
  119612. removePhysicsBody(impostor: PhysicsImpostor): void;
  119613. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119614. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119615. private _addMaterial;
  119616. private _checkWithEpsilon;
  119617. private _createShape;
  119618. private _createHeightmap;
  119619. private _minus90X;
  119620. private _plus90X;
  119621. private _tmpPosition;
  119622. private _tmpDeltaPosition;
  119623. private _tmpUnityRotation;
  119624. private _updatePhysicsBodyTransformation;
  119625. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119626. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119627. isSupported(): boolean;
  119628. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119629. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119630. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119631. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119632. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119633. getBodyMass(impostor: PhysicsImpostor): number;
  119634. getBodyFriction(impostor: PhysicsImpostor): number;
  119635. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119636. getBodyRestitution(impostor: PhysicsImpostor): number;
  119637. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119638. sleepBody(impostor: PhysicsImpostor): void;
  119639. wakeUpBody(impostor: PhysicsImpostor): void;
  119640. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119641. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119642. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119643. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119644. getRadius(impostor: PhysicsImpostor): number;
  119645. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119646. dispose(): void;
  119647. private _extendNamespace;
  119648. /**
  119649. * Does a raycast in the physics world
  119650. * @param from when should the ray start?
  119651. * @param to when should the ray end?
  119652. * @returns PhysicsRaycastResult
  119653. */
  119654. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119655. }
  119656. }
  119657. declare module BABYLON {
  119658. /** @hidden */
  119659. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  119660. world: any;
  119661. name: string;
  119662. BJSOIMO: any;
  119663. private _raycastResult;
  119664. constructor(iterations?: number, oimoInjection?: any);
  119665. setGravity(gravity: Vector3): void;
  119666. setTimeStep(timeStep: number): void;
  119667. getTimeStep(): number;
  119668. private _tmpImpostorsArray;
  119669. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119670. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119671. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119672. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119673. private _tmpPositionVector;
  119674. removePhysicsBody(impostor: PhysicsImpostor): void;
  119675. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119676. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119677. isSupported(): boolean;
  119678. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119679. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119680. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119681. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119682. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119683. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119684. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119685. getBodyMass(impostor: PhysicsImpostor): number;
  119686. getBodyFriction(impostor: PhysicsImpostor): number;
  119687. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119688. getBodyRestitution(impostor: PhysicsImpostor): number;
  119689. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119690. sleepBody(impostor: PhysicsImpostor): void;
  119691. wakeUpBody(impostor: PhysicsImpostor): void;
  119692. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119693. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119694. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119695. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119696. getRadius(impostor: PhysicsImpostor): number;
  119697. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119698. dispose(): void;
  119699. /**
  119700. * Does a raycast in the physics world
  119701. * @param from when should the ray start?
  119702. * @param to when should the ray end?
  119703. * @returns PhysicsRaycastResult
  119704. */
  119705. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119706. }
  119707. }
  119708. declare module BABYLON {
  119709. /**
  119710. * Class containing static functions to help procedurally build meshes
  119711. */
  119712. export class RibbonBuilder {
  119713. /**
  119714. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119715. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119716. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119717. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119718. * * 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
  119719. * * 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
  119720. * * 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
  119721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119724. * * 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
  119725. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119726. * * 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
  119727. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119729. * @param name defines the name of the mesh
  119730. * @param options defines the options used to create the mesh
  119731. * @param scene defines the hosting scene
  119732. * @returns the ribbon mesh
  119733. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119735. */
  119736. static CreateRibbon(name: string, options: {
  119737. pathArray: Vector3[][];
  119738. closeArray?: boolean;
  119739. closePath?: boolean;
  119740. offset?: number;
  119741. updatable?: boolean;
  119742. sideOrientation?: number;
  119743. frontUVs?: Vector4;
  119744. backUVs?: Vector4;
  119745. instance?: Mesh;
  119746. invertUV?: boolean;
  119747. uvs?: Vector2[];
  119748. colors?: Color4[];
  119749. }, scene?: Nullable<Scene>): Mesh;
  119750. }
  119751. }
  119752. declare module BABYLON {
  119753. /**
  119754. * Class containing static functions to help procedurally build meshes
  119755. */
  119756. export class ShapeBuilder {
  119757. /**
  119758. * 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.
  119759. * * 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.
  119760. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119761. * * 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.
  119762. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119763. * * 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
  119764. * * 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
  119765. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119768. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119770. * @param name defines the name of the mesh
  119771. * @param options defines the options used to create the mesh
  119772. * @param scene defines the hosting scene
  119773. * @returns the extruded shape mesh
  119774. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119776. */
  119777. static ExtrudeShape(name: string, options: {
  119778. shape: Vector3[];
  119779. path: Vector3[];
  119780. scale?: number;
  119781. rotation?: number;
  119782. cap?: number;
  119783. updatable?: boolean;
  119784. sideOrientation?: number;
  119785. frontUVs?: Vector4;
  119786. backUVs?: Vector4;
  119787. instance?: Mesh;
  119788. invertUV?: boolean;
  119789. }, scene?: Nullable<Scene>): Mesh;
  119790. /**
  119791. * Creates an custom extruded shape mesh.
  119792. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119793. * * 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.
  119794. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119795. * * 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
  119796. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119797. * * 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
  119798. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119799. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119800. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119801. * * 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
  119802. * * 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
  119803. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119808. * @param name defines the name of the mesh
  119809. * @param options defines the options used to create the mesh
  119810. * @param scene defines the hosting scene
  119811. * @returns the custom extruded shape mesh
  119812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119813. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119815. */
  119816. static ExtrudeShapeCustom(name: string, options: {
  119817. shape: Vector3[];
  119818. path: Vector3[];
  119819. scaleFunction?: any;
  119820. rotationFunction?: any;
  119821. ribbonCloseArray?: boolean;
  119822. ribbonClosePath?: boolean;
  119823. cap?: number;
  119824. updatable?: boolean;
  119825. sideOrientation?: number;
  119826. frontUVs?: Vector4;
  119827. backUVs?: Vector4;
  119828. instance?: Mesh;
  119829. invertUV?: boolean;
  119830. }, scene?: Nullable<Scene>): Mesh;
  119831. private static _ExtrudeShapeGeneric;
  119832. }
  119833. }
  119834. declare module BABYLON {
  119835. /**
  119836. * AmmoJS Physics plugin
  119837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  119838. * @see https://github.com/kripken/ammo.js/
  119839. */
  119840. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  119841. private _useDeltaForWorldStep;
  119842. /**
  119843. * Reference to the Ammo library
  119844. */
  119845. bjsAMMO: any;
  119846. /**
  119847. * Created ammoJS world which physics bodies are added to
  119848. */
  119849. world: any;
  119850. /**
  119851. * Name of the plugin
  119852. */
  119853. name: string;
  119854. private _timeStep;
  119855. private _fixedTimeStep;
  119856. private _maxSteps;
  119857. private _tmpQuaternion;
  119858. private _tmpAmmoTransform;
  119859. private _tmpAmmoQuaternion;
  119860. private _tmpAmmoConcreteContactResultCallback;
  119861. private _collisionConfiguration;
  119862. private _dispatcher;
  119863. private _overlappingPairCache;
  119864. private _solver;
  119865. private _softBodySolver;
  119866. private _tmpAmmoVectorA;
  119867. private _tmpAmmoVectorB;
  119868. private _tmpAmmoVectorC;
  119869. private _tmpAmmoVectorD;
  119870. private _tmpContactCallbackResult;
  119871. private _tmpAmmoVectorRCA;
  119872. private _tmpAmmoVectorRCB;
  119873. private _raycastResult;
  119874. private static readonly DISABLE_COLLISION_FLAG;
  119875. private static readonly KINEMATIC_FLAG;
  119876. private static readonly DISABLE_DEACTIVATION_FLAG;
  119877. /**
  119878. * Initializes the ammoJS plugin
  119879. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  119880. * @param ammoInjection can be used to inject your own ammo reference
  119881. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  119882. */
  119883. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  119884. /**
  119885. * Sets the gravity of the physics world (m/(s^2))
  119886. * @param gravity Gravity to set
  119887. */
  119888. setGravity(gravity: Vector3): void;
  119889. /**
  119890. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  119891. * @param timeStep timestep to use in seconds
  119892. */
  119893. setTimeStep(timeStep: number): void;
  119894. /**
  119895. * 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)
  119896. * @param fixedTimeStep fixedTimeStep to use in seconds
  119897. */
  119898. setFixedTimeStep(fixedTimeStep: number): void;
  119899. /**
  119900. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  119901. * @param maxSteps the maximum number of steps by the physics engine per frame
  119902. */
  119903. setMaxSteps(maxSteps: number): void;
  119904. /**
  119905. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  119906. * @returns the current timestep in seconds
  119907. */
  119908. getTimeStep(): number;
  119909. private _isImpostorInContact;
  119910. private _isImpostorPairInContact;
  119911. private _stepSimulation;
  119912. /**
  119913. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  119914. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  119915. * After the step the babylon meshes are set to the position of the physics imposters
  119916. * @param delta amount of time to step forward
  119917. * @param impostors array of imposters to update before/after the step
  119918. */
  119919. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119920. /**
  119921. * Update babylon mesh to match physics world object
  119922. * @param impostor imposter to match
  119923. */
  119924. private _afterSoftStep;
  119925. /**
  119926. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119927. * @param impostor imposter to match
  119928. */
  119929. private _ropeStep;
  119930. /**
  119931. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119932. * @param impostor imposter to match
  119933. */
  119934. private _softbodyOrClothStep;
  119935. private _tmpVector;
  119936. private _tmpMatrix;
  119937. /**
  119938. * Applies an impulse on the imposter
  119939. * @param impostor imposter to apply impulse to
  119940. * @param force amount of force to be applied to the imposter
  119941. * @param contactPoint the location to apply the impulse on the imposter
  119942. */
  119943. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119944. /**
  119945. * Applies a force on the imposter
  119946. * @param impostor imposter to apply force
  119947. * @param force amount of force to be applied to the imposter
  119948. * @param contactPoint the location to apply the force on the imposter
  119949. */
  119950. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119951. /**
  119952. * Creates a physics body using the plugin
  119953. * @param impostor the imposter to create the physics body on
  119954. */
  119955. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119956. /**
  119957. * Removes the physics body from the imposter and disposes of the body's memory
  119958. * @param impostor imposter to remove the physics body from
  119959. */
  119960. removePhysicsBody(impostor: PhysicsImpostor): void;
  119961. /**
  119962. * Generates a joint
  119963. * @param impostorJoint the imposter joint to create the joint with
  119964. */
  119965. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119966. /**
  119967. * Removes a joint
  119968. * @param impostorJoint the imposter joint to remove the joint from
  119969. */
  119970. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119971. private _addMeshVerts;
  119972. /**
  119973. * Initialise the soft body vertices to match its object's (mesh) vertices
  119974. * Softbody vertices (nodes) are in world space and to match this
  119975. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  119976. * @param impostor to create the softbody for
  119977. */
  119978. private _softVertexData;
  119979. /**
  119980. * Create an impostor's soft body
  119981. * @param impostor to create the softbody for
  119982. */
  119983. private _createSoftbody;
  119984. /**
  119985. * Create cloth for an impostor
  119986. * @param impostor to create the softbody for
  119987. */
  119988. private _createCloth;
  119989. /**
  119990. * Create rope for an impostor
  119991. * @param impostor to create the softbody for
  119992. */
  119993. private _createRope;
  119994. private _addHullVerts;
  119995. private _createShape;
  119996. /**
  119997. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  119998. * @param impostor imposter containing the physics body and babylon object
  119999. */
  120000. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120001. /**
  120002. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120003. * @param impostor imposter containing the physics body and babylon object
  120004. * @param newPosition new position
  120005. * @param newRotation new rotation
  120006. */
  120007. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120008. /**
  120009. * If this plugin is supported
  120010. * @returns true if its supported
  120011. */
  120012. isSupported(): boolean;
  120013. /**
  120014. * Sets the linear velocity of the physics body
  120015. * @param impostor imposter to set the velocity on
  120016. * @param velocity velocity to set
  120017. */
  120018. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120019. /**
  120020. * Sets the angular velocity of the physics body
  120021. * @param impostor imposter to set the velocity on
  120022. * @param velocity velocity to set
  120023. */
  120024. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120025. /**
  120026. * gets the linear velocity
  120027. * @param impostor imposter to get linear velocity from
  120028. * @returns linear velocity
  120029. */
  120030. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120031. /**
  120032. * gets the angular velocity
  120033. * @param impostor imposter to get angular velocity from
  120034. * @returns angular velocity
  120035. */
  120036. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120037. /**
  120038. * Sets the mass of physics body
  120039. * @param impostor imposter to set the mass on
  120040. * @param mass mass to set
  120041. */
  120042. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120043. /**
  120044. * Gets the mass of the physics body
  120045. * @param impostor imposter to get the mass from
  120046. * @returns mass
  120047. */
  120048. getBodyMass(impostor: PhysicsImpostor): number;
  120049. /**
  120050. * Gets friction of the impostor
  120051. * @param impostor impostor to get friction from
  120052. * @returns friction value
  120053. */
  120054. getBodyFriction(impostor: PhysicsImpostor): number;
  120055. /**
  120056. * Sets friction of the impostor
  120057. * @param impostor impostor to set friction on
  120058. * @param friction friction value
  120059. */
  120060. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120061. /**
  120062. * Gets restitution of the impostor
  120063. * @param impostor impostor to get restitution from
  120064. * @returns restitution value
  120065. */
  120066. getBodyRestitution(impostor: PhysicsImpostor): number;
  120067. /**
  120068. * Sets resitution of the impostor
  120069. * @param impostor impostor to set resitution on
  120070. * @param restitution resitution value
  120071. */
  120072. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120073. /**
  120074. * Gets pressure inside the impostor
  120075. * @param impostor impostor to get pressure from
  120076. * @returns pressure value
  120077. */
  120078. getBodyPressure(impostor: PhysicsImpostor): number;
  120079. /**
  120080. * Sets pressure inside a soft body impostor
  120081. * Cloth and rope must remain 0 pressure
  120082. * @param impostor impostor to set pressure on
  120083. * @param pressure pressure value
  120084. */
  120085. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120086. /**
  120087. * Gets stiffness of the impostor
  120088. * @param impostor impostor to get stiffness from
  120089. * @returns pressure value
  120090. */
  120091. getBodyStiffness(impostor: PhysicsImpostor): number;
  120092. /**
  120093. * Sets stiffness of the impostor
  120094. * @param impostor impostor to set stiffness on
  120095. * @param stiffness stiffness value from 0 to 1
  120096. */
  120097. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120098. /**
  120099. * Gets velocityIterations of the impostor
  120100. * @param impostor impostor to get velocity iterations from
  120101. * @returns velocityIterations value
  120102. */
  120103. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120104. /**
  120105. * Sets velocityIterations of the impostor
  120106. * @param impostor impostor to set velocity iterations on
  120107. * @param velocityIterations velocityIterations value
  120108. */
  120109. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120110. /**
  120111. * Gets positionIterations of the impostor
  120112. * @param impostor impostor to get position iterations from
  120113. * @returns positionIterations value
  120114. */
  120115. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120116. /**
  120117. * Sets positionIterations of the impostor
  120118. * @param impostor impostor to set position on
  120119. * @param positionIterations positionIterations value
  120120. */
  120121. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120122. /**
  120123. * Append an anchor to a cloth object
  120124. * @param impostor is the cloth impostor to add anchor to
  120125. * @param otherImpostor is the rigid impostor to anchor to
  120126. * @param width ratio across width from 0 to 1
  120127. * @param height ratio up height from 0 to 1
  120128. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120129. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120130. */
  120131. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120132. /**
  120133. * Append an hook to a rope object
  120134. * @param impostor is the rope impostor to add hook to
  120135. * @param otherImpostor is the rigid impostor to hook to
  120136. * @param length ratio along the rope from 0 to 1
  120137. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120138. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120139. */
  120140. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120141. /**
  120142. * Sleeps the physics body and stops it from being active
  120143. * @param impostor impostor to sleep
  120144. */
  120145. sleepBody(impostor: PhysicsImpostor): void;
  120146. /**
  120147. * Activates the physics body
  120148. * @param impostor impostor to activate
  120149. */
  120150. wakeUpBody(impostor: PhysicsImpostor): void;
  120151. /**
  120152. * Updates the distance parameters of the joint
  120153. * @param joint joint to update
  120154. * @param maxDistance maximum distance of the joint
  120155. * @param minDistance minimum distance of the joint
  120156. */
  120157. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120158. /**
  120159. * Sets a motor on the joint
  120160. * @param joint joint to set motor on
  120161. * @param speed speed of the motor
  120162. * @param maxForce maximum force of the motor
  120163. * @param motorIndex index of the motor
  120164. */
  120165. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120166. /**
  120167. * Sets the motors limit
  120168. * @param joint joint to set limit on
  120169. * @param upperLimit upper limit
  120170. * @param lowerLimit lower limit
  120171. */
  120172. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120173. /**
  120174. * Syncs the position and rotation of a mesh with the impostor
  120175. * @param mesh mesh to sync
  120176. * @param impostor impostor to update the mesh with
  120177. */
  120178. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120179. /**
  120180. * Gets the radius of the impostor
  120181. * @param impostor impostor to get radius from
  120182. * @returns the radius
  120183. */
  120184. getRadius(impostor: PhysicsImpostor): number;
  120185. /**
  120186. * Gets the box size of the impostor
  120187. * @param impostor impostor to get box size from
  120188. * @param result the resulting box size
  120189. */
  120190. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120191. /**
  120192. * Disposes of the impostor
  120193. */
  120194. dispose(): void;
  120195. /**
  120196. * Does a raycast in the physics world
  120197. * @param from when should the ray start?
  120198. * @param to when should the ray end?
  120199. * @returns PhysicsRaycastResult
  120200. */
  120201. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120202. }
  120203. }
  120204. declare module BABYLON {
  120205. interface AbstractScene {
  120206. /**
  120207. * The list of reflection probes added to the scene
  120208. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120209. */
  120210. reflectionProbes: Array<ReflectionProbe>;
  120211. /**
  120212. * Removes the given reflection probe from this scene.
  120213. * @param toRemove The reflection probe to remove
  120214. * @returns The index of the removed reflection probe
  120215. */
  120216. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120217. /**
  120218. * Adds the given reflection probe to this scene.
  120219. * @param newReflectionProbe The reflection probe to add
  120220. */
  120221. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120222. }
  120223. /**
  120224. * Class used to generate realtime reflection / refraction cube textures
  120225. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120226. */
  120227. export class ReflectionProbe {
  120228. /** defines the name of the probe */
  120229. name: string;
  120230. private _scene;
  120231. private _renderTargetTexture;
  120232. private _projectionMatrix;
  120233. private _viewMatrix;
  120234. private _target;
  120235. private _add;
  120236. private _attachedMesh;
  120237. private _invertYAxis;
  120238. /** Gets or sets probe position (center of the cube map) */
  120239. position: Vector3;
  120240. /**
  120241. * Creates a new reflection probe
  120242. * @param name defines the name of the probe
  120243. * @param size defines the texture resolution (for each face)
  120244. * @param scene defines the hosting scene
  120245. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120246. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120247. */
  120248. constructor(
  120249. /** defines the name of the probe */
  120250. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120251. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120252. samples: number;
  120253. /** Gets or sets the refresh rate to use (on every frame by default) */
  120254. refreshRate: number;
  120255. /**
  120256. * Gets the hosting scene
  120257. * @returns a Scene
  120258. */
  120259. getScene(): Scene;
  120260. /** Gets the internal CubeTexture used to render to */
  120261. readonly cubeTexture: RenderTargetTexture;
  120262. /** Gets the list of meshes to render */
  120263. readonly renderList: Nullable<AbstractMesh[]>;
  120264. /**
  120265. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120266. * @param mesh defines the mesh to attach to
  120267. */
  120268. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120269. /**
  120270. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120271. * @param renderingGroupId The rendering group id corresponding to its index
  120272. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120273. */
  120274. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120275. /**
  120276. * Clean all associated resources
  120277. */
  120278. dispose(): void;
  120279. /**
  120280. * Converts the reflection probe information to a readable string for debug purpose.
  120281. * @param fullDetails Supports for multiple levels of logging within scene loading
  120282. * @returns the human readable reflection probe info
  120283. */
  120284. toString(fullDetails?: boolean): string;
  120285. /**
  120286. * Get the class name of the relfection probe.
  120287. * @returns "ReflectionProbe"
  120288. */
  120289. getClassName(): string;
  120290. /**
  120291. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120292. * @returns The JSON representation of the texture
  120293. */
  120294. serialize(): any;
  120295. /**
  120296. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120297. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120298. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120299. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120300. * @returns The parsed reflection probe if successful
  120301. */
  120302. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120303. }
  120304. }
  120305. declare module BABYLON {
  120306. /** @hidden */
  120307. export var _BabylonLoaderRegistered: boolean;
  120308. /**
  120309. * Helps setting up some configuration for the babylon file loader.
  120310. */
  120311. export class BabylonFileLoaderConfiguration {
  120312. /**
  120313. * The loader does not allow injecting custom physix engine into the plugins.
  120314. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120315. * So you could set this variable to your engine import to make it work.
  120316. */
  120317. static LoaderInjectedPhysicsEngine: any;
  120318. }
  120319. }
  120320. declare module BABYLON {
  120321. /**
  120322. * The Physically based simple base material of BJS.
  120323. *
  120324. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120325. * It is used as the base class for both the specGloss and metalRough conventions.
  120326. */
  120327. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120328. /**
  120329. * Number of Simultaneous lights allowed on the material.
  120330. */
  120331. maxSimultaneousLights: number;
  120332. /**
  120333. * If sets to true, disables all the lights affecting the material.
  120334. */
  120335. disableLighting: boolean;
  120336. /**
  120337. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120338. */
  120339. environmentTexture: BaseTexture;
  120340. /**
  120341. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120342. */
  120343. invertNormalMapX: boolean;
  120344. /**
  120345. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120346. */
  120347. invertNormalMapY: boolean;
  120348. /**
  120349. * Normal map used in the model.
  120350. */
  120351. normalTexture: BaseTexture;
  120352. /**
  120353. * Emissivie color used to self-illuminate the model.
  120354. */
  120355. emissiveColor: Color3;
  120356. /**
  120357. * Emissivie texture used to self-illuminate the model.
  120358. */
  120359. emissiveTexture: BaseTexture;
  120360. /**
  120361. * Occlusion Channel Strenght.
  120362. */
  120363. occlusionStrength: number;
  120364. /**
  120365. * Occlusion Texture of the material (adding extra occlusion effects).
  120366. */
  120367. occlusionTexture: BaseTexture;
  120368. /**
  120369. * Defines the alpha limits in alpha test mode.
  120370. */
  120371. alphaCutOff: number;
  120372. /**
  120373. * Gets the current double sided mode.
  120374. */
  120375. /**
  120376. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120377. */
  120378. doubleSided: boolean;
  120379. /**
  120380. * Stores the pre-calculated light information of a mesh in a texture.
  120381. */
  120382. lightmapTexture: BaseTexture;
  120383. /**
  120384. * If true, the light map contains occlusion information instead of lighting info.
  120385. */
  120386. useLightmapAsShadowmap: boolean;
  120387. /**
  120388. * Instantiates a new PBRMaterial instance.
  120389. *
  120390. * @param name The material name
  120391. * @param scene The scene the material will be use in.
  120392. */
  120393. constructor(name: string, scene: Scene);
  120394. getClassName(): string;
  120395. }
  120396. }
  120397. declare module BABYLON {
  120398. /**
  120399. * The PBR material of BJS following the metal roughness convention.
  120400. *
  120401. * This fits to the PBR convention in the GLTF definition:
  120402. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120403. */
  120404. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120405. /**
  120406. * The base color has two different interpretations depending on the value of metalness.
  120407. * When the material is a metal, the base color is the specific measured reflectance value
  120408. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120409. * of the material.
  120410. */
  120411. baseColor: Color3;
  120412. /**
  120413. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120414. * well as opacity information in the alpha channel.
  120415. */
  120416. baseTexture: BaseTexture;
  120417. /**
  120418. * Specifies the metallic scalar value of the material.
  120419. * Can also be used to scale the metalness values of the metallic texture.
  120420. */
  120421. metallic: number;
  120422. /**
  120423. * Specifies the roughness scalar value of the material.
  120424. * Can also be used to scale the roughness values of the metallic texture.
  120425. */
  120426. roughness: number;
  120427. /**
  120428. * Texture containing both the metallic value in the B channel and the
  120429. * roughness value in the G channel to keep better precision.
  120430. */
  120431. metallicRoughnessTexture: BaseTexture;
  120432. /**
  120433. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120434. *
  120435. * @param name The material name
  120436. * @param scene The scene the material will be use in.
  120437. */
  120438. constructor(name: string, scene: Scene);
  120439. /**
  120440. * Return the currrent class name of the material.
  120441. */
  120442. getClassName(): string;
  120443. /**
  120444. * Makes a duplicate of the current material.
  120445. * @param name - name to use for the new material.
  120446. */
  120447. clone(name: string): PBRMetallicRoughnessMaterial;
  120448. /**
  120449. * Serialize the material to a parsable JSON object.
  120450. */
  120451. serialize(): any;
  120452. /**
  120453. * Parses a JSON object correponding to the serialize function.
  120454. */
  120455. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120456. }
  120457. }
  120458. declare module BABYLON {
  120459. /**
  120460. * The PBR material of BJS following the specular glossiness convention.
  120461. *
  120462. * This fits to the PBR convention in the GLTF definition:
  120463. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120464. */
  120465. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120466. /**
  120467. * Specifies the diffuse color of the material.
  120468. */
  120469. diffuseColor: Color3;
  120470. /**
  120471. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120472. * channel.
  120473. */
  120474. diffuseTexture: BaseTexture;
  120475. /**
  120476. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120477. */
  120478. specularColor: Color3;
  120479. /**
  120480. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120481. */
  120482. glossiness: number;
  120483. /**
  120484. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120485. */
  120486. specularGlossinessTexture: BaseTexture;
  120487. /**
  120488. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120489. *
  120490. * @param name The material name
  120491. * @param scene The scene the material will be use in.
  120492. */
  120493. constructor(name: string, scene: Scene);
  120494. /**
  120495. * Return the currrent class name of the material.
  120496. */
  120497. getClassName(): string;
  120498. /**
  120499. * Makes a duplicate of the current material.
  120500. * @param name - name to use for the new material.
  120501. */
  120502. clone(name: string): PBRSpecularGlossinessMaterial;
  120503. /**
  120504. * Serialize the material to a parsable JSON object.
  120505. */
  120506. serialize(): any;
  120507. /**
  120508. * Parses a JSON object correponding to the serialize function.
  120509. */
  120510. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120511. }
  120512. }
  120513. declare module BABYLON {
  120514. /**
  120515. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120516. * It can help converting any input color in a desired output one. This can then be used to create effects
  120517. * from sepia, black and white to sixties or futuristic rendering...
  120518. *
  120519. * The only supported format is currently 3dl.
  120520. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120521. */
  120522. export class ColorGradingTexture extends BaseTexture {
  120523. /**
  120524. * The current texture matrix. (will always be identity in color grading texture)
  120525. */
  120526. private _textureMatrix;
  120527. /**
  120528. * The texture URL.
  120529. */
  120530. url: string;
  120531. /**
  120532. * Empty line regex stored for GC.
  120533. */
  120534. private static _noneEmptyLineRegex;
  120535. private _engine;
  120536. /**
  120537. * Instantiates a ColorGradingTexture from the following parameters.
  120538. *
  120539. * @param url The location of the color gradind data (currently only supporting 3dl)
  120540. * @param scene The scene the texture will be used in
  120541. */
  120542. constructor(url: string, scene: Scene);
  120543. /**
  120544. * Returns the texture matrix used in most of the material.
  120545. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120546. */
  120547. getTextureMatrix(): Matrix;
  120548. /**
  120549. * Occurs when the file being loaded is a .3dl LUT file.
  120550. */
  120551. private load3dlTexture;
  120552. /**
  120553. * Starts the loading process of the texture.
  120554. */
  120555. private loadTexture;
  120556. /**
  120557. * Clones the color gradind texture.
  120558. */
  120559. clone(): ColorGradingTexture;
  120560. /**
  120561. * Called during delayed load for textures.
  120562. */
  120563. delayLoad(): void;
  120564. /**
  120565. * Parses a color grading texture serialized by Babylon.
  120566. * @param parsedTexture The texture information being parsedTexture
  120567. * @param scene The scene to load the texture in
  120568. * @param rootUrl The root url of the data assets to load
  120569. * @return A color gradind texture
  120570. */
  120571. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120572. /**
  120573. * Serializes the LUT texture to json format.
  120574. */
  120575. serialize(): any;
  120576. }
  120577. }
  120578. declare module BABYLON {
  120579. /**
  120580. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120581. */
  120582. export class EquiRectangularCubeTexture extends BaseTexture {
  120583. /** The six faces of the cube. */
  120584. private static _FacesMapping;
  120585. private _noMipmap;
  120586. private _onLoad;
  120587. private _onError;
  120588. /** The size of the cubemap. */
  120589. private _size;
  120590. /** The buffer of the image. */
  120591. private _buffer;
  120592. /** The width of the input image. */
  120593. private _width;
  120594. /** The height of the input image. */
  120595. private _height;
  120596. /** The URL to the image. */
  120597. url: string;
  120598. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120599. coordinatesMode: number;
  120600. /**
  120601. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120602. * @param url The location of the image
  120603. * @param scene The scene the texture will be used in
  120604. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120605. * @param noMipmap Forces to not generate the mipmap if true
  120606. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120607. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120608. * @param onLoad — defines a callback called when texture is loaded
  120609. * @param onError — defines a callback called if there is an error
  120610. */
  120611. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120612. /**
  120613. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120614. */
  120615. private loadImage;
  120616. /**
  120617. * Convert the image buffer into a cubemap and create a CubeTexture.
  120618. */
  120619. private loadTexture;
  120620. /**
  120621. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120622. * @param buffer The ArrayBuffer that should be converted.
  120623. * @returns The buffer as Float32Array.
  120624. */
  120625. private getFloat32ArrayFromArrayBuffer;
  120626. /**
  120627. * Get the current class name of the texture useful for serialization or dynamic coding.
  120628. * @returns "EquiRectangularCubeTexture"
  120629. */
  120630. getClassName(): string;
  120631. /**
  120632. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120633. * @returns A clone of the current EquiRectangularCubeTexture.
  120634. */
  120635. clone(): EquiRectangularCubeTexture;
  120636. }
  120637. }
  120638. declare module BABYLON {
  120639. /**
  120640. * Based on jsTGALoader - Javascript loader for TGA file
  120641. * By Vincent Thibault
  120642. * @see http://blog.robrowser.com/javascript-tga-loader.html
  120643. */
  120644. export class TGATools {
  120645. private static _TYPE_INDEXED;
  120646. private static _TYPE_RGB;
  120647. private static _TYPE_GREY;
  120648. private static _TYPE_RLE_INDEXED;
  120649. private static _TYPE_RLE_RGB;
  120650. private static _TYPE_RLE_GREY;
  120651. private static _ORIGIN_MASK;
  120652. private static _ORIGIN_SHIFT;
  120653. private static _ORIGIN_BL;
  120654. private static _ORIGIN_BR;
  120655. private static _ORIGIN_UL;
  120656. private static _ORIGIN_UR;
  120657. /**
  120658. * Gets the header of a TGA file
  120659. * @param data defines the TGA data
  120660. * @returns the header
  120661. */
  120662. static GetTGAHeader(data: Uint8Array): any;
  120663. /**
  120664. * Uploads TGA content to a Babylon Texture
  120665. * @hidden
  120666. */
  120667. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  120668. /** @hidden */
  120669. 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;
  120670. /** @hidden */
  120671. 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;
  120672. /** @hidden */
  120673. 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;
  120674. /** @hidden */
  120675. 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;
  120676. /** @hidden */
  120677. 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;
  120678. /** @hidden */
  120679. 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;
  120680. }
  120681. }
  120682. declare module BABYLON {
  120683. /**
  120684. * Implementation of the TGA Texture Loader.
  120685. * @hidden
  120686. */
  120687. export class _TGATextureLoader implements IInternalTextureLoader {
  120688. /**
  120689. * Defines wether the loader supports cascade loading the different faces.
  120690. */
  120691. readonly supportCascades: boolean;
  120692. /**
  120693. * This returns if the loader support the current file information.
  120694. * @param extension defines the file extension of the file being loaded
  120695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120696. * @param fallback defines the fallback internal texture if any
  120697. * @param isBase64 defines whether the texture is encoded as a base64
  120698. * @param isBuffer defines whether the texture data are stored as a buffer
  120699. * @returns true if the loader can load the specified file
  120700. */
  120701. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120702. /**
  120703. * Transform the url before loading if required.
  120704. * @param rootUrl the url of the texture
  120705. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120706. * @returns the transformed texture
  120707. */
  120708. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120709. /**
  120710. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120711. * @param rootUrl the url of the texture
  120712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120713. * @returns the fallback texture
  120714. */
  120715. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120716. /**
  120717. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120718. * @param data contains the texture data
  120719. * @param texture defines the BabylonJS internal texture
  120720. * @param createPolynomials will be true if polynomials have been requested
  120721. * @param onLoad defines the callback to trigger once the texture is ready
  120722. * @param onError defines the callback to trigger in case of error
  120723. */
  120724. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120725. /**
  120726. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120727. * @param data contains the texture data
  120728. * @param texture defines the BabylonJS internal texture
  120729. * @param callback defines the method to call once ready to upload
  120730. */
  120731. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120732. }
  120733. }
  120734. declare module BABYLON {
  120735. /**
  120736. * Info about the .basis files
  120737. */
  120738. class BasisFileInfo {
  120739. /**
  120740. * If the file has alpha
  120741. */
  120742. hasAlpha: boolean;
  120743. /**
  120744. * Info about each image of the basis file
  120745. */
  120746. images: Array<{
  120747. levels: Array<{
  120748. width: number;
  120749. height: number;
  120750. transcodedPixels: ArrayBufferView;
  120751. }>;
  120752. }>;
  120753. }
  120754. /**
  120755. * Result of transcoding a basis file
  120756. */
  120757. class TranscodeResult {
  120758. /**
  120759. * Info about the .basis file
  120760. */
  120761. fileInfo: BasisFileInfo;
  120762. /**
  120763. * Format to use when loading the file
  120764. */
  120765. format: number;
  120766. }
  120767. /**
  120768. * Configuration options for the Basis transcoder
  120769. */
  120770. export class BasisTranscodeConfiguration {
  120771. /**
  120772. * Supported compression formats used to determine the supported output format of the transcoder
  120773. */
  120774. supportedCompressionFormats?: {
  120775. /**
  120776. * etc1 compression format
  120777. */
  120778. etc1?: boolean;
  120779. /**
  120780. * s3tc compression format
  120781. */
  120782. s3tc?: boolean;
  120783. /**
  120784. * pvrtc compression format
  120785. */
  120786. pvrtc?: boolean;
  120787. /**
  120788. * etc2 compression format
  120789. */
  120790. etc2?: boolean;
  120791. };
  120792. /**
  120793. * If mipmap levels should be loaded for transcoded images (Default: true)
  120794. */
  120795. loadMipmapLevels?: boolean;
  120796. /**
  120797. * Index of a single image to load (Default: all images)
  120798. */
  120799. loadSingleImage?: number;
  120800. }
  120801. /**
  120802. * Used to load .Basis files
  120803. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  120804. */
  120805. export class BasisTools {
  120806. private static _IgnoreSupportedFormats;
  120807. /**
  120808. * URL to use when loading the basis transcoder
  120809. */
  120810. static JSModuleURL: string;
  120811. /**
  120812. * URL to use when loading the wasm module for the transcoder
  120813. */
  120814. static WasmModuleURL: string;
  120815. /**
  120816. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  120817. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  120818. * @returns internal format corresponding to the Basis format
  120819. */
  120820. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  120821. private static _WorkerPromise;
  120822. private static _Worker;
  120823. private static _actionId;
  120824. private static _CreateWorkerAsync;
  120825. /**
  120826. * Transcodes a loaded image file to compressed pixel data
  120827. * @param imageData image data to transcode
  120828. * @param config configuration options for the transcoding
  120829. * @returns a promise resulting in the transcoded image
  120830. */
  120831. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  120832. /**
  120833. * Loads a texture from the transcode result
  120834. * @param texture texture load to
  120835. * @param transcodeResult the result of transcoding the basis file to load from
  120836. */
  120837. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  120838. }
  120839. }
  120840. declare module BABYLON {
  120841. /**
  120842. * Loader for .basis file format
  120843. */
  120844. export class _BasisTextureLoader implements IInternalTextureLoader {
  120845. /**
  120846. * Defines whether the loader supports cascade loading the different faces.
  120847. */
  120848. readonly supportCascades: boolean;
  120849. /**
  120850. * This returns if the loader support the current file information.
  120851. * @param extension defines the file extension of the file being loaded
  120852. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120853. * @param fallback defines the fallback internal texture if any
  120854. * @param isBase64 defines whether the texture is encoded as a base64
  120855. * @param isBuffer defines whether the texture data are stored as a buffer
  120856. * @returns true if the loader can load the specified file
  120857. */
  120858. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120859. /**
  120860. * Transform the url before loading if required.
  120861. * @param rootUrl the url of the texture
  120862. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120863. * @returns the transformed texture
  120864. */
  120865. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120866. /**
  120867. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120868. * @param rootUrl the url of the texture
  120869. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120870. * @returns the fallback texture
  120871. */
  120872. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120873. /**
  120874. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  120875. * @param data contains the texture data
  120876. * @param texture defines the BabylonJS internal texture
  120877. * @param createPolynomials will be true if polynomials have been requested
  120878. * @param onLoad defines the callback to trigger once the texture is ready
  120879. * @param onError defines the callback to trigger in case of error
  120880. */
  120881. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120882. /**
  120883. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120884. * @param data contains the texture data
  120885. * @param texture defines the BabylonJS internal texture
  120886. * @param callback defines the method to call once ready to upload
  120887. */
  120888. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120889. }
  120890. }
  120891. declare module BABYLON {
  120892. /**
  120893. * 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.
  120894. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120895. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120896. */
  120897. export class CustomProceduralTexture extends ProceduralTexture {
  120898. private _animate;
  120899. private _time;
  120900. private _config;
  120901. private _texturePath;
  120902. /**
  120903. * Instantiates a new Custom Procedural Texture.
  120904. * 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.
  120905. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120906. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120907. * @param name Define the name of the texture
  120908. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  120909. * @param size Define the size of the texture to create
  120910. * @param scene Define the scene the texture belongs to
  120911. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  120912. * @param generateMipMaps Define if the texture should creates mip maps or not
  120913. */
  120914. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120915. private _loadJson;
  120916. /**
  120917. * Is the texture ready to be used ? (rendered at least once)
  120918. * @returns true if ready, otherwise, false.
  120919. */
  120920. isReady(): boolean;
  120921. /**
  120922. * Render the texture to its associated render target.
  120923. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  120924. */
  120925. render(useCameraPostProcess?: boolean): void;
  120926. /**
  120927. * Update the list of dependant textures samplers in the shader.
  120928. */
  120929. updateTextures(): void;
  120930. /**
  120931. * Update the uniform values of the procedural texture in the shader.
  120932. */
  120933. updateShaderUniforms(): void;
  120934. /**
  120935. * Define if the texture animates or not.
  120936. */
  120937. animate: boolean;
  120938. }
  120939. }
  120940. declare module BABYLON {
  120941. /** @hidden */
  120942. export var noisePixelShader: {
  120943. name: string;
  120944. shader: string;
  120945. };
  120946. }
  120947. declare module BABYLON {
  120948. /**
  120949. * Class used to generate noise procedural textures
  120950. */
  120951. export class NoiseProceduralTexture extends ProceduralTexture {
  120952. private _time;
  120953. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  120954. brightness: number;
  120955. /** Defines the number of octaves to process */
  120956. octaves: number;
  120957. /** Defines the level of persistence (0.8 by default) */
  120958. persistence: number;
  120959. /** Gets or sets animation speed factor (default is 1) */
  120960. animationSpeedFactor: number;
  120961. /**
  120962. * Creates a new NoiseProceduralTexture
  120963. * @param name defines the name fo the texture
  120964. * @param size defines the size of the texture (default is 256)
  120965. * @param scene defines the hosting scene
  120966. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  120967. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  120968. */
  120969. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120970. private _updateShaderUniforms;
  120971. protected _getDefines(): string;
  120972. /** Generate the current state of the procedural texture */
  120973. render(useCameraPostProcess?: boolean): void;
  120974. /**
  120975. * Serializes this noise procedural texture
  120976. * @returns a serialized noise procedural texture object
  120977. */
  120978. serialize(): any;
  120979. /**
  120980. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  120981. * @param parsedTexture defines parsed texture data
  120982. * @param scene defines the current scene
  120983. * @param rootUrl defines the root URL containing noise procedural texture information
  120984. * @returns a parsed NoiseProceduralTexture
  120985. */
  120986. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  120987. }
  120988. }
  120989. declare module BABYLON {
  120990. /**
  120991. * Raw cube texture where the raw buffers are passed in
  120992. */
  120993. export class RawCubeTexture extends CubeTexture {
  120994. /**
  120995. * Creates a cube texture where the raw buffers are passed in.
  120996. * @param scene defines the scene the texture is attached to
  120997. * @param data defines the array of data to use to create each face
  120998. * @param size defines the size of the textures
  120999. * @param format defines the format of the data
  121000. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121001. * @param generateMipMaps defines if the engine should generate the mip levels
  121002. * @param invertY defines if data must be stored with Y axis inverted
  121003. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121004. * @param compression defines the compression used (null by default)
  121005. */
  121006. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121007. /**
  121008. * Updates the raw cube texture.
  121009. * @param data defines the data to store
  121010. * @param format defines the data format
  121011. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121012. * @param invertY defines if data must be stored with Y axis inverted
  121013. * @param compression defines the compression used (null by default)
  121014. * @param level defines which level of the texture to update
  121015. */
  121016. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121017. /**
  121018. * Updates a raw cube texture with RGBD encoded data.
  121019. * @param data defines the array of data [mipmap][face] to use to create each face
  121020. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121021. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121022. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121023. * @returns a promsie that resolves when the operation is complete
  121024. */
  121025. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121026. /**
  121027. * Clones the raw cube texture.
  121028. * @return a new cube texture
  121029. */
  121030. clone(): CubeTexture;
  121031. /** @hidden */
  121032. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121033. }
  121034. }
  121035. declare module BABYLON {
  121036. /**
  121037. * Class used to store 3D textures containing user data
  121038. */
  121039. export class RawTexture3D extends Texture {
  121040. /** Gets or sets the texture format to use */
  121041. format: number;
  121042. private _engine;
  121043. /**
  121044. * Create a new RawTexture3D
  121045. * @param data defines the data of the texture
  121046. * @param width defines the width of the texture
  121047. * @param height defines the height of the texture
  121048. * @param depth defines the depth of the texture
  121049. * @param format defines the texture format to use
  121050. * @param scene defines the hosting scene
  121051. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121052. * @param invertY defines if texture must be stored with Y axis inverted
  121053. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121054. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121055. */
  121056. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121057. /** Gets or sets the texture format to use */
  121058. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121059. /**
  121060. * Update the texture with new data
  121061. * @param data defines the data to store in the texture
  121062. */
  121063. update(data: ArrayBufferView): void;
  121064. }
  121065. }
  121066. declare module BABYLON {
  121067. /**
  121068. * Class used to store 2D array textures containing user data
  121069. */
  121070. export class RawTexture2DArray extends Texture {
  121071. /** Gets or sets the texture format to use */
  121072. format: number;
  121073. private _engine;
  121074. /**
  121075. * Create a new RawTexture2DArray
  121076. * @param data defines the data of the texture
  121077. * @param width defines the width of the texture
  121078. * @param height defines the height of the texture
  121079. * @param depth defines the number of layers of the texture
  121080. * @param format defines the texture format to use
  121081. * @param scene defines the hosting scene
  121082. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121083. * @param invertY defines if texture must be stored with Y axis inverted
  121084. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121085. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121086. */
  121087. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121088. /** Gets or sets the texture format to use */
  121089. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121090. /**
  121091. * Update the texture with new data
  121092. * @param data defines the data to store in the texture
  121093. */
  121094. update(data: ArrayBufferView): void;
  121095. }
  121096. }
  121097. declare module BABYLON {
  121098. /**
  121099. * Creates a refraction texture used by refraction channel of the standard material.
  121100. * It is like a mirror but to see through a material.
  121101. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121102. */
  121103. export class RefractionTexture extends RenderTargetTexture {
  121104. /**
  121105. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121106. * 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.
  121107. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121108. */
  121109. refractionPlane: Plane;
  121110. /**
  121111. * Define how deep under the surface we should see.
  121112. */
  121113. depth: number;
  121114. /**
  121115. * Creates a refraction texture used by refraction channel of the standard material.
  121116. * It is like a mirror but to see through a material.
  121117. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121118. * @param name Define the texture name
  121119. * @param size Define the size of the underlying texture
  121120. * @param scene Define the scene the refraction belongs to
  121121. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121122. */
  121123. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121124. /**
  121125. * Clone the refraction texture.
  121126. * @returns the cloned texture
  121127. */
  121128. clone(): RefractionTexture;
  121129. /**
  121130. * Serialize the texture to a JSON representation you could use in Parse later on
  121131. * @returns the serialized JSON representation
  121132. */
  121133. serialize(): any;
  121134. }
  121135. }
  121136. declare module BABYLON {
  121137. /**
  121138. * Defines the options related to the creation of an HtmlElementTexture
  121139. */
  121140. export interface IHtmlElementTextureOptions {
  121141. /**
  121142. * Defines wether mip maps should be created or not.
  121143. */
  121144. generateMipMaps?: boolean;
  121145. /**
  121146. * Defines the sampling mode of the texture.
  121147. */
  121148. samplingMode?: number;
  121149. /**
  121150. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121151. */
  121152. engine: Nullable<ThinEngine>;
  121153. /**
  121154. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121155. */
  121156. scene: Nullable<Scene>;
  121157. }
  121158. /**
  121159. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121160. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121161. * is automatically managed.
  121162. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121163. * in your application.
  121164. *
  121165. * As the update is not automatic, you need to call them manually.
  121166. */
  121167. export class HtmlElementTexture extends BaseTexture {
  121168. /**
  121169. * The texture URL.
  121170. */
  121171. element: HTMLVideoElement | HTMLCanvasElement;
  121172. private static readonly DefaultOptions;
  121173. private _textureMatrix;
  121174. private _engine;
  121175. private _isVideo;
  121176. private _generateMipMaps;
  121177. private _samplingMode;
  121178. /**
  121179. * Instantiates a HtmlElementTexture from the following parameters.
  121180. *
  121181. * @param name Defines the name of the texture
  121182. * @param element Defines the video or canvas the texture is filled with
  121183. * @param options Defines the other none mandatory texture creation options
  121184. */
  121185. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121186. private _createInternalTexture;
  121187. /**
  121188. * Returns the texture matrix used in most of the material.
  121189. */
  121190. getTextureMatrix(): Matrix;
  121191. /**
  121192. * Updates the content of the texture.
  121193. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121194. */
  121195. update(invertY?: Nullable<boolean>): void;
  121196. }
  121197. }
  121198. declare module BABYLON {
  121199. /**
  121200. * Enum used to define the target of a block
  121201. */
  121202. export enum NodeMaterialBlockTargets {
  121203. /** Vertex shader */
  121204. Vertex = 1,
  121205. /** Fragment shader */
  121206. Fragment = 2,
  121207. /** Neutral */
  121208. Neutral = 4,
  121209. /** Vertex and Fragment */
  121210. VertexAndFragment = 3
  121211. }
  121212. }
  121213. declare module BABYLON {
  121214. /**
  121215. * Defines the kind of connection point for node based material
  121216. */
  121217. export enum NodeMaterialBlockConnectionPointTypes {
  121218. /** Float */
  121219. Float = 1,
  121220. /** Int */
  121221. Int = 2,
  121222. /** Vector2 */
  121223. Vector2 = 4,
  121224. /** Vector3 */
  121225. Vector3 = 8,
  121226. /** Vector4 */
  121227. Vector4 = 16,
  121228. /** Color3 */
  121229. Color3 = 32,
  121230. /** Color4 */
  121231. Color4 = 64,
  121232. /** Matrix */
  121233. Matrix = 128,
  121234. /** Detect type based on connection */
  121235. AutoDetect = 1024,
  121236. /** Output type that will be defined by input type */
  121237. BasedOnInput = 2048
  121238. }
  121239. }
  121240. declare module BABYLON {
  121241. /**
  121242. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121243. */
  121244. export enum NodeMaterialBlockConnectionPointMode {
  121245. /** Value is an uniform */
  121246. Uniform = 0,
  121247. /** Value is a mesh attribute */
  121248. Attribute = 1,
  121249. /** Value is a varying between vertex and fragment shaders */
  121250. Varying = 2,
  121251. /** Mode is undefined */
  121252. Undefined = 3
  121253. }
  121254. }
  121255. declare module BABYLON {
  121256. /**
  121257. * Enum used to define system values e.g. values automatically provided by the system
  121258. */
  121259. export enum NodeMaterialSystemValues {
  121260. /** World */
  121261. World = 1,
  121262. /** View */
  121263. View = 2,
  121264. /** Projection */
  121265. Projection = 3,
  121266. /** ViewProjection */
  121267. ViewProjection = 4,
  121268. /** WorldView */
  121269. WorldView = 5,
  121270. /** WorldViewProjection */
  121271. WorldViewProjection = 6,
  121272. /** CameraPosition */
  121273. CameraPosition = 7,
  121274. /** Fog Color */
  121275. FogColor = 8,
  121276. /** Delta time */
  121277. DeltaTime = 9
  121278. }
  121279. }
  121280. declare module BABYLON {
  121281. /**
  121282. * Root class for all node material optimizers
  121283. */
  121284. export class NodeMaterialOptimizer {
  121285. /**
  121286. * Function used to optimize a NodeMaterial graph
  121287. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121288. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121289. */
  121290. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121291. }
  121292. }
  121293. declare module BABYLON {
  121294. /**
  121295. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121296. */
  121297. export class TransformBlock extends NodeMaterialBlock {
  121298. /**
  121299. * Defines the value to use to complement W value to transform it to a Vector4
  121300. */
  121301. complementW: number;
  121302. /**
  121303. * Defines the value to use to complement z value to transform it to a Vector4
  121304. */
  121305. complementZ: number;
  121306. /**
  121307. * Creates a new TransformBlock
  121308. * @param name defines the block name
  121309. */
  121310. constructor(name: string);
  121311. /**
  121312. * Gets the current class name
  121313. * @returns the class name
  121314. */
  121315. getClassName(): string;
  121316. /**
  121317. * Gets the vector input
  121318. */
  121319. readonly vector: NodeMaterialConnectionPoint;
  121320. /**
  121321. * Gets the output component
  121322. */
  121323. readonly output: NodeMaterialConnectionPoint;
  121324. /**
  121325. * Gets the matrix transform input
  121326. */
  121327. readonly transform: NodeMaterialConnectionPoint;
  121328. protected _buildBlock(state: NodeMaterialBuildState): this;
  121329. serialize(): any;
  121330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121331. protected _dumpPropertiesCode(): string;
  121332. }
  121333. }
  121334. declare module BABYLON {
  121335. /**
  121336. * Block used to output the vertex position
  121337. */
  121338. export class VertexOutputBlock extends NodeMaterialBlock {
  121339. /**
  121340. * Creates a new VertexOutputBlock
  121341. * @param name defines the block name
  121342. */
  121343. constructor(name: string);
  121344. /**
  121345. * Gets the current class name
  121346. * @returns the class name
  121347. */
  121348. getClassName(): string;
  121349. /**
  121350. * Gets the vector input component
  121351. */
  121352. readonly vector: NodeMaterialConnectionPoint;
  121353. protected _buildBlock(state: NodeMaterialBuildState): this;
  121354. }
  121355. }
  121356. declare module BABYLON {
  121357. /**
  121358. * Block used to output the final color
  121359. */
  121360. export class FragmentOutputBlock extends NodeMaterialBlock {
  121361. /**
  121362. * Create a new FragmentOutputBlock
  121363. * @param name defines the block name
  121364. */
  121365. constructor(name: string);
  121366. /**
  121367. * Gets the current class name
  121368. * @returns the class name
  121369. */
  121370. getClassName(): string;
  121371. /**
  121372. * Gets the rgba input component
  121373. */
  121374. readonly rgba: NodeMaterialConnectionPoint;
  121375. /**
  121376. * Gets the rgb input component
  121377. */
  121378. readonly rgb: NodeMaterialConnectionPoint;
  121379. /**
  121380. * Gets the a input component
  121381. */
  121382. readonly a: NodeMaterialConnectionPoint;
  121383. protected _buildBlock(state: NodeMaterialBuildState): this;
  121384. }
  121385. }
  121386. declare module BABYLON {
  121387. /**
  121388. * Block used to read a reflection texture from a sampler
  121389. */
  121390. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121391. private _define3DName;
  121392. private _defineCubicName;
  121393. private _defineExplicitName;
  121394. private _defineProjectionName;
  121395. private _defineLocalCubicName;
  121396. private _defineSphericalName;
  121397. private _definePlanarName;
  121398. private _defineEquirectangularName;
  121399. private _defineMirroredEquirectangularFixedName;
  121400. private _defineEquirectangularFixedName;
  121401. private _defineSkyboxName;
  121402. private _cubeSamplerName;
  121403. private _2DSamplerName;
  121404. private _positionUVWName;
  121405. private _directionWName;
  121406. private _reflectionCoordsName;
  121407. private _reflection2DCoordsName;
  121408. private _reflectionColorName;
  121409. private _reflectionMatrixName;
  121410. /**
  121411. * Gets or sets the texture associated with the node
  121412. */
  121413. texture: Nullable<BaseTexture>;
  121414. /**
  121415. * Create a new TextureBlock
  121416. * @param name defines the block name
  121417. */
  121418. constructor(name: string);
  121419. /**
  121420. * Gets the current class name
  121421. * @returns the class name
  121422. */
  121423. getClassName(): string;
  121424. /**
  121425. * Gets the world position input component
  121426. */
  121427. readonly position: NodeMaterialConnectionPoint;
  121428. /**
  121429. * Gets the world position input component
  121430. */
  121431. readonly worldPosition: NodeMaterialConnectionPoint;
  121432. /**
  121433. * Gets the world normal input component
  121434. */
  121435. readonly worldNormal: NodeMaterialConnectionPoint;
  121436. /**
  121437. * Gets the world input component
  121438. */
  121439. readonly world: NodeMaterialConnectionPoint;
  121440. /**
  121441. * Gets the camera (or eye) position component
  121442. */
  121443. readonly cameraPosition: NodeMaterialConnectionPoint;
  121444. /**
  121445. * Gets the view input component
  121446. */
  121447. readonly view: NodeMaterialConnectionPoint;
  121448. /**
  121449. * Gets the rgb output component
  121450. */
  121451. readonly rgb: NodeMaterialConnectionPoint;
  121452. /**
  121453. * Gets the r output component
  121454. */
  121455. readonly r: NodeMaterialConnectionPoint;
  121456. /**
  121457. * Gets the g output component
  121458. */
  121459. readonly g: NodeMaterialConnectionPoint;
  121460. /**
  121461. * Gets the b output component
  121462. */
  121463. readonly b: NodeMaterialConnectionPoint;
  121464. autoConfigure(material: NodeMaterial): void;
  121465. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121466. isReady(): boolean;
  121467. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121468. private _injectVertexCode;
  121469. private _writeOutput;
  121470. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121471. protected _dumpPropertiesCode(): string;
  121472. serialize(): any;
  121473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121474. }
  121475. }
  121476. declare module BABYLON {
  121477. /**
  121478. * Interface used to configure the node material editor
  121479. */
  121480. export interface INodeMaterialEditorOptions {
  121481. /** Define the URl to load node editor script */
  121482. editorURL?: string;
  121483. }
  121484. /** @hidden */
  121485. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121486. /** BONES */
  121487. NUM_BONE_INFLUENCERS: number;
  121488. BonesPerMesh: number;
  121489. BONETEXTURE: boolean;
  121490. /** MORPH TARGETS */
  121491. MORPHTARGETS: boolean;
  121492. MORPHTARGETS_NORMAL: boolean;
  121493. MORPHTARGETS_TANGENT: boolean;
  121494. MORPHTARGETS_UV: boolean;
  121495. NUM_MORPH_INFLUENCERS: number;
  121496. /** IMAGE PROCESSING */
  121497. IMAGEPROCESSING: boolean;
  121498. VIGNETTE: boolean;
  121499. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121500. VIGNETTEBLENDMODEOPAQUE: boolean;
  121501. TONEMAPPING: boolean;
  121502. TONEMAPPING_ACES: boolean;
  121503. CONTRAST: boolean;
  121504. EXPOSURE: boolean;
  121505. COLORCURVES: boolean;
  121506. COLORGRADING: boolean;
  121507. COLORGRADING3D: boolean;
  121508. SAMPLER3DGREENDEPTH: boolean;
  121509. SAMPLER3DBGRMAP: boolean;
  121510. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121511. /** MISC. */
  121512. BUMPDIRECTUV: number;
  121513. constructor();
  121514. setValue(name: string, value: boolean): void;
  121515. }
  121516. /**
  121517. * Class used to configure NodeMaterial
  121518. */
  121519. export interface INodeMaterialOptions {
  121520. /**
  121521. * Defines if blocks should emit comments
  121522. */
  121523. emitComments: boolean;
  121524. }
  121525. /**
  121526. * Class used to create a node based material built by assembling shader blocks
  121527. */
  121528. export class NodeMaterial extends PushMaterial {
  121529. private static _BuildIdGenerator;
  121530. private _options;
  121531. private _vertexCompilationState;
  121532. private _fragmentCompilationState;
  121533. private _sharedData;
  121534. private _buildId;
  121535. private _buildWasSuccessful;
  121536. private _cachedWorldViewMatrix;
  121537. private _cachedWorldViewProjectionMatrix;
  121538. private _optimizers;
  121539. private _animationFrame;
  121540. /** Define the URl to load node editor script */
  121541. static EditorURL: string;
  121542. private BJSNODEMATERIALEDITOR;
  121543. /** Get the inspector from bundle or global */
  121544. private _getGlobalNodeMaterialEditor;
  121545. /**
  121546. * 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)
  121547. */
  121548. ignoreAlpha: boolean;
  121549. /**
  121550. * Defines the maximum number of lights that can be used in the material
  121551. */
  121552. maxSimultaneousLights: number;
  121553. /**
  121554. * Observable raised when the material is built
  121555. */
  121556. onBuildObservable: Observable<NodeMaterial>;
  121557. /**
  121558. * Gets or sets the root nodes of the material vertex shader
  121559. */
  121560. _vertexOutputNodes: NodeMaterialBlock[];
  121561. /**
  121562. * Gets or sets the root nodes of the material fragment (pixel) shader
  121563. */
  121564. _fragmentOutputNodes: NodeMaterialBlock[];
  121565. /** Gets or sets options to control the node material overall behavior */
  121566. options: INodeMaterialOptions;
  121567. /**
  121568. * Default configuration related to image processing available in the standard Material.
  121569. */
  121570. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121571. /**
  121572. * Gets the image processing configuration used either in this material.
  121573. */
  121574. /**
  121575. * Sets the Default image processing configuration used either in the this material.
  121576. *
  121577. * If sets to null, the scene one is in use.
  121578. */
  121579. imageProcessingConfiguration: ImageProcessingConfiguration;
  121580. /**
  121581. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121582. */
  121583. attachedBlocks: NodeMaterialBlock[];
  121584. /**
  121585. * Create a new node based material
  121586. * @param name defines the material name
  121587. * @param scene defines the hosting scene
  121588. * @param options defines creation option
  121589. */
  121590. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121591. /**
  121592. * Gets the current class name of the material e.g. "NodeMaterial"
  121593. * @returns the class name
  121594. */
  121595. getClassName(): string;
  121596. /**
  121597. * Keep track of the image processing observer to allow dispose and replace.
  121598. */
  121599. private _imageProcessingObserver;
  121600. /**
  121601. * Attaches a new image processing configuration to the Standard Material.
  121602. * @param configuration
  121603. */
  121604. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121605. /**
  121606. * Get a block by its name
  121607. * @param name defines the name of the block to retrieve
  121608. * @returns the required block or null if not found
  121609. */
  121610. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121611. /**
  121612. * Get a block by its name
  121613. * @param predicate defines the predicate used to find the good candidate
  121614. * @returns the required block or null if not found
  121615. */
  121616. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121617. /**
  121618. * Get an input block by its name
  121619. * @param predicate defines the predicate used to find the good candidate
  121620. * @returns the required input block or null if not found
  121621. */
  121622. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121623. /**
  121624. * Gets the list of input blocks attached to this material
  121625. * @returns an array of InputBlocks
  121626. */
  121627. getInputBlocks(): InputBlock[];
  121628. /**
  121629. * Adds a new optimizer to the list of optimizers
  121630. * @param optimizer defines the optimizers to add
  121631. * @returns the current material
  121632. */
  121633. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121634. /**
  121635. * Remove an optimizer from the list of optimizers
  121636. * @param optimizer defines the optimizers to remove
  121637. * @returns the current material
  121638. */
  121639. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121640. /**
  121641. * Add a new block to the list of output nodes
  121642. * @param node defines the node to add
  121643. * @returns the current material
  121644. */
  121645. addOutputNode(node: NodeMaterialBlock): this;
  121646. /**
  121647. * Remove a block from the list of root nodes
  121648. * @param node defines the node to remove
  121649. * @returns the current material
  121650. */
  121651. removeOutputNode(node: NodeMaterialBlock): this;
  121652. private _addVertexOutputNode;
  121653. private _removeVertexOutputNode;
  121654. private _addFragmentOutputNode;
  121655. private _removeFragmentOutputNode;
  121656. /**
  121657. * Specifies if the material will require alpha blending
  121658. * @returns a boolean specifying if alpha blending is needed
  121659. */
  121660. needAlphaBlending(): boolean;
  121661. /**
  121662. * Specifies if this material should be rendered in alpha test mode
  121663. * @returns a boolean specifying if an alpha test is needed.
  121664. */
  121665. needAlphaTesting(): boolean;
  121666. private _initializeBlock;
  121667. private _resetDualBlocks;
  121668. /**
  121669. * Build the material and generates the inner effect
  121670. * @param verbose defines if the build should log activity
  121671. */
  121672. build(verbose?: boolean): void;
  121673. /**
  121674. * Runs an otpimization phase to try to improve the shader code
  121675. */
  121676. optimize(): void;
  121677. private _prepareDefinesForAttributes;
  121678. /**
  121679. * Get if the submesh is ready to be used and all its information available.
  121680. * Child classes can use it to update shaders
  121681. * @param mesh defines the mesh to check
  121682. * @param subMesh defines which submesh to check
  121683. * @param useInstances specifies that instances should be used
  121684. * @returns a boolean indicating that the submesh is ready or not
  121685. */
  121686. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121687. /**
  121688. * Get a string representing the shaders built by the current node graph
  121689. */
  121690. readonly compiledShaders: string;
  121691. /**
  121692. * Binds the world matrix to the material
  121693. * @param world defines the world transformation matrix
  121694. */
  121695. bindOnlyWorldMatrix(world: Matrix): void;
  121696. /**
  121697. * Binds the submesh to this material by preparing the effect and shader to draw
  121698. * @param world defines the world transformation matrix
  121699. * @param mesh defines the mesh containing the submesh
  121700. * @param subMesh defines the submesh to bind the material to
  121701. */
  121702. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121703. /**
  121704. * Gets the active textures from the material
  121705. * @returns an array of textures
  121706. */
  121707. getActiveTextures(): BaseTexture[];
  121708. /**
  121709. * Gets the list of texture blocks
  121710. * @returns an array of texture blocks
  121711. */
  121712. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121713. /**
  121714. * Specifies if the material uses a texture
  121715. * @param texture defines the texture to check against the material
  121716. * @returns a boolean specifying if the material uses the texture
  121717. */
  121718. hasTexture(texture: BaseTexture): boolean;
  121719. /**
  121720. * Disposes the material
  121721. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121722. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121723. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121724. */
  121725. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121726. /** Creates the node editor window. */
  121727. private _createNodeEditor;
  121728. /**
  121729. * Launch the node material editor
  121730. * @param config Define the configuration of the editor
  121731. * @return a promise fulfilled when the node editor is visible
  121732. */
  121733. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  121734. /**
  121735. * Clear the current material
  121736. */
  121737. clear(): void;
  121738. /**
  121739. * Clear the current material and set it to a default state
  121740. */
  121741. setToDefault(): void;
  121742. /**
  121743. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  121744. * @param url defines the url to load from
  121745. * @returns a promise that will fullfil when the material is fully loaded
  121746. */
  121747. loadAsync(url: string): Promise<void>;
  121748. private _gatherBlocks;
  121749. /**
  121750. * Generate a string containing the code declaration required to create an equivalent of this material
  121751. * @returns a string
  121752. */
  121753. generateCode(): string;
  121754. /**
  121755. * Serializes this material in a JSON representation
  121756. * @returns the serialized material object
  121757. */
  121758. serialize(): any;
  121759. private _restoreConnections;
  121760. /**
  121761. * Clear the current graph and load a new one from a serialization object
  121762. * @param source defines the JSON representation of the material
  121763. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121764. */
  121765. loadFromSerialization(source: any, rootUrl?: string): void;
  121766. /**
  121767. * Creates a node material from parsed material data
  121768. * @param source defines the JSON representation of the material
  121769. * @param scene defines the hosting scene
  121770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121771. * @returns a new node material
  121772. */
  121773. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  121774. /**
  121775. * Creates a new node material set to default basic configuration
  121776. * @param name defines the name of the material
  121777. * @param scene defines the hosting scene
  121778. * @returns a new NodeMaterial
  121779. */
  121780. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  121781. }
  121782. }
  121783. declare module BABYLON {
  121784. /**
  121785. * Block used to read a texture from a sampler
  121786. */
  121787. export class TextureBlock extends NodeMaterialBlock {
  121788. private _defineName;
  121789. private _linearDefineName;
  121790. private _samplerName;
  121791. private _transformedUVName;
  121792. private _textureTransformName;
  121793. private _textureInfoName;
  121794. private _mainUVName;
  121795. private _mainUVDefineName;
  121796. /**
  121797. * Gets or sets the texture associated with the node
  121798. */
  121799. texture: Nullable<Texture>;
  121800. /**
  121801. * Create a new TextureBlock
  121802. * @param name defines the block name
  121803. */
  121804. constructor(name: string);
  121805. /**
  121806. * Gets the current class name
  121807. * @returns the class name
  121808. */
  121809. getClassName(): string;
  121810. /**
  121811. * Gets the uv input component
  121812. */
  121813. readonly uv: NodeMaterialConnectionPoint;
  121814. /**
  121815. * Gets the rgba output component
  121816. */
  121817. readonly rgba: NodeMaterialConnectionPoint;
  121818. /**
  121819. * Gets the rgb output component
  121820. */
  121821. readonly rgb: NodeMaterialConnectionPoint;
  121822. /**
  121823. * Gets the r output component
  121824. */
  121825. readonly r: NodeMaterialConnectionPoint;
  121826. /**
  121827. * Gets the g output component
  121828. */
  121829. readonly g: NodeMaterialConnectionPoint;
  121830. /**
  121831. * Gets the b output component
  121832. */
  121833. readonly b: NodeMaterialConnectionPoint;
  121834. /**
  121835. * Gets the a output component
  121836. */
  121837. readonly a: NodeMaterialConnectionPoint;
  121838. readonly target: NodeMaterialBlockTargets;
  121839. autoConfigure(material: NodeMaterial): void;
  121840. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121842. isReady(): boolean;
  121843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121844. private readonly _isMixed;
  121845. private _injectVertexCode;
  121846. private _writeOutput;
  121847. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121848. protected _dumpPropertiesCode(): string;
  121849. serialize(): any;
  121850. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121851. }
  121852. }
  121853. declare module BABYLON {
  121854. /**
  121855. * Class used to store shared data between 2 NodeMaterialBuildState
  121856. */
  121857. export class NodeMaterialBuildStateSharedData {
  121858. /**
  121859. * Gets the list of emitted varyings
  121860. */
  121861. temps: string[];
  121862. /**
  121863. * Gets the list of emitted varyings
  121864. */
  121865. varyings: string[];
  121866. /**
  121867. * Gets the varying declaration string
  121868. */
  121869. varyingDeclaration: string;
  121870. /**
  121871. * Input blocks
  121872. */
  121873. inputBlocks: InputBlock[];
  121874. /**
  121875. * Input blocks
  121876. */
  121877. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  121878. /**
  121879. * Bindable blocks (Blocks that need to set data to the effect)
  121880. */
  121881. bindableBlocks: NodeMaterialBlock[];
  121882. /**
  121883. * List of blocks that can provide a compilation fallback
  121884. */
  121885. blocksWithFallbacks: NodeMaterialBlock[];
  121886. /**
  121887. * List of blocks that can provide a define update
  121888. */
  121889. blocksWithDefines: NodeMaterialBlock[];
  121890. /**
  121891. * List of blocks that can provide a repeatable content
  121892. */
  121893. repeatableContentBlocks: NodeMaterialBlock[];
  121894. /**
  121895. * List of blocks that can provide a dynamic list of uniforms
  121896. */
  121897. dynamicUniformBlocks: NodeMaterialBlock[];
  121898. /**
  121899. * List of blocks that can block the isReady function for the material
  121900. */
  121901. blockingBlocks: NodeMaterialBlock[];
  121902. /**
  121903. * Gets the list of animated inputs
  121904. */
  121905. animatedInputs: InputBlock[];
  121906. /**
  121907. * Build Id used to avoid multiple recompilations
  121908. */
  121909. buildId: number;
  121910. /** List of emitted variables */
  121911. variableNames: {
  121912. [key: string]: number;
  121913. };
  121914. /** List of emitted defines */
  121915. defineNames: {
  121916. [key: string]: number;
  121917. };
  121918. /** Should emit comments? */
  121919. emitComments: boolean;
  121920. /** Emit build activity */
  121921. verbose: boolean;
  121922. /** Gets or sets the hosting scene */
  121923. scene: Scene;
  121924. /**
  121925. * Gets the compilation hints emitted at compilation time
  121926. */
  121927. hints: {
  121928. needWorldViewMatrix: boolean;
  121929. needWorldViewProjectionMatrix: boolean;
  121930. needAlphaBlending: boolean;
  121931. needAlphaTesting: boolean;
  121932. };
  121933. /**
  121934. * List of compilation checks
  121935. */
  121936. checks: {
  121937. emitVertex: boolean;
  121938. emitFragment: boolean;
  121939. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  121940. };
  121941. /** Creates a new shared data */
  121942. constructor();
  121943. /**
  121944. * Emits console errors and exceptions if there is a failing check
  121945. */
  121946. emitErrors(): void;
  121947. }
  121948. }
  121949. declare module BABYLON {
  121950. /**
  121951. * Class used to store node based material build state
  121952. */
  121953. export class NodeMaterialBuildState {
  121954. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  121955. supportUniformBuffers: boolean;
  121956. /**
  121957. * Gets the list of emitted attributes
  121958. */
  121959. attributes: string[];
  121960. /**
  121961. * Gets the list of emitted uniforms
  121962. */
  121963. uniforms: string[];
  121964. /**
  121965. * Gets the list of emitted constants
  121966. */
  121967. constants: string[];
  121968. /**
  121969. * Gets the list of emitted samplers
  121970. */
  121971. samplers: string[];
  121972. /**
  121973. * Gets the list of emitted functions
  121974. */
  121975. functions: {
  121976. [key: string]: string;
  121977. };
  121978. /**
  121979. * Gets the list of emitted extensions
  121980. */
  121981. extensions: {
  121982. [key: string]: string;
  121983. };
  121984. /**
  121985. * Gets the target of the compilation state
  121986. */
  121987. target: NodeMaterialBlockTargets;
  121988. /**
  121989. * Gets the list of emitted counters
  121990. */
  121991. counters: {
  121992. [key: string]: number;
  121993. };
  121994. /**
  121995. * Shared data between multiple NodeMaterialBuildState instances
  121996. */
  121997. sharedData: NodeMaterialBuildStateSharedData;
  121998. /** @hidden */
  121999. _vertexState: NodeMaterialBuildState;
  122000. /** @hidden */
  122001. _attributeDeclaration: string;
  122002. /** @hidden */
  122003. _uniformDeclaration: string;
  122004. /** @hidden */
  122005. _constantDeclaration: string;
  122006. /** @hidden */
  122007. _samplerDeclaration: string;
  122008. /** @hidden */
  122009. _varyingTransfer: string;
  122010. private _repeatableContentAnchorIndex;
  122011. /** @hidden */
  122012. _builtCompilationString: string;
  122013. /**
  122014. * Gets the emitted compilation strings
  122015. */
  122016. compilationString: string;
  122017. /**
  122018. * Finalize the compilation strings
  122019. * @param state defines the current compilation state
  122020. */
  122021. finalize(state: NodeMaterialBuildState): void;
  122022. /** @hidden */
  122023. readonly _repeatableContentAnchor: string;
  122024. /** @hidden */
  122025. _getFreeVariableName(prefix: string): string;
  122026. /** @hidden */
  122027. _getFreeDefineName(prefix: string): string;
  122028. /** @hidden */
  122029. _excludeVariableName(name: string): void;
  122030. /** @hidden */
  122031. _emit2DSampler(name: string): void;
  122032. /** @hidden */
  122033. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122034. /** @hidden */
  122035. _emitExtension(name: string, extension: string): void;
  122036. /** @hidden */
  122037. _emitFunction(name: string, code: string, comments: string): void;
  122038. /** @hidden */
  122039. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122040. replaceStrings?: {
  122041. search: RegExp;
  122042. replace: string;
  122043. }[];
  122044. repeatKey?: string;
  122045. }): string;
  122046. /** @hidden */
  122047. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122048. repeatKey?: string;
  122049. removeAttributes?: boolean;
  122050. removeUniforms?: boolean;
  122051. removeVaryings?: boolean;
  122052. removeIfDef?: boolean;
  122053. replaceStrings?: {
  122054. search: RegExp;
  122055. replace: string;
  122056. }[];
  122057. }, storeKey?: string): void;
  122058. /** @hidden */
  122059. _registerTempVariable(name: string): boolean;
  122060. /** @hidden */
  122061. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122062. /** @hidden */
  122063. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122064. /** @hidden */
  122065. _emitFloat(value: number): string;
  122066. }
  122067. }
  122068. declare module BABYLON {
  122069. /**
  122070. * Defines a block that can be used inside a node based material
  122071. */
  122072. export class NodeMaterialBlock {
  122073. private _buildId;
  122074. private _buildTarget;
  122075. private _target;
  122076. private _isFinalMerger;
  122077. private _isInput;
  122078. protected _isUnique: boolean;
  122079. /** @hidden */
  122080. _codeVariableName: string;
  122081. /** @hidden */
  122082. _inputs: NodeMaterialConnectionPoint[];
  122083. /** @hidden */
  122084. _outputs: NodeMaterialConnectionPoint[];
  122085. /** @hidden */
  122086. _preparationId: number;
  122087. /**
  122088. * Gets or sets the name of the block
  122089. */
  122090. name: string;
  122091. /**
  122092. * Gets or sets the unique id of the node
  122093. */
  122094. uniqueId: number;
  122095. /**
  122096. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  122097. */
  122098. readonly isUnique: boolean;
  122099. /**
  122100. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122101. */
  122102. readonly isFinalMerger: boolean;
  122103. /**
  122104. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122105. */
  122106. readonly isInput: boolean;
  122107. /**
  122108. * Gets or sets the build Id
  122109. */
  122110. buildId: number;
  122111. /**
  122112. * Gets or sets the target of the block
  122113. */
  122114. target: NodeMaterialBlockTargets;
  122115. /**
  122116. * Gets the list of input points
  122117. */
  122118. readonly inputs: NodeMaterialConnectionPoint[];
  122119. /** Gets the list of output points */
  122120. readonly outputs: NodeMaterialConnectionPoint[];
  122121. /**
  122122. * Find an input by its name
  122123. * @param name defines the name of the input to look for
  122124. * @returns the input or null if not found
  122125. */
  122126. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122127. /**
  122128. * Find an output by its name
  122129. * @param name defines the name of the outputto look for
  122130. * @returns the output or null if not found
  122131. */
  122132. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122133. /**
  122134. * Creates a new NodeMaterialBlock
  122135. * @param name defines the block name
  122136. * @param target defines the target of that block (Vertex by default)
  122137. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122138. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122139. */
  122140. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122141. /**
  122142. * Initialize the block and prepare the context for build
  122143. * @param state defines the state that will be used for the build
  122144. */
  122145. initialize(state: NodeMaterialBuildState): void;
  122146. /**
  122147. * Bind data to effect. Will only be called for blocks with isBindable === true
  122148. * @param effect defines the effect to bind data to
  122149. * @param nodeMaterial defines the hosting NodeMaterial
  122150. * @param mesh defines the mesh that will be rendered
  122151. */
  122152. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122153. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122154. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122155. protected _writeFloat(value: number): string;
  122156. /**
  122157. * Gets the current class name e.g. "NodeMaterialBlock"
  122158. * @returns the class name
  122159. */
  122160. getClassName(): string;
  122161. /**
  122162. * Register a new input. Must be called inside a block constructor
  122163. * @param name defines the connection point name
  122164. * @param type defines the connection point type
  122165. * @param isOptional defines a boolean indicating that this input can be omitted
  122166. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122167. * @returns the current block
  122168. */
  122169. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122170. /**
  122171. * Register a new output. Must be called inside a block constructor
  122172. * @param name defines the connection point name
  122173. * @param type defines the connection point type
  122174. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122175. * @returns the current block
  122176. */
  122177. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122178. /**
  122179. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122180. * @param forOutput defines an optional connection point to check compatibility with
  122181. * @returns the first available input or null
  122182. */
  122183. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122184. /**
  122185. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122186. * @param forBlock defines an optional block to check compatibility with
  122187. * @returns the first available input or null
  122188. */
  122189. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122190. /**
  122191. * Gets the sibling of the given output
  122192. * @param current defines the current output
  122193. * @returns the next output in the list or null
  122194. */
  122195. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122196. /**
  122197. * Connect current block with another block
  122198. * @param other defines the block to connect with
  122199. * @param options define the various options to help pick the right connections
  122200. * @returns the current block
  122201. */
  122202. connectTo(other: NodeMaterialBlock, options?: {
  122203. input?: string;
  122204. output?: string;
  122205. outputSwizzle?: string;
  122206. }): this | undefined;
  122207. protected _buildBlock(state: NodeMaterialBuildState): void;
  122208. /**
  122209. * Add uniforms, samplers and uniform buffers at compilation time
  122210. * @param state defines the state to update
  122211. * @param nodeMaterial defines the node material requesting the update
  122212. * @param defines defines the material defines to update
  122213. * @param uniformBuffers defines the list of uniform buffer names
  122214. */
  122215. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122216. /**
  122217. * Add potential fallbacks if shader compilation fails
  122218. * @param mesh defines the mesh to be rendered
  122219. * @param fallbacks defines the current prioritized list of fallbacks
  122220. */
  122221. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122222. /**
  122223. * Initialize defines for shader compilation
  122224. * @param mesh defines the mesh to be rendered
  122225. * @param nodeMaterial defines the node material requesting the update
  122226. * @param defines defines the material defines to update
  122227. * @param useInstances specifies that instances should be used
  122228. */
  122229. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122230. /**
  122231. * Update defines for shader compilation
  122232. * @param mesh defines the mesh to be rendered
  122233. * @param nodeMaterial defines the node material requesting the update
  122234. * @param defines defines the material defines to update
  122235. * @param useInstances specifies that instances should be used
  122236. */
  122237. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122238. /**
  122239. * Lets the block try to connect some inputs automatically
  122240. * @param material defines the hosting NodeMaterial
  122241. */
  122242. autoConfigure(material: NodeMaterial): void;
  122243. /**
  122244. * Function called when a block is declared as repeatable content generator
  122245. * @param vertexShaderState defines the current compilation state for the vertex shader
  122246. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122247. * @param mesh defines the mesh to be rendered
  122248. * @param defines defines the material defines to update
  122249. */
  122250. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122251. /**
  122252. * Checks if the block is ready
  122253. * @param mesh defines the mesh to be rendered
  122254. * @param nodeMaterial defines the node material requesting the update
  122255. * @param defines defines the material defines to update
  122256. * @param useInstances specifies that instances should be used
  122257. * @returns true if the block is ready
  122258. */
  122259. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122260. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122261. private _processBuild;
  122262. /**
  122263. * Compile the current node and generate the shader code
  122264. * @param state defines the current compilation state (uniforms, samplers, current string)
  122265. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122266. * @returns true if already built
  122267. */
  122268. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122269. protected _inputRename(name: string): string;
  122270. protected _outputRename(name: string): string;
  122271. protected _dumpPropertiesCode(): string;
  122272. /** @hidden */
  122273. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122274. /** @hidden */
  122275. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  122276. /**
  122277. * Clone the current block to a new identical block
  122278. * @param scene defines the hosting scene
  122279. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122280. * @returns a copy of the current block
  122281. */
  122282. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122283. /**
  122284. * Serializes this block in a JSON representation
  122285. * @returns the serialized block object
  122286. */
  122287. serialize(): any;
  122288. /** @hidden */
  122289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122290. /**
  122291. * Release resources
  122292. */
  122293. dispose(): void;
  122294. }
  122295. }
  122296. declare module BABYLON {
  122297. /**
  122298. * Enum defining the type of animations supported by InputBlock
  122299. */
  122300. export enum AnimatedInputBlockTypes {
  122301. /** No animation */
  122302. None = 0,
  122303. /** Time based animation. Will only work for floats */
  122304. Time = 1
  122305. }
  122306. }
  122307. declare module BABYLON {
  122308. /**
  122309. * Block used to expose an input value
  122310. */
  122311. export class InputBlock extends NodeMaterialBlock {
  122312. private _mode;
  122313. private _associatedVariableName;
  122314. private _storedValue;
  122315. private _valueCallback;
  122316. private _type;
  122317. private _animationType;
  122318. /** Gets or set a value used to limit the range of float values */
  122319. min: number;
  122320. /** Gets or set a value used to limit the range of float values */
  122321. max: number;
  122322. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122323. matrixMode: number;
  122324. /** @hidden */
  122325. _systemValue: Nullable<NodeMaterialSystemValues>;
  122326. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122327. visibleInInspector: boolean;
  122328. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122329. isConstant: boolean;
  122330. /**
  122331. * Gets or sets the connection point type (default is float)
  122332. */
  122333. readonly type: NodeMaterialBlockConnectionPointTypes;
  122334. /**
  122335. * Creates a new InputBlock
  122336. * @param name defines the block name
  122337. * @param target defines the target of that block (Vertex by default)
  122338. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122339. */
  122340. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122341. /**
  122342. * Gets the output component
  122343. */
  122344. readonly output: NodeMaterialConnectionPoint;
  122345. /**
  122346. * Set the source of this connection point to a vertex attribute
  122347. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122348. * @returns the current connection point
  122349. */
  122350. setAsAttribute(attributeName?: string): InputBlock;
  122351. /**
  122352. * Set the source of this connection point to a system value
  122353. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122354. * @returns the current connection point
  122355. */
  122356. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122357. /**
  122358. * Gets or sets the value of that point.
  122359. * Please note that this value will be ignored if valueCallback is defined
  122360. */
  122361. value: any;
  122362. /**
  122363. * Gets or sets a callback used to get the value of that point.
  122364. * Please note that setting this value will force the connection point to ignore the value property
  122365. */
  122366. valueCallback: () => any;
  122367. /**
  122368. * Gets or sets the associated variable name in the shader
  122369. */
  122370. associatedVariableName: string;
  122371. /** Gets or sets the type of animation applied to the input */
  122372. animationType: AnimatedInputBlockTypes;
  122373. /**
  122374. * Gets a boolean indicating that this connection point not defined yet
  122375. */
  122376. readonly isUndefined: boolean;
  122377. /**
  122378. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122379. * In this case the connection point name must be the name of the uniform to use.
  122380. * Can only be set on inputs
  122381. */
  122382. isUniform: boolean;
  122383. /**
  122384. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122385. * In this case the connection point name must be the name of the attribute to use
  122386. * Can only be set on inputs
  122387. */
  122388. isAttribute: boolean;
  122389. /**
  122390. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122391. * Can only be set on exit points
  122392. */
  122393. isVarying: boolean;
  122394. /**
  122395. * Gets a boolean indicating that the current connection point is a system value
  122396. */
  122397. readonly isSystemValue: boolean;
  122398. /**
  122399. * Gets or sets the current well known value or null if not defined as a system value
  122400. */
  122401. systemValue: Nullable<NodeMaterialSystemValues>;
  122402. /**
  122403. * Gets the current class name
  122404. * @returns the class name
  122405. */
  122406. getClassName(): string;
  122407. /**
  122408. * Animate the input if animationType !== None
  122409. * @param scene defines the rendering scene
  122410. */
  122411. animate(scene: Scene): void;
  122412. private _emitDefine;
  122413. initialize(state: NodeMaterialBuildState): void;
  122414. /**
  122415. * Set the input block to its default value (based on its type)
  122416. */
  122417. setDefaultValue(): void;
  122418. private _emitConstant;
  122419. private _emit;
  122420. /** @hidden */
  122421. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122422. /** @hidden */
  122423. _transmit(effect: Effect, scene: Scene): void;
  122424. protected _buildBlock(state: NodeMaterialBuildState): void;
  122425. protected _dumpPropertiesCode(): string;
  122426. serialize(): any;
  122427. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122428. }
  122429. }
  122430. declare module BABYLON {
  122431. /**
  122432. * Enum used to define the compatibility state between two connection points
  122433. */
  122434. export enum NodeMaterialConnectionPointCompatibilityStates {
  122435. /** Points are compatibles */
  122436. Compatible = 0,
  122437. /** Points are incompatible because of their types */
  122438. TypeIncompatible = 1,
  122439. /** Points are incompatible because of their targets (vertex vs fragment) */
  122440. TargetIncompatible = 2
  122441. }
  122442. /**
  122443. * Defines a connection point for a block
  122444. */
  122445. export class NodeMaterialConnectionPoint {
  122446. /** @hidden */
  122447. _ownerBlock: NodeMaterialBlock;
  122448. /** @hidden */
  122449. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122450. private _endpoints;
  122451. private _associatedVariableName;
  122452. /** @hidden */
  122453. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122454. /** @hidden */
  122455. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122456. private _type;
  122457. /** @hidden */
  122458. _enforceAssociatedVariableName: boolean;
  122459. /**
  122460. * Gets or sets the additional types supported by this connection point
  122461. */
  122462. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122463. /**
  122464. * Gets or sets the additional types excluded by this connection point
  122465. */
  122466. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122467. /**
  122468. * Observable triggered when this point is connected
  122469. */
  122470. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122471. /**
  122472. * Gets or sets the associated variable name in the shader
  122473. */
  122474. associatedVariableName: string;
  122475. /**
  122476. * Gets or sets the connection point type (default is float)
  122477. */
  122478. type: NodeMaterialBlockConnectionPointTypes;
  122479. /**
  122480. * Gets or sets the connection point name
  122481. */
  122482. name: string;
  122483. /**
  122484. * Gets or sets a boolean indicating that this connection point can be omitted
  122485. */
  122486. isOptional: boolean;
  122487. /**
  122488. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122489. */
  122490. define: string;
  122491. /** @hidden */
  122492. _prioritizeVertex: boolean;
  122493. private _target;
  122494. /** Gets or sets the target of that connection point */
  122495. target: NodeMaterialBlockTargets;
  122496. /**
  122497. * Gets a boolean indicating that the current point is connected
  122498. */
  122499. readonly isConnected: boolean;
  122500. /**
  122501. * Gets a boolean indicating that the current point is connected to an input block
  122502. */
  122503. readonly isConnectedToInputBlock: boolean;
  122504. /**
  122505. * Gets a the connected input block (if any)
  122506. */
  122507. readonly connectInputBlock: Nullable<InputBlock>;
  122508. /** Get the other side of the connection (if any) */
  122509. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122510. /** Get the block that owns this connection point */
  122511. readonly ownerBlock: NodeMaterialBlock;
  122512. /** Get the block connected on the other side of this connection (if any) */
  122513. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122514. /** Get the block connected on the endpoints of this connection (if any) */
  122515. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122516. /** Gets the list of connected endpoints */
  122517. readonly endpoints: NodeMaterialConnectionPoint[];
  122518. /** Gets a boolean indicating if that output point is connected to at least one input */
  122519. readonly hasEndpoints: boolean;
  122520. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122521. readonly isConnectedInVertexShader: boolean;
  122522. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122523. readonly isConnectedInFragmentShader: boolean;
  122524. /**
  122525. * Creates a new connection point
  122526. * @param name defines the connection point name
  122527. * @param ownerBlock defines the block hosting this connection point
  122528. */
  122529. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122530. /**
  122531. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122532. * @returns the class name
  122533. */
  122534. getClassName(): string;
  122535. /**
  122536. * Gets a boolean indicating if the current point can be connected to another point
  122537. * @param connectionPoint defines the other connection point
  122538. * @returns a boolean
  122539. */
  122540. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122541. /**
  122542. * Gets a number indicating if the current point can be connected to another point
  122543. * @param connectionPoint defines the other connection point
  122544. * @returns a number defining the compatibility state
  122545. */
  122546. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  122547. /**
  122548. * Connect this point to another connection point
  122549. * @param connectionPoint defines the other connection point
  122550. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122551. * @returns the current connection point
  122552. */
  122553. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122554. /**
  122555. * Disconnect this point from one of his endpoint
  122556. * @param endpoint defines the other connection point
  122557. * @returns the current connection point
  122558. */
  122559. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122560. /**
  122561. * Serializes this point in a JSON representation
  122562. * @returns the serialized point object
  122563. */
  122564. serialize(): any;
  122565. /**
  122566. * Release resources
  122567. */
  122568. dispose(): void;
  122569. }
  122570. }
  122571. declare module BABYLON {
  122572. /**
  122573. * Block used to add support for vertex skinning (bones)
  122574. */
  122575. export class BonesBlock extends NodeMaterialBlock {
  122576. /**
  122577. * Creates a new BonesBlock
  122578. * @param name defines the block name
  122579. */
  122580. constructor(name: string);
  122581. /**
  122582. * Initialize the block and prepare the context for build
  122583. * @param state defines the state that will be used for the build
  122584. */
  122585. initialize(state: NodeMaterialBuildState): void;
  122586. /**
  122587. * Gets the current class name
  122588. * @returns the class name
  122589. */
  122590. getClassName(): string;
  122591. /**
  122592. * Gets the matrix indices input component
  122593. */
  122594. readonly matricesIndices: NodeMaterialConnectionPoint;
  122595. /**
  122596. * Gets the matrix weights input component
  122597. */
  122598. readonly matricesWeights: NodeMaterialConnectionPoint;
  122599. /**
  122600. * Gets the extra matrix indices input component
  122601. */
  122602. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122603. /**
  122604. * Gets the extra matrix weights input component
  122605. */
  122606. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122607. /**
  122608. * Gets the world input component
  122609. */
  122610. readonly world: NodeMaterialConnectionPoint;
  122611. /**
  122612. * Gets the output component
  122613. */
  122614. readonly output: NodeMaterialConnectionPoint;
  122615. autoConfigure(material: NodeMaterial): void;
  122616. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122618. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122619. protected _buildBlock(state: NodeMaterialBuildState): this;
  122620. }
  122621. }
  122622. declare module BABYLON {
  122623. /**
  122624. * Block used to add support for instances
  122625. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122626. */
  122627. export class InstancesBlock extends NodeMaterialBlock {
  122628. /**
  122629. * Creates a new InstancesBlock
  122630. * @param name defines the block name
  122631. */
  122632. constructor(name: string);
  122633. /**
  122634. * Gets the current class name
  122635. * @returns the class name
  122636. */
  122637. getClassName(): string;
  122638. /**
  122639. * Gets the first world row input component
  122640. */
  122641. readonly world0: NodeMaterialConnectionPoint;
  122642. /**
  122643. * Gets the second world row input component
  122644. */
  122645. readonly world1: NodeMaterialConnectionPoint;
  122646. /**
  122647. * Gets the third world row input component
  122648. */
  122649. readonly world2: NodeMaterialConnectionPoint;
  122650. /**
  122651. * Gets the forth world row input component
  122652. */
  122653. readonly world3: NodeMaterialConnectionPoint;
  122654. /**
  122655. * Gets the world input component
  122656. */
  122657. readonly world: NodeMaterialConnectionPoint;
  122658. /**
  122659. * Gets the output component
  122660. */
  122661. readonly output: NodeMaterialConnectionPoint;
  122662. autoConfigure(material: NodeMaterial): void;
  122663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122664. protected _buildBlock(state: NodeMaterialBuildState): this;
  122665. }
  122666. }
  122667. declare module BABYLON {
  122668. /**
  122669. * Block used to add morph targets support to vertex shader
  122670. */
  122671. export class MorphTargetsBlock extends NodeMaterialBlock {
  122672. private _repeatableContentAnchor;
  122673. private _repeatebleContentGenerated;
  122674. /**
  122675. * Create a new MorphTargetsBlock
  122676. * @param name defines the block name
  122677. */
  122678. constructor(name: string);
  122679. /**
  122680. * Gets the current class name
  122681. * @returns the class name
  122682. */
  122683. getClassName(): string;
  122684. /**
  122685. * Gets the position input component
  122686. */
  122687. readonly position: NodeMaterialConnectionPoint;
  122688. /**
  122689. * Gets the normal input component
  122690. */
  122691. readonly normal: NodeMaterialConnectionPoint;
  122692. /**
  122693. * Gets the tangent input component
  122694. */
  122695. readonly tangent: NodeMaterialConnectionPoint;
  122696. /**
  122697. * Gets the tangent input component
  122698. */
  122699. readonly uv: NodeMaterialConnectionPoint;
  122700. /**
  122701. * Gets the position output component
  122702. */
  122703. readonly positionOutput: NodeMaterialConnectionPoint;
  122704. /**
  122705. * Gets the normal output component
  122706. */
  122707. readonly normalOutput: NodeMaterialConnectionPoint;
  122708. /**
  122709. * Gets the tangent output component
  122710. */
  122711. readonly tangentOutput: NodeMaterialConnectionPoint;
  122712. /**
  122713. * Gets the tangent output component
  122714. */
  122715. readonly uvOutput: NodeMaterialConnectionPoint;
  122716. initialize(state: NodeMaterialBuildState): void;
  122717. autoConfigure(material: NodeMaterial): void;
  122718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122720. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122721. protected _buildBlock(state: NodeMaterialBuildState): this;
  122722. }
  122723. }
  122724. declare module BABYLON {
  122725. /**
  122726. * Block used to get data information from a light
  122727. */
  122728. export class LightInformationBlock extends NodeMaterialBlock {
  122729. private _lightDataUniformName;
  122730. private _lightColorUniformName;
  122731. private _lightTypeDefineName;
  122732. /**
  122733. * Gets or sets the light associated with this block
  122734. */
  122735. light: Nullable<Light>;
  122736. /**
  122737. * Creates a new LightInformationBlock
  122738. * @param name defines the block name
  122739. */
  122740. constructor(name: string);
  122741. /**
  122742. * Gets the current class name
  122743. * @returns the class name
  122744. */
  122745. getClassName(): string;
  122746. /**
  122747. * Gets the world position input component
  122748. */
  122749. readonly worldPosition: NodeMaterialConnectionPoint;
  122750. /**
  122751. * Gets the direction output component
  122752. */
  122753. readonly direction: NodeMaterialConnectionPoint;
  122754. /**
  122755. * Gets the direction output component
  122756. */
  122757. readonly color: NodeMaterialConnectionPoint;
  122758. /**
  122759. * Gets the direction output component
  122760. */
  122761. readonly intensity: NodeMaterialConnectionPoint;
  122762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122764. protected _buildBlock(state: NodeMaterialBuildState): this;
  122765. serialize(): any;
  122766. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122767. }
  122768. }
  122769. declare module BABYLON {
  122770. /**
  122771. * Block used to add image processing support to fragment shader
  122772. */
  122773. export class ImageProcessingBlock extends NodeMaterialBlock {
  122774. /**
  122775. * Create a new ImageProcessingBlock
  122776. * @param name defines the block name
  122777. */
  122778. constructor(name: string);
  122779. /**
  122780. * Gets the current class name
  122781. * @returns the class name
  122782. */
  122783. getClassName(): string;
  122784. /**
  122785. * Gets the color input component
  122786. */
  122787. readonly color: NodeMaterialConnectionPoint;
  122788. /**
  122789. * Gets the output component
  122790. */
  122791. readonly output: NodeMaterialConnectionPoint;
  122792. /**
  122793. * Initialize the block and prepare the context for build
  122794. * @param state defines the state that will be used for the build
  122795. */
  122796. initialize(state: NodeMaterialBuildState): void;
  122797. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  122798. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122800. protected _buildBlock(state: NodeMaterialBuildState): this;
  122801. }
  122802. }
  122803. declare module BABYLON {
  122804. /**
  122805. * Block used to pertub normals based on a normal map
  122806. */
  122807. export class PerturbNormalBlock extends NodeMaterialBlock {
  122808. private _tangentSpaceParameterName;
  122809. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  122810. invertX: boolean;
  122811. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  122812. invertY: boolean;
  122813. /**
  122814. * Create a new PerturbNormalBlock
  122815. * @param name defines the block name
  122816. */
  122817. constructor(name: string);
  122818. /**
  122819. * Gets the current class name
  122820. * @returns the class name
  122821. */
  122822. getClassName(): string;
  122823. /**
  122824. * Gets the world position input component
  122825. */
  122826. readonly worldPosition: NodeMaterialConnectionPoint;
  122827. /**
  122828. * Gets the world normal input component
  122829. */
  122830. readonly worldNormal: NodeMaterialConnectionPoint;
  122831. /**
  122832. * Gets the uv input component
  122833. */
  122834. readonly uv: NodeMaterialConnectionPoint;
  122835. /**
  122836. * Gets the normal map color input component
  122837. */
  122838. readonly normalMapColor: NodeMaterialConnectionPoint;
  122839. /**
  122840. * Gets the strength input component
  122841. */
  122842. readonly strength: NodeMaterialConnectionPoint;
  122843. /**
  122844. * Gets the output component
  122845. */
  122846. readonly output: NodeMaterialConnectionPoint;
  122847. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122849. autoConfigure(material: NodeMaterial): void;
  122850. protected _buildBlock(state: NodeMaterialBuildState): this;
  122851. protected _dumpPropertiesCode(): string;
  122852. serialize(): any;
  122853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122854. }
  122855. }
  122856. declare module BABYLON {
  122857. /**
  122858. * Block used to discard a pixel if a value is smaller than a cutoff
  122859. */
  122860. export class DiscardBlock extends NodeMaterialBlock {
  122861. /**
  122862. * Create a new DiscardBlock
  122863. * @param name defines the block name
  122864. */
  122865. constructor(name: string);
  122866. /**
  122867. * Gets the current class name
  122868. * @returns the class name
  122869. */
  122870. getClassName(): string;
  122871. /**
  122872. * Gets the color input component
  122873. */
  122874. readonly value: NodeMaterialConnectionPoint;
  122875. /**
  122876. * Gets the cutoff input component
  122877. */
  122878. readonly cutoff: NodeMaterialConnectionPoint;
  122879. protected _buildBlock(state: NodeMaterialBuildState): this;
  122880. }
  122881. }
  122882. declare module BABYLON {
  122883. /**
  122884. * Block used to test if the fragment shader is front facing
  122885. */
  122886. export class FrontFacingBlock extends NodeMaterialBlock {
  122887. /**
  122888. * Creates a new FrontFacingBlock
  122889. * @param name defines the block name
  122890. */
  122891. constructor(name: string);
  122892. /**
  122893. * Gets the current class name
  122894. * @returns the class name
  122895. */
  122896. getClassName(): string;
  122897. /**
  122898. * Gets the output component
  122899. */
  122900. readonly output: NodeMaterialConnectionPoint;
  122901. protected _buildBlock(state: NodeMaterialBuildState): this;
  122902. }
  122903. }
  122904. declare module BABYLON {
  122905. /**
  122906. * Block used to add support for scene fog
  122907. */
  122908. export class FogBlock extends NodeMaterialBlock {
  122909. private _fogDistanceName;
  122910. private _fogParameters;
  122911. /**
  122912. * Create a new FogBlock
  122913. * @param name defines the block name
  122914. */
  122915. constructor(name: string);
  122916. /**
  122917. * Gets the current class name
  122918. * @returns the class name
  122919. */
  122920. getClassName(): string;
  122921. /**
  122922. * Gets the world position input component
  122923. */
  122924. readonly worldPosition: NodeMaterialConnectionPoint;
  122925. /**
  122926. * Gets the view input component
  122927. */
  122928. readonly view: NodeMaterialConnectionPoint;
  122929. /**
  122930. * Gets the color input component
  122931. */
  122932. readonly input: NodeMaterialConnectionPoint;
  122933. /**
  122934. * Gets the fog color input component
  122935. */
  122936. readonly fogColor: NodeMaterialConnectionPoint;
  122937. /**
  122938. * Gets the output component
  122939. */
  122940. readonly output: NodeMaterialConnectionPoint;
  122941. autoConfigure(material: NodeMaterial): void;
  122942. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122943. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122944. protected _buildBlock(state: NodeMaterialBuildState): this;
  122945. }
  122946. }
  122947. declare module BABYLON {
  122948. /**
  122949. * Block used to add light in the fragment shader
  122950. */
  122951. export class LightBlock extends NodeMaterialBlock {
  122952. private _lightId;
  122953. /**
  122954. * Gets or sets the light associated with this block
  122955. */
  122956. light: Nullable<Light>;
  122957. /**
  122958. * Create a new LightBlock
  122959. * @param name defines the block name
  122960. */
  122961. constructor(name: string);
  122962. /**
  122963. * Gets the current class name
  122964. * @returns the class name
  122965. */
  122966. getClassName(): string;
  122967. /**
  122968. * Gets the world position input component
  122969. */
  122970. readonly worldPosition: NodeMaterialConnectionPoint;
  122971. /**
  122972. * Gets the world normal input component
  122973. */
  122974. readonly worldNormal: NodeMaterialConnectionPoint;
  122975. /**
  122976. * Gets the camera (or eye) position component
  122977. */
  122978. readonly cameraPosition: NodeMaterialConnectionPoint;
  122979. /**
  122980. * Gets the glossiness component
  122981. */
  122982. readonly glossiness: NodeMaterialConnectionPoint;
  122983. /**
  122984. * Gets the glossinness power component
  122985. */
  122986. readonly glossPower: NodeMaterialConnectionPoint;
  122987. /**
  122988. * Gets the diffuse color component
  122989. */
  122990. readonly diffuseColor: NodeMaterialConnectionPoint;
  122991. /**
  122992. * Gets the specular color component
  122993. */
  122994. readonly specularColor: NodeMaterialConnectionPoint;
  122995. /**
  122996. * Gets the diffuse output component
  122997. */
  122998. readonly diffuseOutput: NodeMaterialConnectionPoint;
  122999. /**
  123000. * Gets the specular output component
  123001. */
  123002. readonly specularOutput: NodeMaterialConnectionPoint;
  123003. autoConfigure(material: NodeMaterial): void;
  123004. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123005. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123006. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123007. private _injectVertexCode;
  123008. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123009. serialize(): any;
  123010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123011. }
  123012. }
  123013. declare module BABYLON {
  123014. /**
  123015. * Block used to multiply 2 values
  123016. */
  123017. export class MultiplyBlock extends NodeMaterialBlock {
  123018. /**
  123019. * Creates a new MultiplyBlock
  123020. * @param name defines the block name
  123021. */
  123022. constructor(name: string);
  123023. /**
  123024. * Gets the current class name
  123025. * @returns the class name
  123026. */
  123027. getClassName(): string;
  123028. /**
  123029. * Gets the left operand input component
  123030. */
  123031. readonly left: NodeMaterialConnectionPoint;
  123032. /**
  123033. * Gets the right operand input component
  123034. */
  123035. readonly right: NodeMaterialConnectionPoint;
  123036. /**
  123037. * Gets the output component
  123038. */
  123039. readonly output: NodeMaterialConnectionPoint;
  123040. protected _buildBlock(state: NodeMaterialBuildState): this;
  123041. }
  123042. }
  123043. declare module BABYLON {
  123044. /**
  123045. * Block used to add 2 vectors
  123046. */
  123047. export class AddBlock extends NodeMaterialBlock {
  123048. /**
  123049. * Creates a new AddBlock
  123050. * @param name defines the block name
  123051. */
  123052. constructor(name: string);
  123053. /**
  123054. * Gets the current class name
  123055. * @returns the class name
  123056. */
  123057. getClassName(): string;
  123058. /**
  123059. * Gets the left operand input component
  123060. */
  123061. readonly left: NodeMaterialConnectionPoint;
  123062. /**
  123063. * Gets the right operand input component
  123064. */
  123065. readonly right: NodeMaterialConnectionPoint;
  123066. /**
  123067. * Gets the output component
  123068. */
  123069. readonly output: NodeMaterialConnectionPoint;
  123070. protected _buildBlock(state: NodeMaterialBuildState): this;
  123071. }
  123072. }
  123073. declare module BABYLON {
  123074. /**
  123075. * Block used to scale a vector by a float
  123076. */
  123077. export class ScaleBlock extends NodeMaterialBlock {
  123078. /**
  123079. * Creates a new ScaleBlock
  123080. * @param name defines the block name
  123081. */
  123082. constructor(name: string);
  123083. /**
  123084. * Gets the current class name
  123085. * @returns the class name
  123086. */
  123087. getClassName(): string;
  123088. /**
  123089. * Gets the input component
  123090. */
  123091. readonly input: NodeMaterialConnectionPoint;
  123092. /**
  123093. * Gets the factor input component
  123094. */
  123095. readonly factor: NodeMaterialConnectionPoint;
  123096. /**
  123097. * Gets the output component
  123098. */
  123099. readonly output: NodeMaterialConnectionPoint;
  123100. protected _buildBlock(state: NodeMaterialBuildState): this;
  123101. }
  123102. }
  123103. declare module BABYLON {
  123104. /**
  123105. * Block used to clamp a float
  123106. */
  123107. export class ClampBlock extends NodeMaterialBlock {
  123108. /** Gets or sets the minimum range */
  123109. minimum: number;
  123110. /** Gets or sets the maximum range */
  123111. maximum: number;
  123112. /**
  123113. * Creates a new ClampBlock
  123114. * @param name defines the block name
  123115. */
  123116. constructor(name: string);
  123117. /**
  123118. * Gets the current class name
  123119. * @returns the class name
  123120. */
  123121. getClassName(): string;
  123122. /**
  123123. * Gets the value input component
  123124. */
  123125. readonly value: NodeMaterialConnectionPoint;
  123126. /**
  123127. * Gets the output component
  123128. */
  123129. readonly output: NodeMaterialConnectionPoint;
  123130. protected _buildBlock(state: NodeMaterialBuildState): this;
  123131. protected _dumpPropertiesCode(): string;
  123132. serialize(): any;
  123133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123134. }
  123135. }
  123136. declare module BABYLON {
  123137. /**
  123138. * Block used to apply a cross product between 2 vectors
  123139. */
  123140. export class CrossBlock extends NodeMaterialBlock {
  123141. /**
  123142. * Creates a new CrossBlock
  123143. * @param name defines the block name
  123144. */
  123145. constructor(name: string);
  123146. /**
  123147. * Gets the current class name
  123148. * @returns the class name
  123149. */
  123150. getClassName(): string;
  123151. /**
  123152. * Gets the left operand input component
  123153. */
  123154. readonly left: NodeMaterialConnectionPoint;
  123155. /**
  123156. * Gets the right operand input component
  123157. */
  123158. readonly right: NodeMaterialConnectionPoint;
  123159. /**
  123160. * Gets the output component
  123161. */
  123162. readonly output: NodeMaterialConnectionPoint;
  123163. protected _buildBlock(state: NodeMaterialBuildState): this;
  123164. }
  123165. }
  123166. declare module BABYLON {
  123167. /**
  123168. * Block used to apply a dot product between 2 vectors
  123169. */
  123170. export class DotBlock extends NodeMaterialBlock {
  123171. /**
  123172. * Creates a new DotBlock
  123173. * @param name defines the block name
  123174. */
  123175. constructor(name: string);
  123176. /**
  123177. * Gets the current class name
  123178. * @returns the class name
  123179. */
  123180. getClassName(): string;
  123181. /**
  123182. * Gets the left operand input component
  123183. */
  123184. readonly left: NodeMaterialConnectionPoint;
  123185. /**
  123186. * Gets the right operand input component
  123187. */
  123188. readonly right: NodeMaterialConnectionPoint;
  123189. /**
  123190. * Gets the output component
  123191. */
  123192. readonly output: NodeMaterialConnectionPoint;
  123193. protected _buildBlock(state: NodeMaterialBuildState): this;
  123194. }
  123195. }
  123196. declare module BABYLON {
  123197. /**
  123198. * Block used to remap a float from a range to a new one
  123199. */
  123200. export class RemapBlock extends NodeMaterialBlock {
  123201. /**
  123202. * Gets or sets the source range
  123203. */
  123204. sourceRange: Vector2;
  123205. /**
  123206. * Gets or sets the target range
  123207. */
  123208. targetRange: Vector2;
  123209. /**
  123210. * Creates a new RemapBlock
  123211. * @param name defines the block name
  123212. */
  123213. constructor(name: string);
  123214. /**
  123215. * Gets the current class name
  123216. * @returns the class name
  123217. */
  123218. getClassName(): string;
  123219. /**
  123220. * Gets the input component
  123221. */
  123222. readonly input: NodeMaterialConnectionPoint;
  123223. /**
  123224. * Gets the source min input component
  123225. */
  123226. readonly sourceMin: NodeMaterialConnectionPoint;
  123227. /**
  123228. * Gets the source max input component
  123229. */
  123230. readonly sourceMax: NodeMaterialConnectionPoint;
  123231. /**
  123232. * Gets the target min input component
  123233. */
  123234. readonly targetMin: NodeMaterialConnectionPoint;
  123235. /**
  123236. * Gets the target max input component
  123237. */
  123238. readonly targetMax: NodeMaterialConnectionPoint;
  123239. /**
  123240. * Gets the output component
  123241. */
  123242. readonly output: NodeMaterialConnectionPoint;
  123243. protected _buildBlock(state: NodeMaterialBuildState): this;
  123244. protected _dumpPropertiesCode(): string;
  123245. serialize(): any;
  123246. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123247. }
  123248. }
  123249. declare module BABYLON {
  123250. /**
  123251. * Block used to normalize a vector
  123252. */
  123253. export class NormalizeBlock extends NodeMaterialBlock {
  123254. /**
  123255. * Creates a new NormalizeBlock
  123256. * @param name defines the block name
  123257. */
  123258. constructor(name: string);
  123259. /**
  123260. * Gets the current class name
  123261. * @returns the class name
  123262. */
  123263. getClassName(): string;
  123264. /**
  123265. * Gets the input component
  123266. */
  123267. readonly input: NodeMaterialConnectionPoint;
  123268. /**
  123269. * Gets the output component
  123270. */
  123271. readonly output: NodeMaterialConnectionPoint;
  123272. protected _buildBlock(state: NodeMaterialBuildState): this;
  123273. }
  123274. }
  123275. declare module BABYLON {
  123276. /**
  123277. * Operations supported by the Trigonometry block
  123278. */
  123279. export enum TrigonometryBlockOperations {
  123280. /** Cos */
  123281. Cos = 0,
  123282. /** Sin */
  123283. Sin = 1,
  123284. /** Abs */
  123285. Abs = 2,
  123286. /** Exp */
  123287. Exp = 3,
  123288. /** Exp2 */
  123289. Exp2 = 4,
  123290. /** Round */
  123291. Round = 5,
  123292. /** Floor */
  123293. Floor = 6,
  123294. /** Ceiling */
  123295. Ceiling = 7,
  123296. /** Square root */
  123297. Sqrt = 8,
  123298. /** Log */
  123299. Log = 9,
  123300. /** Tangent */
  123301. Tan = 10,
  123302. /** Arc tangent */
  123303. ArcTan = 11,
  123304. /** Arc cosinus */
  123305. ArcCos = 12,
  123306. /** Arc sinus */
  123307. ArcSin = 13,
  123308. /** Fraction */
  123309. Fract = 14,
  123310. /** Sign */
  123311. Sign = 15,
  123312. /** To radians (from degrees) */
  123313. Radians = 16,
  123314. /** To degrees (from radians) */
  123315. Degrees = 17
  123316. }
  123317. /**
  123318. * Block used to apply trigonometry operation to floats
  123319. */
  123320. export class TrigonometryBlock extends NodeMaterialBlock {
  123321. /**
  123322. * Gets or sets the operation applied by the block
  123323. */
  123324. operation: TrigonometryBlockOperations;
  123325. /**
  123326. * Creates a new TrigonometryBlock
  123327. * @param name defines the block name
  123328. */
  123329. constructor(name: string);
  123330. /**
  123331. * Gets the current class name
  123332. * @returns the class name
  123333. */
  123334. getClassName(): string;
  123335. /**
  123336. * Gets the input component
  123337. */
  123338. readonly input: NodeMaterialConnectionPoint;
  123339. /**
  123340. * Gets the output component
  123341. */
  123342. readonly output: NodeMaterialConnectionPoint;
  123343. protected _buildBlock(state: NodeMaterialBuildState): this;
  123344. serialize(): any;
  123345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123346. }
  123347. }
  123348. declare module BABYLON {
  123349. /**
  123350. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123351. */
  123352. export class ColorMergerBlock extends NodeMaterialBlock {
  123353. /**
  123354. * Create a new ColorMergerBlock
  123355. * @param name defines the block name
  123356. */
  123357. constructor(name: string);
  123358. /**
  123359. * Gets the current class name
  123360. * @returns the class name
  123361. */
  123362. getClassName(): string;
  123363. /**
  123364. * Gets the r component (input)
  123365. */
  123366. readonly r: NodeMaterialConnectionPoint;
  123367. /**
  123368. * Gets the g component (input)
  123369. */
  123370. readonly g: NodeMaterialConnectionPoint;
  123371. /**
  123372. * Gets the b component (input)
  123373. */
  123374. readonly b: NodeMaterialConnectionPoint;
  123375. /**
  123376. * Gets the a component (input)
  123377. */
  123378. readonly a: NodeMaterialConnectionPoint;
  123379. /**
  123380. * Gets the rgba component (output)
  123381. */
  123382. readonly rgba: NodeMaterialConnectionPoint;
  123383. /**
  123384. * Gets the rgb component (output)
  123385. */
  123386. readonly rgb: NodeMaterialConnectionPoint;
  123387. protected _buildBlock(state: NodeMaterialBuildState): this;
  123388. }
  123389. }
  123390. declare module BABYLON {
  123391. /**
  123392. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123393. */
  123394. export class VectorMergerBlock extends NodeMaterialBlock {
  123395. /**
  123396. * Create a new VectorMergerBlock
  123397. * @param name defines the block name
  123398. */
  123399. constructor(name: string);
  123400. /**
  123401. * Gets the current class name
  123402. * @returns the class name
  123403. */
  123404. getClassName(): string;
  123405. /**
  123406. * Gets the x component (input)
  123407. */
  123408. readonly x: NodeMaterialConnectionPoint;
  123409. /**
  123410. * Gets the y component (input)
  123411. */
  123412. readonly y: NodeMaterialConnectionPoint;
  123413. /**
  123414. * Gets the z component (input)
  123415. */
  123416. readonly z: NodeMaterialConnectionPoint;
  123417. /**
  123418. * Gets the w component (input)
  123419. */
  123420. readonly w: NodeMaterialConnectionPoint;
  123421. /**
  123422. * Gets the xyzw component (output)
  123423. */
  123424. readonly xyzw: NodeMaterialConnectionPoint;
  123425. /**
  123426. * Gets the xyz component (output)
  123427. */
  123428. readonly xyz: NodeMaterialConnectionPoint;
  123429. /**
  123430. * Gets the xy component (output)
  123431. */
  123432. readonly xy: NodeMaterialConnectionPoint;
  123433. protected _buildBlock(state: NodeMaterialBuildState): this;
  123434. }
  123435. }
  123436. declare module BABYLON {
  123437. /**
  123438. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123439. */
  123440. export class ColorSplitterBlock extends NodeMaterialBlock {
  123441. /**
  123442. * Create a new ColorSplitterBlock
  123443. * @param name defines the block name
  123444. */
  123445. constructor(name: string);
  123446. /**
  123447. * Gets the current class name
  123448. * @returns the class name
  123449. */
  123450. getClassName(): string;
  123451. /**
  123452. * Gets the rgba component (input)
  123453. */
  123454. readonly rgba: NodeMaterialConnectionPoint;
  123455. /**
  123456. * Gets the rgb component (input)
  123457. */
  123458. readonly rgbIn: NodeMaterialConnectionPoint;
  123459. /**
  123460. * Gets the rgb component (output)
  123461. */
  123462. readonly rgbOut: NodeMaterialConnectionPoint;
  123463. /**
  123464. * Gets the r component (output)
  123465. */
  123466. readonly r: NodeMaterialConnectionPoint;
  123467. /**
  123468. * Gets the g component (output)
  123469. */
  123470. readonly g: NodeMaterialConnectionPoint;
  123471. /**
  123472. * Gets the b component (output)
  123473. */
  123474. readonly b: NodeMaterialConnectionPoint;
  123475. /**
  123476. * Gets the a component (output)
  123477. */
  123478. readonly a: NodeMaterialConnectionPoint;
  123479. protected _inputRename(name: string): string;
  123480. protected _outputRename(name: string): string;
  123481. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123482. }
  123483. }
  123484. declare module BABYLON {
  123485. /**
  123486. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123487. */
  123488. export class VectorSplitterBlock extends NodeMaterialBlock {
  123489. /**
  123490. * Create a new VectorSplitterBlock
  123491. * @param name defines the block name
  123492. */
  123493. constructor(name: string);
  123494. /**
  123495. * Gets the current class name
  123496. * @returns the class name
  123497. */
  123498. getClassName(): string;
  123499. /**
  123500. * Gets the xyzw component (input)
  123501. */
  123502. readonly xyzw: NodeMaterialConnectionPoint;
  123503. /**
  123504. * Gets the xyz component (input)
  123505. */
  123506. readonly xyzIn: NodeMaterialConnectionPoint;
  123507. /**
  123508. * Gets the xy component (input)
  123509. */
  123510. readonly xyIn: NodeMaterialConnectionPoint;
  123511. /**
  123512. * Gets the xyz component (output)
  123513. */
  123514. readonly xyzOut: NodeMaterialConnectionPoint;
  123515. /**
  123516. * Gets the xy component (output)
  123517. */
  123518. readonly xyOut: NodeMaterialConnectionPoint;
  123519. /**
  123520. * Gets the x component (output)
  123521. */
  123522. readonly x: NodeMaterialConnectionPoint;
  123523. /**
  123524. * Gets the y component (output)
  123525. */
  123526. readonly y: NodeMaterialConnectionPoint;
  123527. /**
  123528. * Gets the z component (output)
  123529. */
  123530. readonly z: NodeMaterialConnectionPoint;
  123531. /**
  123532. * Gets the w component (output)
  123533. */
  123534. readonly w: NodeMaterialConnectionPoint;
  123535. protected _inputRename(name: string): string;
  123536. protected _outputRename(name: string): string;
  123537. protected _buildBlock(state: NodeMaterialBuildState): this;
  123538. }
  123539. }
  123540. declare module BABYLON {
  123541. /**
  123542. * Block used to lerp between 2 values
  123543. */
  123544. export class LerpBlock extends NodeMaterialBlock {
  123545. /**
  123546. * Creates a new LerpBlock
  123547. * @param name defines the block name
  123548. */
  123549. constructor(name: string);
  123550. /**
  123551. * Gets the current class name
  123552. * @returns the class name
  123553. */
  123554. getClassName(): string;
  123555. /**
  123556. * Gets the left operand input component
  123557. */
  123558. readonly left: NodeMaterialConnectionPoint;
  123559. /**
  123560. * Gets the right operand input component
  123561. */
  123562. readonly right: NodeMaterialConnectionPoint;
  123563. /**
  123564. * Gets the gradient operand input component
  123565. */
  123566. readonly gradient: NodeMaterialConnectionPoint;
  123567. /**
  123568. * Gets the output component
  123569. */
  123570. readonly output: NodeMaterialConnectionPoint;
  123571. protected _buildBlock(state: NodeMaterialBuildState): this;
  123572. }
  123573. }
  123574. declare module BABYLON {
  123575. /**
  123576. * Block used to divide 2 vectors
  123577. */
  123578. export class DivideBlock extends NodeMaterialBlock {
  123579. /**
  123580. * Creates a new DivideBlock
  123581. * @param name defines the block name
  123582. */
  123583. constructor(name: string);
  123584. /**
  123585. * Gets the current class name
  123586. * @returns the class name
  123587. */
  123588. getClassName(): string;
  123589. /**
  123590. * Gets the left operand input component
  123591. */
  123592. readonly left: NodeMaterialConnectionPoint;
  123593. /**
  123594. * Gets the right operand input component
  123595. */
  123596. readonly right: NodeMaterialConnectionPoint;
  123597. /**
  123598. * Gets the output component
  123599. */
  123600. readonly output: NodeMaterialConnectionPoint;
  123601. protected _buildBlock(state: NodeMaterialBuildState): this;
  123602. }
  123603. }
  123604. declare module BABYLON {
  123605. /**
  123606. * Block used to subtract 2 vectors
  123607. */
  123608. export class SubtractBlock extends NodeMaterialBlock {
  123609. /**
  123610. * Creates a new SubtractBlock
  123611. * @param name defines the block name
  123612. */
  123613. constructor(name: string);
  123614. /**
  123615. * Gets the current class name
  123616. * @returns the class name
  123617. */
  123618. getClassName(): string;
  123619. /**
  123620. * Gets the left operand input component
  123621. */
  123622. readonly left: NodeMaterialConnectionPoint;
  123623. /**
  123624. * Gets the right operand input component
  123625. */
  123626. readonly right: NodeMaterialConnectionPoint;
  123627. /**
  123628. * Gets the output component
  123629. */
  123630. readonly output: NodeMaterialConnectionPoint;
  123631. protected _buildBlock(state: NodeMaterialBuildState): this;
  123632. }
  123633. }
  123634. declare module BABYLON {
  123635. /**
  123636. * Block used to step a value
  123637. */
  123638. export class StepBlock extends NodeMaterialBlock {
  123639. /**
  123640. * Creates a new StepBlock
  123641. * @param name defines the block name
  123642. */
  123643. constructor(name: string);
  123644. /**
  123645. * Gets the current class name
  123646. * @returns the class name
  123647. */
  123648. getClassName(): string;
  123649. /**
  123650. * Gets the value operand input component
  123651. */
  123652. readonly value: NodeMaterialConnectionPoint;
  123653. /**
  123654. * Gets the edge operand input component
  123655. */
  123656. readonly edge: NodeMaterialConnectionPoint;
  123657. /**
  123658. * Gets the output component
  123659. */
  123660. readonly output: NodeMaterialConnectionPoint;
  123661. protected _buildBlock(state: NodeMaterialBuildState): this;
  123662. }
  123663. }
  123664. declare module BABYLON {
  123665. /**
  123666. * Block used to get the opposite (1 - x) of a value
  123667. */
  123668. export class OneMinusBlock extends NodeMaterialBlock {
  123669. /**
  123670. * Creates a new OneMinusBlock
  123671. * @param name defines the block name
  123672. */
  123673. constructor(name: string);
  123674. /**
  123675. * Gets the current class name
  123676. * @returns the class name
  123677. */
  123678. getClassName(): string;
  123679. /**
  123680. * Gets the input component
  123681. */
  123682. readonly input: NodeMaterialConnectionPoint;
  123683. /**
  123684. * Gets the output component
  123685. */
  123686. readonly output: NodeMaterialConnectionPoint;
  123687. protected _buildBlock(state: NodeMaterialBuildState): this;
  123688. }
  123689. }
  123690. declare module BABYLON {
  123691. /**
  123692. * Block used to get the view direction
  123693. */
  123694. export class ViewDirectionBlock extends NodeMaterialBlock {
  123695. /**
  123696. * Creates a new ViewDirectionBlock
  123697. * @param name defines the block name
  123698. */
  123699. constructor(name: string);
  123700. /**
  123701. * Gets the current class name
  123702. * @returns the class name
  123703. */
  123704. getClassName(): string;
  123705. /**
  123706. * Gets the world position component
  123707. */
  123708. readonly worldPosition: NodeMaterialConnectionPoint;
  123709. /**
  123710. * Gets the camera position component
  123711. */
  123712. readonly cameraPosition: NodeMaterialConnectionPoint;
  123713. /**
  123714. * Gets the output component
  123715. */
  123716. readonly output: NodeMaterialConnectionPoint;
  123717. autoConfigure(material: NodeMaterial): void;
  123718. protected _buildBlock(state: NodeMaterialBuildState): this;
  123719. }
  123720. }
  123721. declare module BABYLON {
  123722. /**
  123723. * Block used to compute fresnel value
  123724. */
  123725. export class FresnelBlock extends NodeMaterialBlock {
  123726. /**
  123727. * Create a new FresnelBlock
  123728. * @param name defines the block name
  123729. */
  123730. constructor(name: string);
  123731. /**
  123732. * Gets the current class name
  123733. * @returns the class name
  123734. */
  123735. getClassName(): string;
  123736. /**
  123737. * Gets the world normal input component
  123738. */
  123739. readonly worldNormal: NodeMaterialConnectionPoint;
  123740. /**
  123741. * Gets the view direction input component
  123742. */
  123743. readonly viewDirection: NodeMaterialConnectionPoint;
  123744. /**
  123745. * Gets the bias input component
  123746. */
  123747. readonly bias: NodeMaterialConnectionPoint;
  123748. /**
  123749. * Gets the camera (or eye) position component
  123750. */
  123751. readonly power: NodeMaterialConnectionPoint;
  123752. /**
  123753. * Gets the fresnel output component
  123754. */
  123755. readonly fresnel: NodeMaterialConnectionPoint;
  123756. autoConfigure(material: NodeMaterial): void;
  123757. protected _buildBlock(state: NodeMaterialBuildState): this;
  123758. }
  123759. }
  123760. declare module BABYLON {
  123761. /**
  123762. * Block used to get the max of 2 values
  123763. */
  123764. export class MaxBlock extends NodeMaterialBlock {
  123765. /**
  123766. * Creates a new MaxBlock
  123767. * @param name defines the block name
  123768. */
  123769. constructor(name: string);
  123770. /**
  123771. * Gets the current class name
  123772. * @returns the class name
  123773. */
  123774. getClassName(): string;
  123775. /**
  123776. * Gets the left operand input component
  123777. */
  123778. readonly left: NodeMaterialConnectionPoint;
  123779. /**
  123780. * Gets the right operand input component
  123781. */
  123782. readonly right: NodeMaterialConnectionPoint;
  123783. /**
  123784. * Gets the output component
  123785. */
  123786. readonly output: NodeMaterialConnectionPoint;
  123787. protected _buildBlock(state: NodeMaterialBuildState): this;
  123788. }
  123789. }
  123790. declare module BABYLON {
  123791. /**
  123792. * Block used to get the min of 2 values
  123793. */
  123794. export class MinBlock extends NodeMaterialBlock {
  123795. /**
  123796. * Creates a new MinBlock
  123797. * @param name defines the block name
  123798. */
  123799. constructor(name: string);
  123800. /**
  123801. * Gets the current class name
  123802. * @returns the class name
  123803. */
  123804. getClassName(): string;
  123805. /**
  123806. * Gets the left operand input component
  123807. */
  123808. readonly left: NodeMaterialConnectionPoint;
  123809. /**
  123810. * Gets the right operand input component
  123811. */
  123812. readonly right: NodeMaterialConnectionPoint;
  123813. /**
  123814. * Gets the output component
  123815. */
  123816. readonly output: NodeMaterialConnectionPoint;
  123817. protected _buildBlock(state: NodeMaterialBuildState): this;
  123818. }
  123819. }
  123820. declare module BABYLON {
  123821. /**
  123822. * Block used to get the distance between 2 values
  123823. */
  123824. export class DistanceBlock extends NodeMaterialBlock {
  123825. /**
  123826. * Creates a new DistanceBlock
  123827. * @param name defines the block name
  123828. */
  123829. constructor(name: string);
  123830. /**
  123831. * Gets the current class name
  123832. * @returns the class name
  123833. */
  123834. getClassName(): string;
  123835. /**
  123836. * Gets the left operand input component
  123837. */
  123838. readonly left: NodeMaterialConnectionPoint;
  123839. /**
  123840. * Gets the right operand input component
  123841. */
  123842. readonly right: NodeMaterialConnectionPoint;
  123843. /**
  123844. * Gets the output component
  123845. */
  123846. readonly output: NodeMaterialConnectionPoint;
  123847. protected _buildBlock(state: NodeMaterialBuildState): this;
  123848. }
  123849. }
  123850. declare module BABYLON {
  123851. /**
  123852. * Block used to get the length of a vector
  123853. */
  123854. export class LengthBlock extends NodeMaterialBlock {
  123855. /**
  123856. * Creates a new LengthBlock
  123857. * @param name defines the block name
  123858. */
  123859. constructor(name: string);
  123860. /**
  123861. * Gets the current class name
  123862. * @returns the class name
  123863. */
  123864. getClassName(): string;
  123865. /**
  123866. * Gets the value input component
  123867. */
  123868. readonly value: NodeMaterialConnectionPoint;
  123869. /**
  123870. * Gets the output component
  123871. */
  123872. readonly output: NodeMaterialConnectionPoint;
  123873. protected _buildBlock(state: NodeMaterialBuildState): this;
  123874. }
  123875. }
  123876. declare module BABYLON {
  123877. /**
  123878. * Block used to get negative version of a value (i.e. x * -1)
  123879. */
  123880. export class NegateBlock extends NodeMaterialBlock {
  123881. /**
  123882. * Creates a new NegateBlock
  123883. * @param name defines the block name
  123884. */
  123885. constructor(name: string);
  123886. /**
  123887. * Gets the current class name
  123888. * @returns the class name
  123889. */
  123890. getClassName(): string;
  123891. /**
  123892. * Gets the value input component
  123893. */
  123894. readonly value: NodeMaterialConnectionPoint;
  123895. /**
  123896. * Gets the output component
  123897. */
  123898. readonly output: NodeMaterialConnectionPoint;
  123899. protected _buildBlock(state: NodeMaterialBuildState): this;
  123900. }
  123901. }
  123902. declare module BABYLON {
  123903. /**
  123904. * Block used to get the value of the first parameter raised to the power of the second
  123905. */
  123906. export class PowBlock extends NodeMaterialBlock {
  123907. /**
  123908. * Creates a new PowBlock
  123909. * @param name defines the block name
  123910. */
  123911. constructor(name: string);
  123912. /**
  123913. * Gets the current class name
  123914. * @returns the class name
  123915. */
  123916. getClassName(): string;
  123917. /**
  123918. * Gets the value operand input component
  123919. */
  123920. readonly value: NodeMaterialConnectionPoint;
  123921. /**
  123922. * Gets the power operand input component
  123923. */
  123924. readonly power: NodeMaterialConnectionPoint;
  123925. /**
  123926. * Gets the output component
  123927. */
  123928. readonly output: NodeMaterialConnectionPoint;
  123929. protected _buildBlock(state: NodeMaterialBuildState): this;
  123930. }
  123931. }
  123932. declare module BABYLON {
  123933. /**
  123934. * Block used to get a random number
  123935. */
  123936. export class RandomNumberBlock extends NodeMaterialBlock {
  123937. /**
  123938. * Creates a new RandomNumberBlock
  123939. * @param name defines the block name
  123940. */
  123941. constructor(name: string);
  123942. /**
  123943. * Gets the current class name
  123944. * @returns the class name
  123945. */
  123946. getClassName(): string;
  123947. /**
  123948. * Gets the seed input component
  123949. */
  123950. readonly seed: NodeMaterialConnectionPoint;
  123951. /**
  123952. * Gets the output component
  123953. */
  123954. readonly output: NodeMaterialConnectionPoint;
  123955. protected _buildBlock(state: NodeMaterialBuildState): this;
  123956. }
  123957. }
  123958. declare module BABYLON {
  123959. /**
  123960. * Block used to compute arc tangent of 2 values
  123961. */
  123962. export class ArcTan2Block extends NodeMaterialBlock {
  123963. /**
  123964. * Creates a new ArcTan2Block
  123965. * @param name defines the block name
  123966. */
  123967. constructor(name: string);
  123968. /**
  123969. * Gets the current class name
  123970. * @returns the class name
  123971. */
  123972. getClassName(): string;
  123973. /**
  123974. * Gets the x operand input component
  123975. */
  123976. readonly x: NodeMaterialConnectionPoint;
  123977. /**
  123978. * Gets the y operand input component
  123979. */
  123980. readonly y: NodeMaterialConnectionPoint;
  123981. /**
  123982. * Gets the output component
  123983. */
  123984. readonly output: NodeMaterialConnectionPoint;
  123985. protected _buildBlock(state: NodeMaterialBuildState): this;
  123986. }
  123987. }
  123988. declare module BABYLON {
  123989. /**
  123990. * Block used to smooth step a value
  123991. */
  123992. export class SmoothStepBlock extends NodeMaterialBlock {
  123993. /**
  123994. * Creates a new SmoothStepBlock
  123995. * @param name defines the block name
  123996. */
  123997. constructor(name: string);
  123998. /**
  123999. * Gets the current class name
  124000. * @returns the class name
  124001. */
  124002. getClassName(): string;
  124003. /**
  124004. * Gets the value operand input component
  124005. */
  124006. readonly value: NodeMaterialConnectionPoint;
  124007. /**
  124008. * Gets the first edge operand input component
  124009. */
  124010. readonly edge0: NodeMaterialConnectionPoint;
  124011. /**
  124012. * Gets the second edge operand input component
  124013. */
  124014. readonly edge1: NodeMaterialConnectionPoint;
  124015. /**
  124016. * Gets the output component
  124017. */
  124018. readonly output: NodeMaterialConnectionPoint;
  124019. protected _buildBlock(state: NodeMaterialBuildState): this;
  124020. }
  124021. }
  124022. declare module BABYLON {
  124023. /**
  124024. * Block used to get the reciprocal (1 / x) of a value
  124025. */
  124026. export class ReciprocalBlock extends NodeMaterialBlock {
  124027. /**
  124028. * Creates a new ReciprocalBlock
  124029. * @param name defines the block name
  124030. */
  124031. constructor(name: string);
  124032. /**
  124033. * Gets the current class name
  124034. * @returns the class name
  124035. */
  124036. getClassName(): string;
  124037. /**
  124038. * Gets the input component
  124039. */
  124040. readonly input: NodeMaterialConnectionPoint;
  124041. /**
  124042. * Gets the output component
  124043. */
  124044. readonly output: NodeMaterialConnectionPoint;
  124045. protected _buildBlock(state: NodeMaterialBuildState): this;
  124046. }
  124047. }
  124048. declare module BABYLON {
  124049. /**
  124050. * Block used to replace a color by another one
  124051. */
  124052. export class ReplaceColorBlock extends NodeMaterialBlock {
  124053. /**
  124054. * Creates a new ReplaceColorBlock
  124055. * @param name defines the block name
  124056. */
  124057. constructor(name: string);
  124058. /**
  124059. * Gets the current class name
  124060. * @returns the class name
  124061. */
  124062. getClassName(): string;
  124063. /**
  124064. * Gets the value input component
  124065. */
  124066. readonly value: NodeMaterialConnectionPoint;
  124067. /**
  124068. * Gets the reference input component
  124069. */
  124070. readonly reference: NodeMaterialConnectionPoint;
  124071. /**
  124072. * Gets the distance input component
  124073. */
  124074. readonly distance: NodeMaterialConnectionPoint;
  124075. /**
  124076. * Gets the replacement input component
  124077. */
  124078. readonly replacement: NodeMaterialConnectionPoint;
  124079. /**
  124080. * Gets the output component
  124081. */
  124082. readonly output: NodeMaterialConnectionPoint;
  124083. protected _buildBlock(state: NodeMaterialBuildState): this;
  124084. }
  124085. }
  124086. declare module BABYLON {
  124087. /**
  124088. * Block used to posterize a value
  124089. * @see https://en.wikipedia.org/wiki/Posterization
  124090. */
  124091. export class PosterizeBlock extends NodeMaterialBlock {
  124092. /**
  124093. * Creates a new PosterizeBlock
  124094. * @param name defines the block name
  124095. */
  124096. constructor(name: string);
  124097. /**
  124098. * Gets the current class name
  124099. * @returns the class name
  124100. */
  124101. getClassName(): string;
  124102. /**
  124103. * Gets the value input component
  124104. */
  124105. readonly value: NodeMaterialConnectionPoint;
  124106. /**
  124107. * Gets the steps input component
  124108. */
  124109. readonly steps: NodeMaterialConnectionPoint;
  124110. /**
  124111. * Gets the output component
  124112. */
  124113. readonly output: NodeMaterialConnectionPoint;
  124114. protected _buildBlock(state: NodeMaterialBuildState): this;
  124115. }
  124116. }
  124117. declare module BABYLON {
  124118. /**
  124119. * Operations supported by the Wave block
  124120. */
  124121. export enum WaveBlockKind {
  124122. /** SawTooth */
  124123. SawTooth = 0,
  124124. /** Square */
  124125. Square = 1,
  124126. /** Triangle */
  124127. Triangle = 2
  124128. }
  124129. /**
  124130. * Block used to apply wave operation to floats
  124131. */
  124132. export class WaveBlock extends NodeMaterialBlock {
  124133. /**
  124134. * Gets or sets the kibnd of wave to be applied by the block
  124135. */
  124136. kind: WaveBlockKind;
  124137. /**
  124138. * Creates a new WaveBlock
  124139. * @param name defines the block name
  124140. */
  124141. constructor(name: string);
  124142. /**
  124143. * Gets the current class name
  124144. * @returns the class name
  124145. */
  124146. getClassName(): string;
  124147. /**
  124148. * Gets the input component
  124149. */
  124150. readonly input: NodeMaterialConnectionPoint;
  124151. /**
  124152. * Gets the output component
  124153. */
  124154. readonly output: NodeMaterialConnectionPoint;
  124155. protected _buildBlock(state: NodeMaterialBuildState): this;
  124156. serialize(): any;
  124157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124158. }
  124159. }
  124160. declare module BABYLON {
  124161. /**
  124162. * Class used to store a color step for the GradientBlock
  124163. */
  124164. export class GradientBlockColorStep {
  124165. /**
  124166. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124167. */
  124168. step: number;
  124169. /**
  124170. * Gets or sets the color associated with this step
  124171. */
  124172. color: Color3;
  124173. /**
  124174. * Creates a new GradientBlockColorStep
  124175. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124176. * @param color defines the color associated with this step
  124177. */
  124178. constructor(
  124179. /**
  124180. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124181. */
  124182. step: number,
  124183. /**
  124184. * Gets or sets the color associated with this step
  124185. */
  124186. color: Color3);
  124187. }
  124188. /**
  124189. * Block used to return a color from a gradient based on an input value between 0 and 1
  124190. */
  124191. export class GradientBlock extends NodeMaterialBlock {
  124192. /**
  124193. * Gets or sets the list of color steps
  124194. */
  124195. colorSteps: GradientBlockColorStep[];
  124196. /**
  124197. * Creates a new GradientBlock
  124198. * @param name defines the block name
  124199. */
  124200. constructor(name: string);
  124201. /**
  124202. * Gets the current class name
  124203. * @returns the class name
  124204. */
  124205. getClassName(): string;
  124206. /**
  124207. * Gets the gradient input component
  124208. */
  124209. readonly gradient: NodeMaterialConnectionPoint;
  124210. /**
  124211. * Gets the output component
  124212. */
  124213. readonly output: NodeMaterialConnectionPoint;
  124214. private _writeColorConstant;
  124215. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124216. serialize(): any;
  124217. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124218. protected _dumpPropertiesCode(): string;
  124219. }
  124220. }
  124221. declare module BABYLON {
  124222. /**
  124223. * Block used to normalize lerp between 2 values
  124224. */
  124225. export class NLerpBlock extends NodeMaterialBlock {
  124226. /**
  124227. * Creates a new NLerpBlock
  124228. * @param name defines the block name
  124229. */
  124230. constructor(name: string);
  124231. /**
  124232. * Gets the current class name
  124233. * @returns the class name
  124234. */
  124235. getClassName(): string;
  124236. /**
  124237. * Gets the left operand input component
  124238. */
  124239. readonly left: NodeMaterialConnectionPoint;
  124240. /**
  124241. * Gets the right operand input component
  124242. */
  124243. readonly right: NodeMaterialConnectionPoint;
  124244. /**
  124245. * Gets the gradient operand input component
  124246. */
  124247. readonly gradient: NodeMaterialConnectionPoint;
  124248. /**
  124249. * Gets the output component
  124250. */
  124251. readonly output: NodeMaterialConnectionPoint;
  124252. protected _buildBlock(state: NodeMaterialBuildState): this;
  124253. }
  124254. }
  124255. declare module BABYLON {
  124256. /**
  124257. * Effect Render Options
  124258. */
  124259. export interface IEffectRendererOptions {
  124260. /**
  124261. * Defines the vertices positions.
  124262. */
  124263. positions?: number[];
  124264. /**
  124265. * Defines the indices.
  124266. */
  124267. indices?: number[];
  124268. }
  124269. /**
  124270. * Helper class to render one or more effects
  124271. */
  124272. export class EffectRenderer {
  124273. private engine;
  124274. private static _DefaultOptions;
  124275. private _vertexBuffers;
  124276. private _indexBuffer;
  124277. private _ringBufferIndex;
  124278. private _ringScreenBuffer;
  124279. private _fullscreenViewport;
  124280. private _getNextFrameBuffer;
  124281. /**
  124282. * Creates an effect renderer
  124283. * @param engine the engine to use for rendering
  124284. * @param options defines the options of the effect renderer
  124285. */
  124286. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124287. /**
  124288. * Sets the current viewport in normalized coordinates 0-1
  124289. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124290. */
  124291. setViewport(viewport?: Viewport): void;
  124292. /**
  124293. * Binds the embedded attributes buffer to the effect.
  124294. * @param effect Defines the effect to bind the attributes for
  124295. */
  124296. bindBuffers(effect: Effect): void;
  124297. /**
  124298. * Sets the current effect wrapper to use during draw.
  124299. * The effect needs to be ready before calling this api.
  124300. * This also sets the default full screen position attribute.
  124301. * @param effectWrapper Defines the effect to draw with
  124302. */
  124303. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124304. /**
  124305. * Draws a full screen quad.
  124306. */
  124307. draw(): void;
  124308. /**
  124309. * renders one or more effects to a specified texture
  124310. * @param effectWrappers list of effects to renderer
  124311. * @param outputTexture texture to draw to, if null it will render to the screen
  124312. */
  124313. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124314. /**
  124315. * Disposes of the effect renderer
  124316. */
  124317. dispose(): void;
  124318. }
  124319. /**
  124320. * Options to create an EffectWrapper
  124321. */
  124322. interface EffectWrapperCreationOptions {
  124323. /**
  124324. * Engine to use to create the effect
  124325. */
  124326. engine: ThinEngine;
  124327. /**
  124328. * Fragment shader for the effect
  124329. */
  124330. fragmentShader: string;
  124331. /**
  124332. * Vertex shader for the effect
  124333. */
  124334. vertexShader?: string;
  124335. /**
  124336. * Attributes to use in the shader
  124337. */
  124338. attributeNames?: Array<string>;
  124339. /**
  124340. * Uniforms to use in the shader
  124341. */
  124342. uniformNames?: Array<string>;
  124343. /**
  124344. * Texture sampler names to use in the shader
  124345. */
  124346. samplerNames?: Array<string>;
  124347. /**
  124348. * The friendly name of the effect displayed in Spector.
  124349. */
  124350. name?: string;
  124351. }
  124352. /**
  124353. * Wraps an effect to be used for rendering
  124354. */
  124355. export class EffectWrapper {
  124356. /**
  124357. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124358. */
  124359. onApplyObservable: Observable<{}>;
  124360. /**
  124361. * The underlying effect
  124362. */
  124363. effect: Effect;
  124364. /**
  124365. * Creates an effect to be renderer
  124366. * @param creationOptions options to create the effect
  124367. */
  124368. constructor(creationOptions: EffectWrapperCreationOptions);
  124369. /**
  124370. * Disposes of the effect wrapper
  124371. */
  124372. dispose(): void;
  124373. }
  124374. }
  124375. declare module BABYLON {
  124376. /**
  124377. * Helper class to push actions to a pool of workers.
  124378. */
  124379. export class WorkerPool implements IDisposable {
  124380. private _workerInfos;
  124381. private _pendingActions;
  124382. /**
  124383. * Constructor
  124384. * @param workers Array of workers to use for actions
  124385. */
  124386. constructor(workers: Array<Worker>);
  124387. /**
  124388. * Terminates all workers and clears any pending actions.
  124389. */
  124390. dispose(): void;
  124391. /**
  124392. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124393. * pended until a worker has completed its action.
  124394. * @param action The action to perform. Call onComplete when the action is complete.
  124395. */
  124396. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124397. private _execute;
  124398. }
  124399. }
  124400. declare module BABYLON {
  124401. /**
  124402. * Configuration for Draco compression
  124403. */
  124404. export interface IDracoCompressionConfiguration {
  124405. /**
  124406. * Configuration for the decoder.
  124407. */
  124408. decoder: {
  124409. /**
  124410. * The url to the WebAssembly module.
  124411. */
  124412. wasmUrl?: string;
  124413. /**
  124414. * The url to the WebAssembly binary.
  124415. */
  124416. wasmBinaryUrl?: string;
  124417. /**
  124418. * The url to the fallback JavaScript module.
  124419. */
  124420. fallbackUrl?: string;
  124421. };
  124422. }
  124423. /**
  124424. * Draco compression (https://google.github.io/draco/)
  124425. *
  124426. * This class wraps the Draco module.
  124427. *
  124428. * **Encoder**
  124429. *
  124430. * The encoder is not currently implemented.
  124431. *
  124432. * **Decoder**
  124433. *
  124434. * 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.
  124435. *
  124436. * To update the configuration, use the following code:
  124437. * ```javascript
  124438. * DracoCompression.Configuration = {
  124439. * decoder: {
  124440. * wasmUrl: "<url to the WebAssembly library>",
  124441. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124442. * fallbackUrl: "<url to the fallback JavaScript library>",
  124443. * }
  124444. * };
  124445. * ```
  124446. *
  124447. * 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.
  124448. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124449. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124450. *
  124451. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124452. * ```javascript
  124453. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124454. * ```
  124455. *
  124456. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124457. */
  124458. export class DracoCompression implements IDisposable {
  124459. private _workerPoolPromise?;
  124460. private _decoderModulePromise?;
  124461. /**
  124462. * The configuration. Defaults to the following urls:
  124463. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124464. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124465. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124466. */
  124467. static Configuration: IDracoCompressionConfiguration;
  124468. /**
  124469. * Returns true if the decoder configuration is available.
  124470. */
  124471. static readonly DecoderAvailable: boolean;
  124472. /**
  124473. * Default number of workers to create when creating the draco compression object.
  124474. */
  124475. static DefaultNumWorkers: number;
  124476. private static GetDefaultNumWorkers;
  124477. private static _Default;
  124478. /**
  124479. * Default instance for the draco compression object.
  124480. */
  124481. static readonly Default: DracoCompression;
  124482. /**
  124483. * Constructor
  124484. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  124485. */
  124486. constructor(numWorkers?: number);
  124487. /**
  124488. * Stop all async operations and release resources.
  124489. */
  124490. dispose(): void;
  124491. /**
  124492. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124493. * @returns a promise that resolves when ready
  124494. */
  124495. whenReadyAsync(): Promise<void>;
  124496. /**
  124497. * Decode Draco compressed mesh data to vertex data.
  124498. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124499. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124500. * @returns A promise that resolves with the decoded vertex data
  124501. */
  124502. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124503. [kind: string]: number;
  124504. }): Promise<VertexData>;
  124505. }
  124506. }
  124507. declare module BABYLON {
  124508. /**
  124509. * Class for building Constructive Solid Geometry
  124510. */
  124511. export class CSG {
  124512. private polygons;
  124513. /**
  124514. * The world matrix
  124515. */
  124516. matrix: Matrix;
  124517. /**
  124518. * Stores the position
  124519. */
  124520. position: Vector3;
  124521. /**
  124522. * Stores the rotation
  124523. */
  124524. rotation: Vector3;
  124525. /**
  124526. * Stores the rotation quaternion
  124527. */
  124528. rotationQuaternion: Nullable<Quaternion>;
  124529. /**
  124530. * Stores the scaling vector
  124531. */
  124532. scaling: Vector3;
  124533. /**
  124534. * Convert the Mesh to CSG
  124535. * @param mesh The Mesh to convert to CSG
  124536. * @returns A new CSG from the Mesh
  124537. */
  124538. static FromMesh(mesh: Mesh): CSG;
  124539. /**
  124540. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124541. * @param polygons Polygons used to construct a CSG solid
  124542. */
  124543. private static FromPolygons;
  124544. /**
  124545. * Clones, or makes a deep copy, of the CSG
  124546. * @returns A new CSG
  124547. */
  124548. clone(): CSG;
  124549. /**
  124550. * Unions this CSG with another CSG
  124551. * @param csg The CSG to union against this CSG
  124552. * @returns The unioned CSG
  124553. */
  124554. union(csg: CSG): CSG;
  124555. /**
  124556. * Unions this CSG with another CSG in place
  124557. * @param csg The CSG to union against this CSG
  124558. */
  124559. unionInPlace(csg: CSG): void;
  124560. /**
  124561. * Subtracts this CSG with another CSG
  124562. * @param csg The CSG to subtract against this CSG
  124563. * @returns A new CSG
  124564. */
  124565. subtract(csg: CSG): CSG;
  124566. /**
  124567. * Subtracts this CSG with another CSG in place
  124568. * @param csg The CSG to subtact against this CSG
  124569. */
  124570. subtractInPlace(csg: CSG): void;
  124571. /**
  124572. * Intersect this CSG with another CSG
  124573. * @param csg The CSG to intersect against this CSG
  124574. * @returns A new CSG
  124575. */
  124576. intersect(csg: CSG): CSG;
  124577. /**
  124578. * Intersects this CSG with another CSG in place
  124579. * @param csg The CSG to intersect against this CSG
  124580. */
  124581. intersectInPlace(csg: CSG): void;
  124582. /**
  124583. * Return a new CSG solid with solid and empty space switched. This solid is
  124584. * not modified.
  124585. * @returns A new CSG solid with solid and empty space switched
  124586. */
  124587. inverse(): CSG;
  124588. /**
  124589. * Inverses the CSG in place
  124590. */
  124591. inverseInPlace(): void;
  124592. /**
  124593. * This is used to keep meshes transformations so they can be restored
  124594. * when we build back a Babylon Mesh
  124595. * NB : All CSG operations are performed in world coordinates
  124596. * @param csg The CSG to copy the transform attributes from
  124597. * @returns This CSG
  124598. */
  124599. copyTransformAttributes(csg: CSG): CSG;
  124600. /**
  124601. * Build Raw mesh from CSG
  124602. * Coordinates here are in world space
  124603. * @param name The name of the mesh geometry
  124604. * @param scene The Scene
  124605. * @param keepSubMeshes Specifies if the submeshes should be kept
  124606. * @returns A new Mesh
  124607. */
  124608. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124609. /**
  124610. * Build Mesh from CSG taking material and transforms into account
  124611. * @param name The name of the Mesh
  124612. * @param material The material of the Mesh
  124613. * @param scene The Scene
  124614. * @param keepSubMeshes Specifies if submeshes should be kept
  124615. * @returns The new Mesh
  124616. */
  124617. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124618. }
  124619. }
  124620. declare module BABYLON {
  124621. /**
  124622. * Class used to create a trail following a mesh
  124623. */
  124624. export class TrailMesh extends Mesh {
  124625. private _generator;
  124626. private _autoStart;
  124627. private _running;
  124628. private _diameter;
  124629. private _length;
  124630. private _sectionPolygonPointsCount;
  124631. private _sectionVectors;
  124632. private _sectionNormalVectors;
  124633. private _beforeRenderObserver;
  124634. /**
  124635. * @constructor
  124636. * @param name The value used by scene.getMeshByName() to do a lookup.
  124637. * @param generator The mesh to generate a trail.
  124638. * @param scene The scene to add this mesh to.
  124639. * @param diameter Diameter of trailing mesh. Default is 1.
  124640. * @param length Length of trailing mesh. Default is 60.
  124641. * @param autoStart Automatically start trailing mesh. Default true.
  124642. */
  124643. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  124644. /**
  124645. * "TrailMesh"
  124646. * @returns "TrailMesh"
  124647. */
  124648. getClassName(): string;
  124649. private _createMesh;
  124650. /**
  124651. * Start trailing mesh.
  124652. */
  124653. start(): void;
  124654. /**
  124655. * Stop trailing mesh.
  124656. */
  124657. stop(): void;
  124658. /**
  124659. * Update trailing mesh geometry.
  124660. */
  124661. update(): void;
  124662. /**
  124663. * Returns a new TrailMesh object.
  124664. * @param name is a string, the name given to the new mesh
  124665. * @param newGenerator use new generator object for cloned trail mesh
  124666. * @returns a new mesh
  124667. */
  124668. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  124669. /**
  124670. * Serializes this trail mesh
  124671. * @param serializationObject object to write serialization to
  124672. */
  124673. serialize(serializationObject: any): void;
  124674. /**
  124675. * Parses a serialized trail mesh
  124676. * @param parsedMesh the serialized mesh
  124677. * @param scene the scene to create the trail mesh in
  124678. * @returns the created trail mesh
  124679. */
  124680. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  124681. }
  124682. }
  124683. declare module BABYLON {
  124684. /**
  124685. * Class containing static functions to help procedurally build meshes
  124686. */
  124687. export class TiledBoxBuilder {
  124688. /**
  124689. * Creates a box mesh
  124690. * 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)
  124691. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124695. * @param name defines the name of the mesh
  124696. * @param options defines the options used to create the mesh
  124697. * @param scene defines the hosting scene
  124698. * @returns the box mesh
  124699. */
  124700. static CreateTiledBox(name: string, options: {
  124701. pattern?: number;
  124702. width?: number;
  124703. height?: number;
  124704. depth?: number;
  124705. tileSize?: number;
  124706. tileWidth?: number;
  124707. tileHeight?: number;
  124708. alignHorizontal?: number;
  124709. alignVertical?: number;
  124710. faceUV?: Vector4[];
  124711. faceColors?: Color4[];
  124712. sideOrientation?: number;
  124713. updatable?: boolean;
  124714. }, scene?: Nullable<Scene>): Mesh;
  124715. }
  124716. }
  124717. declare module BABYLON {
  124718. /**
  124719. * Class containing static functions to help procedurally build meshes
  124720. */
  124721. export class TorusKnotBuilder {
  124722. /**
  124723. * Creates a torus knot mesh
  124724. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124725. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124726. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124727. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124731. * @param name defines the name of the mesh
  124732. * @param options defines the options used to create the mesh
  124733. * @param scene defines the hosting scene
  124734. * @returns the torus knot mesh
  124735. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124736. */
  124737. static CreateTorusKnot(name: string, options: {
  124738. radius?: number;
  124739. tube?: number;
  124740. radialSegments?: number;
  124741. tubularSegments?: number;
  124742. p?: number;
  124743. q?: number;
  124744. updatable?: boolean;
  124745. sideOrientation?: number;
  124746. frontUVs?: Vector4;
  124747. backUVs?: Vector4;
  124748. }, scene: any): Mesh;
  124749. }
  124750. }
  124751. declare module BABYLON {
  124752. /**
  124753. * Polygon
  124754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  124755. */
  124756. export class Polygon {
  124757. /**
  124758. * Creates a rectangle
  124759. * @param xmin bottom X coord
  124760. * @param ymin bottom Y coord
  124761. * @param xmax top X coord
  124762. * @param ymax top Y coord
  124763. * @returns points that make the resulting rectation
  124764. */
  124765. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  124766. /**
  124767. * Creates a circle
  124768. * @param radius radius of circle
  124769. * @param cx scale in x
  124770. * @param cy scale in y
  124771. * @param numberOfSides number of sides that make up the circle
  124772. * @returns points that make the resulting circle
  124773. */
  124774. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  124775. /**
  124776. * Creates a polygon from input string
  124777. * @param input Input polygon data
  124778. * @returns the parsed points
  124779. */
  124780. static Parse(input: string): Vector2[];
  124781. /**
  124782. * Starts building a polygon from x and y coordinates
  124783. * @param x x coordinate
  124784. * @param y y coordinate
  124785. * @returns the started path2
  124786. */
  124787. static StartingAt(x: number, y: number): Path2;
  124788. }
  124789. /**
  124790. * Builds a polygon
  124791. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  124792. */
  124793. export class PolygonMeshBuilder {
  124794. private _points;
  124795. private _outlinepoints;
  124796. private _holes;
  124797. private _name;
  124798. private _scene;
  124799. private _epoints;
  124800. private _eholes;
  124801. private _addToepoint;
  124802. /**
  124803. * Babylon reference to the earcut plugin.
  124804. */
  124805. bjsEarcut: any;
  124806. /**
  124807. * Creates a PolygonMeshBuilder
  124808. * @param name name of the builder
  124809. * @param contours Path of the polygon
  124810. * @param scene scene to add to when creating the mesh
  124811. * @param earcutInjection can be used to inject your own earcut reference
  124812. */
  124813. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  124814. /**
  124815. * Adds a whole within the polygon
  124816. * @param hole Array of points defining the hole
  124817. * @returns this
  124818. */
  124819. addHole(hole: Vector2[]): PolygonMeshBuilder;
  124820. /**
  124821. * Creates the polygon
  124822. * @param updatable If the mesh should be updatable
  124823. * @param depth The depth of the mesh created
  124824. * @returns the created mesh
  124825. */
  124826. build(updatable?: boolean, depth?: number): Mesh;
  124827. /**
  124828. * Creates the polygon
  124829. * @param depth The depth of the mesh created
  124830. * @returns the created VertexData
  124831. */
  124832. buildVertexData(depth?: number): VertexData;
  124833. /**
  124834. * Adds a side to the polygon
  124835. * @param positions points that make the polygon
  124836. * @param normals normals of the polygon
  124837. * @param uvs uvs of the polygon
  124838. * @param indices indices of the polygon
  124839. * @param bounds bounds of the polygon
  124840. * @param points points of the polygon
  124841. * @param depth depth of the polygon
  124842. * @param flip flip of the polygon
  124843. */
  124844. private addSide;
  124845. }
  124846. }
  124847. declare module BABYLON {
  124848. /**
  124849. * Class containing static functions to help procedurally build meshes
  124850. */
  124851. export class PolygonBuilder {
  124852. /**
  124853. * Creates a polygon mesh
  124854. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124855. * * 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
  124856. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124859. * * Remember you can only change the shape positions, not their number when updating a polygon
  124860. * @param name defines the name of the mesh
  124861. * @param options defines the options used to create the mesh
  124862. * @param scene defines the hosting scene
  124863. * @param earcutInjection can be used to inject your own earcut reference
  124864. * @returns the polygon mesh
  124865. */
  124866. static CreatePolygon(name: string, options: {
  124867. shape: Vector3[];
  124868. holes?: Vector3[][];
  124869. depth?: number;
  124870. faceUV?: Vector4[];
  124871. faceColors?: Color4[];
  124872. updatable?: boolean;
  124873. sideOrientation?: number;
  124874. frontUVs?: Vector4;
  124875. backUVs?: Vector4;
  124876. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124877. /**
  124878. * Creates an extruded polygon mesh, with depth in the Y direction.
  124879. * * 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)
  124880. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124881. * @param name defines the name of the mesh
  124882. * @param options defines the options used to create the mesh
  124883. * @param scene defines the hosting scene
  124884. * @param earcutInjection can be used to inject your own earcut reference
  124885. * @returns the polygon mesh
  124886. */
  124887. static ExtrudePolygon(name: string, options: {
  124888. shape: Vector3[];
  124889. holes?: Vector3[][];
  124890. depth?: number;
  124891. faceUV?: Vector4[];
  124892. faceColors?: Color4[];
  124893. updatable?: boolean;
  124894. sideOrientation?: number;
  124895. frontUVs?: Vector4;
  124896. backUVs?: Vector4;
  124897. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124898. }
  124899. }
  124900. declare module BABYLON {
  124901. /**
  124902. * Class containing static functions to help procedurally build meshes
  124903. */
  124904. export class LatheBuilder {
  124905. /**
  124906. * Creates lathe mesh.
  124907. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124908. * * 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
  124909. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124910. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124911. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124912. * * 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
  124913. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124914. * * 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
  124915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124919. * @param name defines the name of the mesh
  124920. * @param options defines the options used to create the mesh
  124921. * @param scene defines the hosting scene
  124922. * @returns the lathe mesh
  124923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124924. */
  124925. static CreateLathe(name: string, options: {
  124926. shape: Vector3[];
  124927. radius?: number;
  124928. tessellation?: number;
  124929. clip?: number;
  124930. arc?: number;
  124931. closed?: boolean;
  124932. updatable?: boolean;
  124933. sideOrientation?: number;
  124934. frontUVs?: Vector4;
  124935. backUVs?: Vector4;
  124936. cap?: number;
  124937. invertUV?: boolean;
  124938. }, scene?: Nullable<Scene>): Mesh;
  124939. }
  124940. }
  124941. declare module BABYLON {
  124942. /**
  124943. * Class containing static functions to help procedurally build meshes
  124944. */
  124945. export class TiledPlaneBuilder {
  124946. /**
  124947. * Creates a tiled plane mesh
  124948. * * The parameter `pattern` will, depending on value, do nothing or
  124949. * * * flip (reflect about central vertical) alternate tiles across and up
  124950. * * * flip every tile on alternate rows
  124951. * * * rotate (180 degs) alternate tiles across and up
  124952. * * * rotate every tile on alternate rows
  124953. * * * flip and rotate alternate tiles across and up
  124954. * * * flip and rotate every tile on alternate rows
  124955. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  124956. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  124957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124959. * * 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)
  124960. * * 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)
  124961. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124962. * @param name defines the name of the mesh
  124963. * @param options defines the options used to create the mesh
  124964. * @param scene defines the hosting scene
  124965. * @returns the box mesh
  124966. */
  124967. static CreateTiledPlane(name: string, options: {
  124968. pattern?: number;
  124969. tileSize?: number;
  124970. tileWidth?: number;
  124971. tileHeight?: number;
  124972. size?: number;
  124973. width?: number;
  124974. height?: number;
  124975. alignHorizontal?: number;
  124976. alignVertical?: number;
  124977. sideOrientation?: number;
  124978. frontUVs?: Vector4;
  124979. backUVs?: Vector4;
  124980. updatable?: 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 TubeBuilder {
  124989. /**
  124990. * Creates a tube mesh.
  124991. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124992. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124993. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124994. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124995. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124996. * * 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)
  124997. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124998. * * 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
  124999. * * 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
  125000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125004. * @param name defines the name of the mesh
  125005. * @param options defines the options used to create the mesh
  125006. * @param scene defines the hosting scene
  125007. * @returns the tube mesh
  125008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125009. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125010. */
  125011. static CreateTube(name: string, options: {
  125012. path: Vector3[];
  125013. radius?: number;
  125014. tessellation?: number;
  125015. radiusFunction?: {
  125016. (i: number, distance: number): number;
  125017. };
  125018. cap?: number;
  125019. arc?: number;
  125020. updatable?: boolean;
  125021. sideOrientation?: number;
  125022. frontUVs?: Vector4;
  125023. backUVs?: Vector4;
  125024. instance?: Mesh;
  125025. invertUV?: boolean;
  125026. }, scene?: Nullable<Scene>): Mesh;
  125027. }
  125028. }
  125029. declare module BABYLON {
  125030. /**
  125031. * Class containing static functions to help procedurally build meshes
  125032. */
  125033. export class IcoSphereBuilder {
  125034. /**
  125035. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125036. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125037. * * 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`)
  125038. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125039. * * 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
  125040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125043. * @param name defines the name of the mesh
  125044. * @param options defines the options used to create the mesh
  125045. * @param scene defines the hosting scene
  125046. * @returns the icosahedron mesh
  125047. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125048. */
  125049. static CreateIcoSphere(name: string, options: {
  125050. radius?: number;
  125051. radiusX?: number;
  125052. radiusY?: number;
  125053. radiusZ?: number;
  125054. flat?: boolean;
  125055. subdivisions?: number;
  125056. sideOrientation?: number;
  125057. frontUVs?: Vector4;
  125058. backUVs?: Vector4;
  125059. updatable?: boolean;
  125060. }, scene?: Nullable<Scene>): Mesh;
  125061. }
  125062. }
  125063. declare module BABYLON {
  125064. /**
  125065. * Class containing static functions to help procedurally build meshes
  125066. */
  125067. export class DecalBuilder {
  125068. /**
  125069. * Creates a decal mesh.
  125070. * 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
  125071. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125072. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125073. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125074. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125075. * @param name defines the name of the mesh
  125076. * @param sourceMesh defines the mesh where the decal must be applied
  125077. * @param options defines the options used to create the mesh
  125078. * @param scene defines the hosting scene
  125079. * @returns the decal mesh
  125080. * @see https://doc.babylonjs.com/how_to/decals
  125081. */
  125082. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125083. position?: Vector3;
  125084. normal?: Vector3;
  125085. size?: Vector3;
  125086. angle?: number;
  125087. }): Mesh;
  125088. }
  125089. }
  125090. declare module BABYLON {
  125091. /**
  125092. * Class containing static functions to help procedurally build meshes
  125093. */
  125094. export class MeshBuilder {
  125095. /**
  125096. * Creates a box mesh
  125097. * * The parameter `size` sets the size (float) of each box side (default 1)
  125098. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125099. * * 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)
  125100. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125104. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125105. * @param name defines the name of the mesh
  125106. * @param options defines the options used to create the mesh
  125107. * @param scene defines the hosting scene
  125108. * @returns the box mesh
  125109. */
  125110. static CreateBox(name: string, options: {
  125111. size?: number;
  125112. width?: number;
  125113. height?: number;
  125114. depth?: number;
  125115. faceUV?: Vector4[];
  125116. faceColors?: Color4[];
  125117. sideOrientation?: number;
  125118. frontUVs?: Vector4;
  125119. backUVs?: Vector4;
  125120. updatable?: boolean;
  125121. }, scene?: Nullable<Scene>): Mesh;
  125122. /**
  125123. * Creates a tiled box mesh
  125124. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125126. * @param name defines the name of the mesh
  125127. * @param options defines the options used to create the mesh
  125128. * @param scene defines the hosting scene
  125129. * @returns the tiled box mesh
  125130. */
  125131. static CreateTiledBox(name: string, options: {
  125132. pattern?: number;
  125133. size?: number;
  125134. width?: number;
  125135. height?: number;
  125136. depth: number;
  125137. tileSize?: number;
  125138. tileWidth?: number;
  125139. tileHeight?: number;
  125140. faceUV?: Vector4[];
  125141. faceColors?: Color4[];
  125142. alignHorizontal?: number;
  125143. alignVertical?: number;
  125144. sideOrientation?: number;
  125145. updatable?: boolean;
  125146. }, scene?: Nullable<Scene>): Mesh;
  125147. /**
  125148. * Creates a sphere mesh
  125149. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125150. * * 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`)
  125151. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125152. * * 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
  125153. * * 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)
  125154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125157. * @param name defines the name of the mesh
  125158. * @param options defines the options used to create the mesh
  125159. * @param scene defines the hosting scene
  125160. * @returns the sphere mesh
  125161. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125162. */
  125163. static CreateSphere(name: string, options: {
  125164. segments?: number;
  125165. diameter?: number;
  125166. diameterX?: number;
  125167. diameterY?: number;
  125168. diameterZ?: number;
  125169. arc?: number;
  125170. slice?: number;
  125171. sideOrientation?: number;
  125172. frontUVs?: Vector4;
  125173. backUVs?: Vector4;
  125174. updatable?: boolean;
  125175. }, scene?: Nullable<Scene>): Mesh;
  125176. /**
  125177. * Creates a plane polygonal mesh. By default, this is a disc
  125178. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125179. * * 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
  125180. * * 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
  125181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125184. * @param name defines the name of the mesh
  125185. * @param options defines the options used to create the mesh
  125186. * @param scene defines the hosting scene
  125187. * @returns the plane polygonal mesh
  125188. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125189. */
  125190. static CreateDisc(name: string, options: {
  125191. radius?: number;
  125192. tessellation?: number;
  125193. arc?: number;
  125194. updatable?: boolean;
  125195. sideOrientation?: number;
  125196. frontUVs?: Vector4;
  125197. backUVs?: Vector4;
  125198. }, scene?: Nullable<Scene>): Mesh;
  125199. /**
  125200. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125201. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125202. * * 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`)
  125203. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125204. * * 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
  125205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125208. * @param name defines the name of the mesh
  125209. * @param options defines the options used to create the mesh
  125210. * @param scene defines the hosting scene
  125211. * @returns the icosahedron mesh
  125212. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125213. */
  125214. static CreateIcoSphere(name: string, options: {
  125215. radius?: number;
  125216. radiusX?: number;
  125217. radiusY?: number;
  125218. radiusZ?: number;
  125219. flat?: boolean;
  125220. subdivisions?: number;
  125221. sideOrientation?: number;
  125222. frontUVs?: Vector4;
  125223. backUVs?: Vector4;
  125224. updatable?: boolean;
  125225. }, scene?: Nullable<Scene>): Mesh;
  125226. /**
  125227. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125228. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125229. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125230. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125231. * * 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
  125232. * * 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
  125233. * * 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
  125234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125237. * * 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
  125238. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125239. * * 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
  125240. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125242. * @param name defines the name of the mesh
  125243. * @param options defines the options used to create the mesh
  125244. * @param scene defines the hosting scene
  125245. * @returns the ribbon mesh
  125246. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125247. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125248. */
  125249. static CreateRibbon(name: string, options: {
  125250. pathArray: Vector3[][];
  125251. closeArray?: boolean;
  125252. closePath?: boolean;
  125253. offset?: number;
  125254. updatable?: boolean;
  125255. sideOrientation?: number;
  125256. frontUVs?: Vector4;
  125257. backUVs?: Vector4;
  125258. instance?: Mesh;
  125259. invertUV?: boolean;
  125260. uvs?: Vector2[];
  125261. colors?: Color4[];
  125262. }, scene?: Nullable<Scene>): Mesh;
  125263. /**
  125264. * Creates a cylinder or a cone mesh
  125265. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125266. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125267. * * 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.
  125268. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125269. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125270. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125271. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125272. * * 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).
  125273. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125274. * * 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).
  125275. * * 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
  125276. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125277. * * 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
  125278. * * 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.
  125279. * * If `enclose` is false, a ring surface is one element.
  125280. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125281. * * 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
  125282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125285. * @param name defines the name of the mesh
  125286. * @param options defines the options used to create the mesh
  125287. * @param scene defines the hosting scene
  125288. * @returns the cylinder mesh
  125289. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125290. */
  125291. static CreateCylinder(name: string, options: {
  125292. height?: number;
  125293. diameterTop?: number;
  125294. diameterBottom?: number;
  125295. diameter?: number;
  125296. tessellation?: number;
  125297. subdivisions?: number;
  125298. arc?: number;
  125299. faceColors?: Color4[];
  125300. faceUV?: Vector4[];
  125301. updatable?: boolean;
  125302. hasRings?: boolean;
  125303. enclose?: boolean;
  125304. cap?: number;
  125305. sideOrientation?: number;
  125306. frontUVs?: Vector4;
  125307. backUVs?: Vector4;
  125308. }, scene?: Nullable<Scene>): Mesh;
  125309. /**
  125310. * Creates a torus mesh
  125311. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125312. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125313. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125317. * @param name defines the name of the mesh
  125318. * @param options defines the options used to create the mesh
  125319. * @param scene defines the hosting scene
  125320. * @returns the torus mesh
  125321. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125322. */
  125323. static CreateTorus(name: string, options: {
  125324. diameter?: number;
  125325. thickness?: number;
  125326. tessellation?: number;
  125327. updatable?: boolean;
  125328. sideOrientation?: number;
  125329. frontUVs?: Vector4;
  125330. backUVs?: Vector4;
  125331. }, scene?: Nullable<Scene>): Mesh;
  125332. /**
  125333. * Creates a torus knot mesh
  125334. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125335. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125336. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125337. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125341. * @param name defines the name of the mesh
  125342. * @param options defines the options used to create the mesh
  125343. * @param scene defines the hosting scene
  125344. * @returns the torus knot mesh
  125345. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125346. */
  125347. static CreateTorusKnot(name: string, options: {
  125348. radius?: number;
  125349. tube?: number;
  125350. radialSegments?: number;
  125351. tubularSegments?: number;
  125352. p?: number;
  125353. q?: number;
  125354. updatable?: boolean;
  125355. sideOrientation?: number;
  125356. frontUVs?: Vector4;
  125357. backUVs?: Vector4;
  125358. }, scene?: Nullable<Scene>): Mesh;
  125359. /**
  125360. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125361. * * 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
  125362. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125363. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125364. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125365. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125366. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125367. * * 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
  125368. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125371. * @param name defines the name of the new line system
  125372. * @param options defines the options used to create the line system
  125373. * @param scene defines the hosting scene
  125374. * @returns a new line system mesh
  125375. */
  125376. static CreateLineSystem(name: string, options: {
  125377. lines: Vector3[][];
  125378. updatable?: boolean;
  125379. instance?: Nullable<LinesMesh>;
  125380. colors?: Nullable<Color4[][]>;
  125381. useVertexAlpha?: boolean;
  125382. }, scene: Nullable<Scene>): LinesMesh;
  125383. /**
  125384. * Creates a line mesh
  125385. * 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
  125386. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125387. * * The parameter `points` is an array successive Vector3
  125388. * * 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
  125389. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125390. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125391. * * When updating an instance, remember that only point positions can change, not the number of points
  125392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125394. * @param name defines the name of the new line system
  125395. * @param options defines the options used to create the line system
  125396. * @param scene defines the hosting scene
  125397. * @returns a new line mesh
  125398. */
  125399. static CreateLines(name: string, options: {
  125400. points: Vector3[];
  125401. updatable?: boolean;
  125402. instance?: Nullable<LinesMesh>;
  125403. colors?: Color4[];
  125404. useVertexAlpha?: boolean;
  125405. }, scene?: Nullable<Scene>): LinesMesh;
  125406. /**
  125407. * Creates a dashed line mesh
  125408. * * 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
  125409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125410. * * The parameter `points` is an array successive Vector3
  125411. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125412. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125413. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125414. * * 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
  125415. * * When updating an instance, remember that only point positions can change, not the number of points
  125416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125417. * @param name defines the name of the mesh
  125418. * @param options defines the options used to create the mesh
  125419. * @param scene defines the hosting scene
  125420. * @returns the dashed line mesh
  125421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125422. */
  125423. static CreateDashedLines(name: string, options: {
  125424. points: Vector3[];
  125425. dashSize?: number;
  125426. gapSize?: number;
  125427. dashNb?: number;
  125428. updatable?: boolean;
  125429. instance?: LinesMesh;
  125430. }, scene?: Nullable<Scene>): LinesMesh;
  125431. /**
  125432. * 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.
  125433. * * 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.
  125434. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125435. * * 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.
  125436. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125437. * * 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
  125438. * * 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
  125439. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125444. * @param name defines the name of the mesh
  125445. * @param options defines the options used to create the mesh
  125446. * @param scene defines the hosting scene
  125447. * @returns the extruded shape mesh
  125448. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125450. */
  125451. static ExtrudeShape(name: string, options: {
  125452. shape: Vector3[];
  125453. path: Vector3[];
  125454. scale?: number;
  125455. rotation?: number;
  125456. cap?: number;
  125457. updatable?: boolean;
  125458. sideOrientation?: number;
  125459. frontUVs?: Vector4;
  125460. backUVs?: Vector4;
  125461. instance?: Mesh;
  125462. invertUV?: boolean;
  125463. }, scene?: Nullable<Scene>): Mesh;
  125464. /**
  125465. * Creates an custom extruded shape mesh.
  125466. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125467. * * 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.
  125468. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125469. * * 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
  125470. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125471. * * 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
  125472. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125473. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125474. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125475. * * 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
  125476. * * 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
  125477. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125480. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125482. * @param name defines the name of the mesh
  125483. * @param options defines the options used to create the mesh
  125484. * @param scene defines the hosting scene
  125485. * @returns the custom extruded shape mesh
  125486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125489. */
  125490. static ExtrudeShapeCustom(name: string, options: {
  125491. shape: Vector3[];
  125492. path: Vector3[];
  125493. scaleFunction?: any;
  125494. rotationFunction?: any;
  125495. ribbonCloseArray?: boolean;
  125496. ribbonClosePath?: boolean;
  125497. cap?: number;
  125498. updatable?: boolean;
  125499. sideOrientation?: number;
  125500. frontUVs?: Vector4;
  125501. backUVs?: Vector4;
  125502. instance?: Mesh;
  125503. invertUV?: boolean;
  125504. }, scene?: Nullable<Scene>): Mesh;
  125505. /**
  125506. * Creates lathe mesh.
  125507. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125508. * * 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
  125509. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125510. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125511. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125512. * * 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
  125513. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125514. * * 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
  125515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125517. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125519. * @param name defines the name of the mesh
  125520. * @param options defines the options used to create the mesh
  125521. * @param scene defines the hosting scene
  125522. * @returns the lathe mesh
  125523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125524. */
  125525. static CreateLathe(name: string, options: {
  125526. shape: Vector3[];
  125527. radius?: number;
  125528. tessellation?: number;
  125529. clip?: number;
  125530. arc?: number;
  125531. closed?: boolean;
  125532. updatable?: boolean;
  125533. sideOrientation?: number;
  125534. frontUVs?: Vector4;
  125535. backUVs?: Vector4;
  125536. cap?: number;
  125537. invertUV?: boolean;
  125538. }, scene?: Nullable<Scene>): Mesh;
  125539. /**
  125540. * Creates a tiled plane mesh
  125541. * * You can set a limited pattern arrangement with the tiles
  125542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125545. * @param name defines the name of the mesh
  125546. * @param options defines the options used to create the mesh
  125547. * @param scene defines the hosting scene
  125548. * @returns the plane mesh
  125549. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125550. */
  125551. static CreateTiledPlane(name: string, options: {
  125552. pattern?: number;
  125553. tileSize?: number;
  125554. tileWidth?: number;
  125555. tileHeight?: number;
  125556. size?: number;
  125557. width?: number;
  125558. height?: number;
  125559. alignHorizontal?: number;
  125560. alignVertical?: number;
  125561. sideOrientation?: number;
  125562. frontUVs?: Vector4;
  125563. backUVs?: Vector4;
  125564. updatable?: boolean;
  125565. }, scene?: Nullable<Scene>): Mesh;
  125566. /**
  125567. * Creates a plane mesh
  125568. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125569. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125570. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125574. * @param name defines the name of the mesh
  125575. * @param options defines the options used to create the mesh
  125576. * @param scene defines the hosting scene
  125577. * @returns the plane mesh
  125578. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125579. */
  125580. static CreatePlane(name: string, options: {
  125581. size?: number;
  125582. width?: number;
  125583. height?: number;
  125584. sideOrientation?: number;
  125585. frontUVs?: Vector4;
  125586. backUVs?: Vector4;
  125587. updatable?: boolean;
  125588. sourcePlane?: Plane;
  125589. }, scene?: Nullable<Scene>): Mesh;
  125590. /**
  125591. * Creates a ground mesh
  125592. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125593. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125595. * @param name defines the name of the mesh
  125596. * @param options defines the options used to create the mesh
  125597. * @param scene defines the hosting scene
  125598. * @returns the ground mesh
  125599. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125600. */
  125601. static CreateGround(name: string, options: {
  125602. width?: number;
  125603. height?: number;
  125604. subdivisions?: number;
  125605. subdivisionsX?: number;
  125606. subdivisionsY?: number;
  125607. updatable?: boolean;
  125608. }, scene?: Nullable<Scene>): Mesh;
  125609. /**
  125610. * Creates a tiled ground mesh
  125611. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125612. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125613. * * 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
  125614. * * 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
  125615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125616. * @param name defines the name of the mesh
  125617. * @param options defines the options used to create the mesh
  125618. * @param scene defines the hosting scene
  125619. * @returns the tiled ground mesh
  125620. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125621. */
  125622. static CreateTiledGround(name: string, options: {
  125623. xmin: number;
  125624. zmin: number;
  125625. xmax: number;
  125626. zmax: number;
  125627. subdivisions?: {
  125628. w: number;
  125629. h: number;
  125630. };
  125631. precision?: {
  125632. w: number;
  125633. h: number;
  125634. };
  125635. updatable?: boolean;
  125636. }, scene?: Nullable<Scene>): Mesh;
  125637. /**
  125638. * Creates a ground mesh from a height map
  125639. * * The parameter `url` sets the URL of the height map image resource.
  125640. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125641. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125642. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125643. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125644. * * 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.
  125645. * * 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).
  125646. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125648. * @param name defines the name of the mesh
  125649. * @param url defines the url to the height map
  125650. * @param options defines the options used to create the mesh
  125651. * @param scene defines the hosting scene
  125652. * @returns the ground mesh
  125653. * @see https://doc.babylonjs.com/babylon101/height_map
  125654. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125655. */
  125656. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125657. width?: number;
  125658. height?: number;
  125659. subdivisions?: number;
  125660. minHeight?: number;
  125661. maxHeight?: number;
  125662. colorFilter?: Color3;
  125663. alphaFilter?: number;
  125664. updatable?: boolean;
  125665. onReady?: (mesh: GroundMesh) => void;
  125666. }, scene?: Nullable<Scene>): GroundMesh;
  125667. /**
  125668. * Creates a polygon mesh
  125669. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125670. * * 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
  125671. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125674. * * Remember you can only change the shape positions, not their number when updating a polygon
  125675. * @param name defines the name of the mesh
  125676. * @param options defines the options used to create the mesh
  125677. * @param scene defines the hosting scene
  125678. * @param earcutInjection can be used to inject your own earcut reference
  125679. * @returns the polygon mesh
  125680. */
  125681. static CreatePolygon(name: string, options: {
  125682. shape: Vector3[];
  125683. holes?: Vector3[][];
  125684. depth?: number;
  125685. faceUV?: Vector4[];
  125686. faceColors?: Color4[];
  125687. updatable?: boolean;
  125688. sideOrientation?: number;
  125689. frontUVs?: Vector4;
  125690. backUVs?: Vector4;
  125691. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125692. /**
  125693. * Creates an extruded polygon mesh, with depth in the Y direction.
  125694. * * 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)
  125695. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125696. * @param name defines the name of the mesh
  125697. * @param options defines the options used to create the mesh
  125698. * @param scene defines the hosting scene
  125699. * @param earcutInjection can be used to inject your own earcut reference
  125700. * @returns the polygon mesh
  125701. */
  125702. static ExtrudePolygon(name: string, options: {
  125703. shape: Vector3[];
  125704. holes?: Vector3[][];
  125705. depth?: number;
  125706. faceUV?: Vector4[];
  125707. faceColors?: Color4[];
  125708. updatable?: boolean;
  125709. sideOrientation?: number;
  125710. frontUVs?: Vector4;
  125711. backUVs?: Vector4;
  125712. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125713. /**
  125714. * Creates a tube mesh.
  125715. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125716. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125717. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125718. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125719. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125720. * * 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)
  125721. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125722. * * 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
  125723. * * 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
  125724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125728. * @param name defines the name of the mesh
  125729. * @param options defines the options used to create the mesh
  125730. * @param scene defines the hosting scene
  125731. * @returns the tube mesh
  125732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125733. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125734. */
  125735. static CreateTube(name: string, options: {
  125736. path: Vector3[];
  125737. radius?: number;
  125738. tessellation?: number;
  125739. radiusFunction?: {
  125740. (i: number, distance: number): number;
  125741. };
  125742. cap?: number;
  125743. arc?: number;
  125744. updatable?: boolean;
  125745. sideOrientation?: number;
  125746. frontUVs?: Vector4;
  125747. backUVs?: Vector4;
  125748. instance?: Mesh;
  125749. invertUV?: boolean;
  125750. }, scene?: Nullable<Scene>): Mesh;
  125751. /**
  125752. * Creates a polyhedron mesh
  125753. * * 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
  125754. * * The parameter `size` (positive float, default 1) sets the polygon size
  125755. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125756. * * 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`
  125757. * * 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
  125758. * * 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)`)
  125759. * * 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
  125760. * * 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
  125761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125764. * @param name defines the name of the mesh
  125765. * @param options defines the options used to create the mesh
  125766. * @param scene defines the hosting scene
  125767. * @returns the polyhedron mesh
  125768. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125769. */
  125770. static CreatePolyhedron(name: string, options: {
  125771. type?: number;
  125772. size?: number;
  125773. sizeX?: number;
  125774. sizeY?: number;
  125775. sizeZ?: number;
  125776. custom?: any;
  125777. faceUV?: Vector4[];
  125778. faceColors?: Color4[];
  125779. flat?: boolean;
  125780. updatable?: boolean;
  125781. sideOrientation?: number;
  125782. frontUVs?: Vector4;
  125783. backUVs?: Vector4;
  125784. }, scene?: Nullable<Scene>): Mesh;
  125785. /**
  125786. * Creates a decal mesh.
  125787. * 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
  125788. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125789. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125790. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125791. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125792. * @param name defines the name of the mesh
  125793. * @param sourceMesh defines the mesh where the decal must be applied
  125794. * @param options defines the options used to create the mesh
  125795. * @param scene defines the hosting scene
  125796. * @returns the decal mesh
  125797. * @see https://doc.babylonjs.com/how_to/decals
  125798. */
  125799. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125800. position?: Vector3;
  125801. normal?: Vector3;
  125802. size?: Vector3;
  125803. angle?: number;
  125804. }): Mesh;
  125805. }
  125806. }
  125807. declare module BABYLON {
  125808. /**
  125809. * A simplifier interface for future simplification implementations
  125810. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125811. */
  125812. export interface ISimplifier {
  125813. /**
  125814. * Simplification of a given mesh according to the given settings.
  125815. * Since this requires computation, it is assumed that the function runs async.
  125816. * @param settings The settings of the simplification, including quality and distance
  125817. * @param successCallback A callback that will be called after the mesh was simplified.
  125818. * @param errorCallback in case of an error, this callback will be called. optional.
  125819. */
  125820. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  125821. }
  125822. /**
  125823. * Expected simplification settings.
  125824. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  125825. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125826. */
  125827. export interface ISimplificationSettings {
  125828. /**
  125829. * Gets or sets the expected quality
  125830. */
  125831. quality: number;
  125832. /**
  125833. * Gets or sets the distance when this optimized version should be used
  125834. */
  125835. distance: number;
  125836. /**
  125837. * Gets an already optimized mesh
  125838. */
  125839. optimizeMesh?: boolean;
  125840. }
  125841. /**
  125842. * Class used to specify simplification options
  125843. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125844. */
  125845. export class SimplificationSettings implements ISimplificationSettings {
  125846. /** expected quality */
  125847. quality: number;
  125848. /** distance when this optimized version should be used */
  125849. distance: number;
  125850. /** already optimized mesh */
  125851. optimizeMesh?: boolean | undefined;
  125852. /**
  125853. * Creates a SimplificationSettings
  125854. * @param quality expected quality
  125855. * @param distance distance when this optimized version should be used
  125856. * @param optimizeMesh already optimized mesh
  125857. */
  125858. constructor(
  125859. /** expected quality */
  125860. quality: number,
  125861. /** distance when this optimized version should be used */
  125862. distance: number,
  125863. /** already optimized mesh */
  125864. optimizeMesh?: boolean | undefined);
  125865. }
  125866. /**
  125867. * Interface used to define a simplification task
  125868. */
  125869. export interface ISimplificationTask {
  125870. /**
  125871. * Array of settings
  125872. */
  125873. settings: Array<ISimplificationSettings>;
  125874. /**
  125875. * Simplification type
  125876. */
  125877. simplificationType: SimplificationType;
  125878. /**
  125879. * Mesh to simplify
  125880. */
  125881. mesh: Mesh;
  125882. /**
  125883. * Callback called on success
  125884. */
  125885. successCallback?: () => void;
  125886. /**
  125887. * Defines if parallel processing can be used
  125888. */
  125889. parallelProcessing: boolean;
  125890. }
  125891. /**
  125892. * Queue used to order the simplification tasks
  125893. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125894. */
  125895. export class SimplificationQueue {
  125896. private _simplificationArray;
  125897. /**
  125898. * Gets a boolean indicating that the process is still running
  125899. */
  125900. running: boolean;
  125901. /**
  125902. * Creates a new queue
  125903. */
  125904. constructor();
  125905. /**
  125906. * Adds a new simplification task
  125907. * @param task defines a task to add
  125908. */
  125909. addTask(task: ISimplificationTask): void;
  125910. /**
  125911. * Execute next task
  125912. */
  125913. executeNext(): void;
  125914. /**
  125915. * Execute a simplification task
  125916. * @param task defines the task to run
  125917. */
  125918. runSimplification(task: ISimplificationTask): void;
  125919. private getSimplifier;
  125920. }
  125921. /**
  125922. * The implemented types of simplification
  125923. * At the moment only Quadratic Error Decimation is implemented
  125924. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125925. */
  125926. export enum SimplificationType {
  125927. /** Quadratic error decimation */
  125928. QUADRATIC = 0
  125929. }
  125930. }
  125931. declare module BABYLON {
  125932. interface Scene {
  125933. /** @hidden (Backing field) */
  125934. _simplificationQueue: SimplificationQueue;
  125935. /**
  125936. * Gets or sets the simplification queue attached to the scene
  125937. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125938. */
  125939. simplificationQueue: SimplificationQueue;
  125940. }
  125941. interface Mesh {
  125942. /**
  125943. * Simplify the mesh according to the given array of settings.
  125944. * Function will return immediately and will simplify async
  125945. * @param settings a collection of simplification settings
  125946. * @param parallelProcessing should all levels calculate parallel or one after the other
  125947. * @param simplificationType the type of simplification to run
  125948. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  125949. * @returns the current mesh
  125950. */
  125951. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  125952. }
  125953. /**
  125954. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  125955. * created in a scene
  125956. */
  125957. export class SimplicationQueueSceneComponent implements ISceneComponent {
  125958. /**
  125959. * The component name helpfull to identify the component in the list of scene components.
  125960. */
  125961. readonly name: string;
  125962. /**
  125963. * The scene the component belongs to.
  125964. */
  125965. scene: Scene;
  125966. /**
  125967. * Creates a new instance of the component for the given scene
  125968. * @param scene Defines the scene to register the component in
  125969. */
  125970. constructor(scene: Scene);
  125971. /**
  125972. * Registers the component in a given scene
  125973. */
  125974. register(): void;
  125975. /**
  125976. * Rebuilds the elements related to this component in case of
  125977. * context lost for instance.
  125978. */
  125979. rebuild(): void;
  125980. /**
  125981. * Disposes the component and the associated ressources
  125982. */
  125983. dispose(): void;
  125984. private _beforeCameraUpdate;
  125985. }
  125986. }
  125987. declare module BABYLON {
  125988. /**
  125989. * Navigation plugin interface to add navigation constrained by a navigation mesh
  125990. */
  125991. export interface INavigationEnginePlugin {
  125992. /**
  125993. * plugin name
  125994. */
  125995. name: string;
  125996. /**
  125997. * Creates a navigation mesh
  125998. * @param meshes array of all the geometry used to compute the navigatio mesh
  125999. * @param parameters bunch of parameters used to filter geometry
  126000. */
  126001. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126002. /**
  126003. * Create a navigation mesh debug mesh
  126004. * @param scene is where the mesh will be added
  126005. * @returns debug display mesh
  126006. */
  126007. createDebugNavMesh(scene: Scene): Mesh;
  126008. /**
  126009. * Get a navigation mesh constrained position, closest to the parameter position
  126010. * @param position world position
  126011. * @returns the closest point to position constrained by the navigation mesh
  126012. */
  126013. getClosestPoint(position: Vector3): Vector3;
  126014. /**
  126015. * Get a navigation mesh constrained position, within a particular radius
  126016. * @param position world position
  126017. * @param maxRadius the maximum distance to the constrained world position
  126018. * @returns the closest point to position constrained by the navigation mesh
  126019. */
  126020. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126021. /**
  126022. * Compute the final position from a segment made of destination-position
  126023. * @param position world position
  126024. * @param destination world position
  126025. * @returns the resulting point along the navmesh
  126026. */
  126027. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126028. /**
  126029. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126030. * @param start world position
  126031. * @param end world position
  126032. * @returns array containing world position composing the path
  126033. */
  126034. computePath(start: Vector3, end: Vector3): Vector3[];
  126035. /**
  126036. * If this plugin is supported
  126037. * @returns true if plugin is supported
  126038. */
  126039. isSupported(): boolean;
  126040. /**
  126041. * Create a new Crowd so you can add agents
  126042. * @param maxAgents the maximum agent count in the crowd
  126043. * @param maxAgentRadius the maximum radius an agent can have
  126044. * @param scene to attach the crowd to
  126045. * @returns the crowd you can add agents to
  126046. */
  126047. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126048. /**
  126049. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126050. * The queries will try to find a solution within those bounds
  126051. * default is (1,1,1)
  126052. * @param extent x,y,z value that define the extent around the queries point of reference
  126053. */
  126054. setDefaultQueryExtent(extent: Vector3): void;
  126055. /**
  126056. * Get the Bounding box extent specified by setDefaultQueryExtent
  126057. * @returns the box extent values
  126058. */
  126059. getDefaultQueryExtent(): Vector3;
  126060. /**
  126061. * Release all resources
  126062. */
  126063. dispose(): void;
  126064. }
  126065. /**
  126066. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126067. */
  126068. export interface ICrowd {
  126069. /**
  126070. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126071. * You can attach anything to that node. The node position is updated in the scene update tick.
  126072. * @param pos world position that will be constrained by the navigation mesh
  126073. * @param parameters agent parameters
  126074. * @param transform hooked to the agent that will be update by the scene
  126075. * @returns agent index
  126076. */
  126077. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126078. /**
  126079. * Returns the agent position in world space
  126080. * @param index agent index returned by addAgent
  126081. * @returns world space position
  126082. */
  126083. getAgentPosition(index: number): Vector3;
  126084. /**
  126085. * Gets the agent velocity in world space
  126086. * @param index agent index returned by addAgent
  126087. * @returns world space velocity
  126088. */
  126089. getAgentVelocity(index: number): Vector3;
  126090. /**
  126091. * remove a particular agent previously created
  126092. * @param index agent index returned by addAgent
  126093. */
  126094. removeAgent(index: number): void;
  126095. /**
  126096. * get the list of all agents attached to this crowd
  126097. * @returns list of agent indices
  126098. */
  126099. getAgents(): number[];
  126100. /**
  126101. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126102. * @param deltaTime in seconds
  126103. */
  126104. update(deltaTime: number): void;
  126105. /**
  126106. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126107. * @param index agent index returned by addAgent
  126108. * @param destination targeted world position
  126109. */
  126110. agentGoto(index: number, destination: Vector3): void;
  126111. /**
  126112. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126113. * The queries will try to find a solution within those bounds
  126114. * default is (1,1,1)
  126115. * @param extent x,y,z value that define the extent around the queries point of reference
  126116. */
  126117. setDefaultQueryExtent(extent: Vector3): void;
  126118. /**
  126119. * Get the Bounding box extent specified by setDefaultQueryExtent
  126120. * @returns the box extent values
  126121. */
  126122. getDefaultQueryExtent(): Vector3;
  126123. /**
  126124. * Release all resources
  126125. */
  126126. dispose(): void;
  126127. }
  126128. /**
  126129. * Configures an agent
  126130. */
  126131. export interface IAgentParameters {
  126132. /**
  126133. * Agent radius. [Limit: >= 0]
  126134. */
  126135. radius: number;
  126136. /**
  126137. * Agent height. [Limit: > 0]
  126138. */
  126139. height: number;
  126140. /**
  126141. * Maximum allowed acceleration. [Limit: >= 0]
  126142. */
  126143. maxAcceleration: number;
  126144. /**
  126145. * Maximum allowed speed. [Limit: >= 0]
  126146. */
  126147. maxSpeed: number;
  126148. /**
  126149. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126150. */
  126151. collisionQueryRange: number;
  126152. /**
  126153. * The path visibility optimization range. [Limit: > 0]
  126154. */
  126155. pathOptimizationRange: number;
  126156. /**
  126157. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126158. */
  126159. separationWeight: number;
  126160. }
  126161. /**
  126162. * Configures the navigation mesh creation
  126163. */
  126164. export interface INavMeshParameters {
  126165. /**
  126166. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126167. */
  126168. cs: number;
  126169. /**
  126170. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126171. */
  126172. ch: number;
  126173. /**
  126174. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126175. */
  126176. walkableSlopeAngle: number;
  126177. /**
  126178. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126179. * be considered walkable. [Limit: >= 3] [Units: vx]
  126180. */
  126181. walkableHeight: number;
  126182. /**
  126183. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126184. */
  126185. walkableClimb: number;
  126186. /**
  126187. * The distance to erode/shrink the walkable area of the heightfield away from
  126188. * obstructions. [Limit: >=0] [Units: vx]
  126189. */
  126190. walkableRadius: number;
  126191. /**
  126192. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126193. */
  126194. maxEdgeLen: number;
  126195. /**
  126196. * The maximum distance a simplfied contour's border edges should deviate
  126197. * the original raw contour. [Limit: >=0] [Units: vx]
  126198. */
  126199. maxSimplificationError: number;
  126200. /**
  126201. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126202. */
  126203. minRegionArea: number;
  126204. /**
  126205. * Any regions with a span count smaller than this value will, if possible,
  126206. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126207. */
  126208. mergeRegionArea: number;
  126209. /**
  126210. * The maximum number of vertices allowed for polygons generated during the
  126211. * contour to polygon conversion process. [Limit: >= 3]
  126212. */
  126213. maxVertsPerPoly: number;
  126214. /**
  126215. * Sets the sampling distance to use when generating the detail mesh.
  126216. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126217. */
  126218. detailSampleDist: number;
  126219. /**
  126220. * The maximum distance the detail mesh surface should deviate from heightfield
  126221. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126222. */
  126223. detailSampleMaxError: number;
  126224. }
  126225. }
  126226. declare module BABYLON {
  126227. /**
  126228. * RecastJS navigation plugin
  126229. */
  126230. export class RecastJSPlugin implements INavigationEnginePlugin {
  126231. /**
  126232. * Reference to the Recast library
  126233. */
  126234. bjsRECAST: any;
  126235. /**
  126236. * plugin name
  126237. */
  126238. name: string;
  126239. /**
  126240. * the first navmesh created. We might extend this to support multiple navmeshes
  126241. */
  126242. navMesh: any;
  126243. /**
  126244. * Initializes the recastJS plugin
  126245. * @param recastInjection can be used to inject your own recast reference
  126246. */
  126247. constructor(recastInjection?: any);
  126248. /**
  126249. * Creates a navigation mesh
  126250. * @param meshes array of all the geometry used to compute the navigatio mesh
  126251. * @param parameters bunch of parameters used to filter geometry
  126252. */
  126253. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126254. /**
  126255. * Create a navigation mesh debug mesh
  126256. * @param scene is where the mesh will be added
  126257. * @returns debug display mesh
  126258. */
  126259. createDebugNavMesh(scene: Scene): Mesh;
  126260. /**
  126261. * Get a navigation mesh constrained position, closest to the parameter position
  126262. * @param position world position
  126263. * @returns the closest point to position constrained by the navigation mesh
  126264. */
  126265. getClosestPoint(position: Vector3): Vector3;
  126266. /**
  126267. * Get a navigation mesh constrained position, within a particular radius
  126268. * @param position world position
  126269. * @param maxRadius the maximum distance to the constrained world position
  126270. * @returns the closest point to position constrained by the navigation mesh
  126271. */
  126272. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126273. /**
  126274. * Compute the final position from a segment made of destination-position
  126275. * @param position world position
  126276. * @param destination world position
  126277. * @returns the resulting point along the navmesh
  126278. */
  126279. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126280. /**
  126281. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126282. * @param start world position
  126283. * @param end world position
  126284. * @returns array containing world position composing the path
  126285. */
  126286. computePath(start: Vector3, end: Vector3): Vector3[];
  126287. /**
  126288. * Create a new Crowd so you can add agents
  126289. * @param maxAgents the maximum agent count in the crowd
  126290. * @param maxAgentRadius the maximum radius an agent can have
  126291. * @param scene to attach the crowd to
  126292. * @returns the crowd you can add agents to
  126293. */
  126294. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126295. /**
  126296. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126297. * The queries will try to find a solution within those bounds
  126298. * default is (1,1,1)
  126299. * @param extent x,y,z value that define the extent around the queries point of reference
  126300. */
  126301. setDefaultQueryExtent(extent: Vector3): void;
  126302. /**
  126303. * Get the Bounding box extent specified by setDefaultQueryExtent
  126304. * @returns the box extent values
  126305. */
  126306. getDefaultQueryExtent(): Vector3;
  126307. /**
  126308. * Disposes
  126309. */
  126310. dispose(): void;
  126311. /**
  126312. * If this plugin is supported
  126313. * @returns true if plugin is supported
  126314. */
  126315. isSupported(): boolean;
  126316. }
  126317. /**
  126318. * Recast detour crowd implementation
  126319. */
  126320. export class RecastJSCrowd implements ICrowd {
  126321. /**
  126322. * Recast/detour plugin
  126323. */
  126324. bjsRECASTPlugin: RecastJSPlugin;
  126325. /**
  126326. * Link to the detour crowd
  126327. */
  126328. recastCrowd: any;
  126329. /**
  126330. * One transform per agent
  126331. */
  126332. transforms: TransformNode[];
  126333. /**
  126334. * All agents created
  126335. */
  126336. agents: number[];
  126337. /**
  126338. * Link to the scene is kept to unregister the crowd from the scene
  126339. */
  126340. private _scene;
  126341. /**
  126342. * Observer for crowd updates
  126343. */
  126344. private _onBeforeAnimationsObserver;
  126345. /**
  126346. * Constructor
  126347. * @param plugin recastJS plugin
  126348. * @param maxAgents the maximum agent count in the crowd
  126349. * @param maxAgentRadius the maximum radius an agent can have
  126350. * @param scene to attach the crowd to
  126351. * @returns the crowd you can add agents to
  126352. */
  126353. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126354. /**
  126355. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126356. * You can attach anything to that node. The node position is updated in the scene update tick.
  126357. * @param pos world position that will be constrained by the navigation mesh
  126358. * @param parameters agent parameters
  126359. * @param transform hooked to the agent that will be update by the scene
  126360. * @returns agent index
  126361. */
  126362. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126363. /**
  126364. * Returns the agent position in world space
  126365. * @param index agent index returned by addAgent
  126366. * @returns world space position
  126367. */
  126368. getAgentPosition(index: number): Vector3;
  126369. /**
  126370. * Returns the agent velocity in world space
  126371. * @param index agent index returned by addAgent
  126372. * @returns world space velocity
  126373. */
  126374. getAgentVelocity(index: number): Vector3;
  126375. /**
  126376. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126377. * @param index agent index returned by addAgent
  126378. * @param destination targeted world position
  126379. */
  126380. agentGoto(index: number, destination: Vector3): void;
  126381. /**
  126382. * remove a particular agent previously created
  126383. * @param index agent index returned by addAgent
  126384. */
  126385. removeAgent(index: number): void;
  126386. /**
  126387. * get the list of all agents attached to this crowd
  126388. * @returns list of agent indices
  126389. */
  126390. getAgents(): number[];
  126391. /**
  126392. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126393. * @param deltaTime in seconds
  126394. */
  126395. update(deltaTime: number): void;
  126396. /**
  126397. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126398. * The queries will try to find a solution within those bounds
  126399. * default is (1,1,1)
  126400. * @param extent x,y,z value that define the extent around the queries point of reference
  126401. */
  126402. setDefaultQueryExtent(extent: Vector3): void;
  126403. /**
  126404. * Get the Bounding box extent specified by setDefaultQueryExtent
  126405. * @returns the box extent values
  126406. */
  126407. getDefaultQueryExtent(): Vector3;
  126408. /**
  126409. * Release all resources
  126410. */
  126411. dispose(): void;
  126412. }
  126413. }
  126414. declare module BABYLON {
  126415. /**
  126416. * Class used to enable access to IndexedDB
  126417. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126418. */
  126419. export class Database implements IOfflineProvider {
  126420. private _callbackManifestChecked;
  126421. private _currentSceneUrl;
  126422. private _db;
  126423. private _enableSceneOffline;
  126424. private _enableTexturesOffline;
  126425. private _manifestVersionFound;
  126426. private _mustUpdateRessources;
  126427. private _hasReachedQuota;
  126428. private _isSupported;
  126429. private _idbFactory;
  126430. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126431. private static IsUASupportingBlobStorage;
  126432. /**
  126433. * Gets a boolean indicating if Database storate is enabled (off by default)
  126434. */
  126435. static IDBStorageEnabled: boolean;
  126436. /**
  126437. * Gets a boolean indicating if scene must be saved in the database
  126438. */
  126439. readonly enableSceneOffline: boolean;
  126440. /**
  126441. * Gets a boolean indicating if textures must be saved in the database
  126442. */
  126443. readonly enableTexturesOffline: boolean;
  126444. /**
  126445. * Creates a new Database
  126446. * @param urlToScene defines the url to load the scene
  126447. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126448. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126449. */
  126450. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126451. private static _ParseURL;
  126452. private static _ReturnFullUrlLocation;
  126453. private _checkManifestFile;
  126454. /**
  126455. * Open the database and make it available
  126456. * @param successCallback defines the callback to call on success
  126457. * @param errorCallback defines the callback to call on error
  126458. */
  126459. open(successCallback: () => void, errorCallback: () => void): void;
  126460. /**
  126461. * Loads an image from the database
  126462. * @param url defines the url to load from
  126463. * @param image defines the target DOM image
  126464. */
  126465. loadImage(url: string, image: HTMLImageElement): void;
  126466. private _loadImageFromDBAsync;
  126467. private _saveImageIntoDBAsync;
  126468. private _checkVersionFromDB;
  126469. private _loadVersionFromDBAsync;
  126470. private _saveVersionIntoDBAsync;
  126471. /**
  126472. * Loads a file from database
  126473. * @param url defines the URL to load from
  126474. * @param sceneLoaded defines a callback to call on success
  126475. * @param progressCallBack defines a callback to call when progress changed
  126476. * @param errorCallback defines a callback to call on error
  126477. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126478. */
  126479. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126480. private _loadFileAsync;
  126481. private _saveFileAsync;
  126482. /**
  126483. * Validates if xhr data is correct
  126484. * @param xhr defines the request to validate
  126485. * @param dataType defines the expected data type
  126486. * @returns true if data is correct
  126487. */
  126488. private static _ValidateXHRData;
  126489. }
  126490. }
  126491. declare module BABYLON {
  126492. /** @hidden */
  126493. export var gpuUpdateParticlesPixelShader: {
  126494. name: string;
  126495. shader: string;
  126496. };
  126497. }
  126498. declare module BABYLON {
  126499. /** @hidden */
  126500. export var gpuUpdateParticlesVertexShader: {
  126501. name: string;
  126502. shader: string;
  126503. };
  126504. }
  126505. declare module BABYLON {
  126506. /** @hidden */
  126507. export var clipPlaneFragmentDeclaration2: {
  126508. name: string;
  126509. shader: string;
  126510. };
  126511. }
  126512. declare module BABYLON {
  126513. /** @hidden */
  126514. export var gpuRenderParticlesPixelShader: {
  126515. name: string;
  126516. shader: string;
  126517. };
  126518. }
  126519. declare module BABYLON {
  126520. /** @hidden */
  126521. export var clipPlaneVertexDeclaration2: {
  126522. name: string;
  126523. shader: string;
  126524. };
  126525. }
  126526. declare module BABYLON {
  126527. /** @hidden */
  126528. export var gpuRenderParticlesVertexShader: {
  126529. name: string;
  126530. shader: string;
  126531. };
  126532. }
  126533. declare module BABYLON {
  126534. /**
  126535. * This represents a GPU particle system in Babylon
  126536. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126537. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126538. */
  126539. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126540. /**
  126541. * The layer mask we are rendering the particles through.
  126542. */
  126543. layerMask: number;
  126544. private _capacity;
  126545. private _activeCount;
  126546. private _currentActiveCount;
  126547. private _accumulatedCount;
  126548. private _renderEffect;
  126549. private _updateEffect;
  126550. private _buffer0;
  126551. private _buffer1;
  126552. private _spriteBuffer;
  126553. private _updateVAO;
  126554. private _renderVAO;
  126555. private _targetIndex;
  126556. private _sourceBuffer;
  126557. private _targetBuffer;
  126558. private _engine;
  126559. private _currentRenderId;
  126560. private _started;
  126561. private _stopped;
  126562. private _timeDelta;
  126563. private _randomTexture;
  126564. private _randomTexture2;
  126565. private _attributesStrideSize;
  126566. private _updateEffectOptions;
  126567. private _randomTextureSize;
  126568. private _actualFrame;
  126569. private readonly _rawTextureWidth;
  126570. /**
  126571. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  126572. */
  126573. static readonly IsSupported: boolean;
  126574. /**
  126575. * An event triggered when the system is disposed.
  126576. */
  126577. onDisposeObservable: Observable<GPUParticleSystem>;
  126578. /**
  126579. * Gets the maximum number of particles active at the same time.
  126580. * @returns The max number of active particles.
  126581. */
  126582. getCapacity(): number;
  126583. /**
  126584. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  126585. * to override the particles.
  126586. */
  126587. forceDepthWrite: boolean;
  126588. /**
  126589. * Gets or set the number of active particles
  126590. */
  126591. activeParticleCount: number;
  126592. private _preWarmDone;
  126593. /**
  126594. * Is this system ready to be used/rendered
  126595. * @return true if the system is ready
  126596. */
  126597. isReady(): boolean;
  126598. /**
  126599. * Gets if the system has been started. (Note: this will still be true after stop is called)
  126600. * @returns True if it has been started, otherwise false.
  126601. */
  126602. isStarted(): boolean;
  126603. /**
  126604. * Starts the particle system and begins to emit
  126605. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  126606. */
  126607. start(delay?: number): void;
  126608. /**
  126609. * Stops the particle system.
  126610. */
  126611. stop(): void;
  126612. /**
  126613. * Remove all active particles
  126614. */
  126615. reset(): void;
  126616. /**
  126617. * Returns the string "GPUParticleSystem"
  126618. * @returns a string containing the class name
  126619. */
  126620. getClassName(): string;
  126621. private _colorGradientsTexture;
  126622. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  126623. /**
  126624. * Adds a new color gradient
  126625. * @param gradient defines the gradient to use (between 0 and 1)
  126626. * @param color1 defines the color to affect to the specified gradient
  126627. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  126628. * @returns the current particle system
  126629. */
  126630. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  126631. /**
  126632. * Remove a specific color gradient
  126633. * @param gradient defines the gradient to remove
  126634. * @returns the current particle system
  126635. */
  126636. removeColorGradient(gradient: number): GPUParticleSystem;
  126637. private _angularSpeedGradientsTexture;
  126638. private _sizeGradientsTexture;
  126639. private _velocityGradientsTexture;
  126640. private _limitVelocityGradientsTexture;
  126641. private _dragGradientsTexture;
  126642. private _addFactorGradient;
  126643. /**
  126644. * Adds a new size gradient
  126645. * @param gradient defines the gradient to use (between 0 and 1)
  126646. * @param factor defines the size factor to affect to the specified gradient
  126647. * @returns the current particle system
  126648. */
  126649. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  126650. /**
  126651. * Remove a specific size gradient
  126652. * @param gradient defines the gradient to remove
  126653. * @returns the current particle system
  126654. */
  126655. removeSizeGradient(gradient: number): GPUParticleSystem;
  126656. /**
  126657. * Adds a new angular speed gradient
  126658. * @param gradient defines the gradient to use (between 0 and 1)
  126659. * @param factor defines the angular speed to affect to the specified gradient
  126660. * @returns the current particle system
  126661. */
  126662. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  126663. /**
  126664. * Remove a specific angular speed gradient
  126665. * @param gradient defines the gradient to remove
  126666. * @returns the current particle system
  126667. */
  126668. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  126669. /**
  126670. * Adds a new velocity gradient
  126671. * @param gradient defines the gradient to use (between 0 and 1)
  126672. * @param factor defines the velocity to affect to the specified gradient
  126673. * @returns the current particle system
  126674. */
  126675. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126676. /**
  126677. * Remove a specific velocity gradient
  126678. * @param gradient defines the gradient to remove
  126679. * @returns the current particle system
  126680. */
  126681. removeVelocityGradient(gradient: number): GPUParticleSystem;
  126682. /**
  126683. * Adds a new limit velocity gradient
  126684. * @param gradient defines the gradient to use (between 0 and 1)
  126685. * @param factor defines the limit velocity value to affect to the specified gradient
  126686. * @returns the current particle system
  126687. */
  126688. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126689. /**
  126690. * Remove a specific limit velocity gradient
  126691. * @param gradient defines the gradient to remove
  126692. * @returns the current particle system
  126693. */
  126694. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  126695. /**
  126696. * Adds a new drag gradient
  126697. * @param gradient defines the gradient to use (between 0 and 1)
  126698. * @param factor defines the drag value to affect to the specified gradient
  126699. * @returns the current particle system
  126700. */
  126701. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  126702. /**
  126703. * Remove a specific drag gradient
  126704. * @param gradient defines the gradient to remove
  126705. * @returns the current particle system
  126706. */
  126707. removeDragGradient(gradient: number): GPUParticleSystem;
  126708. /**
  126709. * Not supported by GPUParticleSystem
  126710. * @param gradient defines the gradient to use (between 0 and 1)
  126711. * @param factor defines the emit rate value to affect to the specified gradient
  126712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126713. * @returns the current particle system
  126714. */
  126715. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126716. /**
  126717. * Not supported by GPUParticleSystem
  126718. * @param gradient defines the gradient to remove
  126719. * @returns the current particle system
  126720. */
  126721. removeEmitRateGradient(gradient: number): IParticleSystem;
  126722. /**
  126723. * Not supported by GPUParticleSystem
  126724. * @param gradient defines the gradient to use (between 0 and 1)
  126725. * @param factor defines the start size value to affect to the specified gradient
  126726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126727. * @returns the current particle system
  126728. */
  126729. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126730. /**
  126731. * Not supported by GPUParticleSystem
  126732. * @param gradient defines the gradient to remove
  126733. * @returns the current particle system
  126734. */
  126735. removeStartSizeGradient(gradient: number): IParticleSystem;
  126736. /**
  126737. * Not supported by GPUParticleSystem
  126738. * @param gradient defines the gradient to use (between 0 and 1)
  126739. * @param min defines the color remap minimal range
  126740. * @param max defines the color remap maximal range
  126741. * @returns the current particle system
  126742. */
  126743. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126744. /**
  126745. * Not supported by GPUParticleSystem
  126746. * @param gradient defines the gradient to remove
  126747. * @returns the current particle system
  126748. */
  126749. removeColorRemapGradient(): IParticleSystem;
  126750. /**
  126751. * Not supported by GPUParticleSystem
  126752. * @param gradient defines the gradient to use (between 0 and 1)
  126753. * @param min defines the alpha remap minimal range
  126754. * @param max defines the alpha remap maximal range
  126755. * @returns the current particle system
  126756. */
  126757. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126758. /**
  126759. * Not supported by GPUParticleSystem
  126760. * @param gradient defines the gradient to remove
  126761. * @returns the current particle system
  126762. */
  126763. removeAlphaRemapGradient(): IParticleSystem;
  126764. /**
  126765. * Not supported by GPUParticleSystem
  126766. * @param gradient defines the gradient to use (between 0 and 1)
  126767. * @param color defines the color to affect to the specified gradient
  126768. * @returns the current particle system
  126769. */
  126770. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  126771. /**
  126772. * Not supported by GPUParticleSystem
  126773. * @param gradient defines the gradient to remove
  126774. * @returns the current particle system
  126775. */
  126776. removeRampGradient(): IParticleSystem;
  126777. /**
  126778. * Not supported by GPUParticleSystem
  126779. * @returns the list of ramp gradients
  126780. */
  126781. getRampGradients(): Nullable<Array<Color3Gradient>>;
  126782. /**
  126783. * Not supported by GPUParticleSystem
  126784. * Gets or sets a boolean indicating that ramp gradients must be used
  126785. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  126786. */
  126787. useRampGradients: boolean;
  126788. /**
  126789. * Not supported by GPUParticleSystem
  126790. * @param gradient defines the gradient to use (between 0 and 1)
  126791. * @param factor defines the life time factor to affect to the specified gradient
  126792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126793. * @returns the current particle system
  126794. */
  126795. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126796. /**
  126797. * Not supported by GPUParticleSystem
  126798. * @param gradient defines the gradient to remove
  126799. * @returns the current particle system
  126800. */
  126801. removeLifeTimeGradient(gradient: number): IParticleSystem;
  126802. /**
  126803. * Instantiates a GPU particle system.
  126804. * 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.
  126805. * @param name The name of the particle system
  126806. * @param options The options used to create the system
  126807. * @param scene The scene the particle system belongs to
  126808. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  126809. */
  126810. constructor(name: string, options: Partial<{
  126811. capacity: number;
  126812. randomTextureSize: number;
  126813. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  126814. protected _reset(): void;
  126815. private _createUpdateVAO;
  126816. private _createRenderVAO;
  126817. private _initialize;
  126818. /** @hidden */
  126819. _recreateUpdateEffect(): void;
  126820. /** @hidden */
  126821. _recreateRenderEffect(): void;
  126822. /**
  126823. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  126824. * @param preWarm defines if we are in the pre-warmimg phase
  126825. */
  126826. animate(preWarm?: boolean): void;
  126827. private _createFactorGradientTexture;
  126828. private _createSizeGradientTexture;
  126829. private _createAngularSpeedGradientTexture;
  126830. private _createVelocityGradientTexture;
  126831. private _createLimitVelocityGradientTexture;
  126832. private _createDragGradientTexture;
  126833. private _createColorGradientTexture;
  126834. /**
  126835. * Renders the particle system in its current state
  126836. * @param preWarm defines if the system should only update the particles but not render them
  126837. * @returns the current number of particles
  126838. */
  126839. render(preWarm?: boolean): number;
  126840. /**
  126841. * Rebuilds the particle system
  126842. */
  126843. rebuild(): void;
  126844. private _releaseBuffers;
  126845. private _releaseVAOs;
  126846. /**
  126847. * Disposes the particle system and free the associated resources
  126848. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  126849. */
  126850. dispose(disposeTexture?: boolean): void;
  126851. /**
  126852. * Clones the particle system.
  126853. * @param name The name of the cloned object
  126854. * @param newEmitter The new emitter to use
  126855. * @returns the cloned particle system
  126856. */
  126857. clone(name: string, newEmitter: any): GPUParticleSystem;
  126858. /**
  126859. * Serializes the particle system to a JSON object.
  126860. * @returns the JSON object
  126861. */
  126862. serialize(): any;
  126863. /**
  126864. * Parses a JSON object to create a GPU particle system.
  126865. * @param parsedParticleSystem The JSON object to parse
  126866. * @param scene The scene to create the particle system in
  126867. * @param rootUrl The root url to use to load external dependencies like texture
  126868. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  126869. * @returns the parsed GPU particle system
  126870. */
  126871. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  126872. }
  126873. }
  126874. declare module BABYLON {
  126875. /**
  126876. * Represents a set of particle systems working together to create a specific effect
  126877. */
  126878. export class ParticleSystemSet implements IDisposable {
  126879. /**
  126880. * Gets or sets base Assets URL
  126881. */
  126882. static BaseAssetsUrl: string;
  126883. private _emitterCreationOptions;
  126884. private _emitterNode;
  126885. /**
  126886. * Gets the particle system list
  126887. */
  126888. systems: IParticleSystem[];
  126889. /**
  126890. * Gets the emitter node used with this set
  126891. */
  126892. readonly emitterNode: Nullable<TransformNode>;
  126893. /**
  126894. * Creates a new emitter mesh as a sphere
  126895. * @param options defines the options used to create the sphere
  126896. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  126897. * @param scene defines the hosting scene
  126898. */
  126899. setEmitterAsSphere(options: {
  126900. diameter: number;
  126901. segments: number;
  126902. color: Color3;
  126903. }, renderingGroupId: number, scene: Scene): void;
  126904. /**
  126905. * Starts all particle systems of the set
  126906. * @param emitter defines an optional mesh to use as emitter for the particle systems
  126907. */
  126908. start(emitter?: AbstractMesh): void;
  126909. /**
  126910. * Release all associated resources
  126911. */
  126912. dispose(): void;
  126913. /**
  126914. * Serialize the set into a JSON compatible object
  126915. * @returns a JSON compatible representation of the set
  126916. */
  126917. serialize(): any;
  126918. /**
  126919. * Parse a new ParticleSystemSet from a serialized source
  126920. * @param data defines a JSON compatible representation of the set
  126921. * @param scene defines the hosting scene
  126922. * @param gpu defines if we want GPU particles or CPU particles
  126923. * @returns a new ParticleSystemSet
  126924. */
  126925. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  126926. }
  126927. }
  126928. declare module BABYLON {
  126929. /**
  126930. * This class is made for on one-liner static method to help creating particle system set.
  126931. */
  126932. export class ParticleHelper {
  126933. /**
  126934. * Gets or sets base Assets URL
  126935. */
  126936. static BaseAssetsUrl: string;
  126937. /**
  126938. * Create a default particle system that you can tweak
  126939. * @param emitter defines the emitter to use
  126940. * @param capacity defines the system capacity (default is 500 particles)
  126941. * @param scene defines the hosting scene
  126942. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  126943. * @returns the new Particle system
  126944. */
  126945. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  126946. /**
  126947. * This is the main static method (one-liner) of this helper to create different particle systems
  126948. * @param type This string represents the type to the particle system to create
  126949. * @param scene The scene where the particle system should live
  126950. * @param gpu If the system will use gpu
  126951. * @returns the ParticleSystemSet created
  126952. */
  126953. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  126954. /**
  126955. * Static function used to export a particle system to a ParticleSystemSet variable.
  126956. * Please note that the emitter shape is not exported
  126957. * @param systems defines the particle systems to export
  126958. * @returns the created particle system set
  126959. */
  126960. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  126961. }
  126962. }
  126963. declare module BABYLON {
  126964. interface Engine {
  126965. /**
  126966. * Create an effect to use with particle systems.
  126967. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  126968. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  126969. * @param uniformsNames defines a list of attribute names
  126970. * @param samplers defines an array of string used to represent textures
  126971. * @param defines defines the string containing the defines to use to compile the shaders
  126972. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  126973. * @param onCompiled defines a function to call when the effect creation is successful
  126974. * @param onError defines a function to call when the effect creation has failed
  126975. * @returns the new Effect
  126976. */
  126977. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  126978. }
  126979. interface Mesh {
  126980. /**
  126981. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  126982. * @returns an array of IParticleSystem
  126983. */
  126984. getEmittedParticleSystems(): IParticleSystem[];
  126985. /**
  126986. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  126987. * @returns an array of IParticleSystem
  126988. */
  126989. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  126990. }
  126991. /**
  126992. * @hidden
  126993. */
  126994. export var _IDoNeedToBeInTheBuild: number;
  126995. }
  126996. declare module BABYLON {
  126997. /** Defines the 4 color options */
  126998. export enum PointColor {
  126999. /** color value */
  127000. Color = 2,
  127001. /** uv value */
  127002. UV = 1,
  127003. /** random value */
  127004. Random = 0,
  127005. /** stated value */
  127006. Stated = 3
  127007. }
  127008. /**
  127009. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  127010. * 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.
  127011. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  127012. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  127013. *
  127014. * Full documentation here : TO BE ENTERED
  127015. */
  127016. export class PointsCloudSystem implements IDisposable {
  127017. /**
  127018. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  127019. * Example : var p = SPS.particles[i];
  127020. */
  127021. particles: CloudPoint[];
  127022. /**
  127023. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  127024. */
  127025. nbParticles: number;
  127026. /**
  127027. * This a counter for your own usage. It's not set by any SPS functions.
  127028. */
  127029. counter: number;
  127030. /**
  127031. * The PCS name. This name is also given to the underlying mesh.
  127032. */
  127033. name: string;
  127034. /**
  127035. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  127036. */
  127037. mesh: Mesh;
  127038. /**
  127039. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  127040. * Please read :
  127041. */
  127042. vars: any;
  127043. /**
  127044. * @hidden
  127045. */
  127046. _size: number;
  127047. private _scene;
  127048. private _promises;
  127049. private _positions;
  127050. private _indices;
  127051. private _normals;
  127052. private _colors;
  127053. private _uvs;
  127054. private _indices32;
  127055. private _positions32;
  127056. private _colors32;
  127057. private _uvs32;
  127058. private _updatable;
  127059. private _isVisibilityBoxLocked;
  127060. private _alwaysVisible;
  127061. private _groups;
  127062. private _groupCounter;
  127063. private _computeParticleColor;
  127064. private _computeParticleTexture;
  127065. private _computeParticleRotation;
  127066. private _computeBoundingBox;
  127067. private _isReady;
  127068. /**
  127069. * Creates a PCS (Points Cloud System) object
  127070. * @param name (String) is the PCS name, this will be the underlying mesh name
  127071. * @param pointSize (number) is the size for each point
  127072. * @param scene (Scene) is the scene in which the PCS is added
  127073. * @param options defines the options of the PCS e.g.
  127074. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127075. */
  127076. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127077. updatable?: boolean;
  127078. });
  127079. /**
  127080. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127081. * If no points were added to the PCS, the returned mesh is just a single point.
  127082. * @returns a promise for the created mesh
  127083. */
  127084. buildMeshAsync(): Promise<Mesh>;
  127085. /**
  127086. * @hidden
  127087. */
  127088. private _buildMesh;
  127089. private _addParticle;
  127090. private _randomUnitVector;
  127091. private _getColorIndicesForCoord;
  127092. private _setPointsColorOrUV;
  127093. private _colorFromTexture;
  127094. private _calculateDensity;
  127095. /**
  127096. * Adds points to the PCS in random positions within a unit sphere
  127097. * @param nb (positive integer) the number of particles to be created from this model
  127098. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127099. * @returns the number of groups in the system
  127100. */
  127101. addPoints(nb: number, pointFunction?: any): number;
  127102. /**
  127103. * Adds points to the PCS from the surface of the model shape
  127104. * @param mesh is any Mesh object that will be used as a surface model for the points
  127105. * @param nb (positive integer) the number of particles to be created from this model
  127106. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127107. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127108. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127109. * @returns the number of groups in the system
  127110. */
  127111. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127112. /**
  127113. * Adds points to the PCS inside the model shape
  127114. * @param mesh is any Mesh object that will be used as a surface model for the points
  127115. * @param nb (positive integer) the number of particles to be created from this model
  127116. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127117. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127118. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127119. * @returns the number of groups in the system
  127120. */
  127121. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127122. /**
  127123. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127124. * This method calls `updateParticle()` for each particle of the SPS.
  127125. * For an animated SPS, it is usually called within the render loop.
  127126. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127127. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127128. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127129. * @returns the PCS.
  127130. */
  127131. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127132. /**
  127133. * Disposes the PCS.
  127134. */
  127135. dispose(): void;
  127136. /**
  127137. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127138. * doc :
  127139. * @returns the PCS.
  127140. */
  127141. refreshVisibleSize(): PointsCloudSystem;
  127142. /**
  127143. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127144. * @param size the size (float) of the visibility box
  127145. * note : this doesn't lock the PCS mesh bounding box.
  127146. * doc :
  127147. */
  127148. setVisibilityBox(size: number): void;
  127149. /**
  127150. * Gets whether the PCS is always visible or not
  127151. * doc :
  127152. */
  127153. /**
  127154. * Sets the PCS as always visible or not
  127155. * doc :
  127156. */
  127157. isAlwaysVisible: boolean;
  127158. /**
  127159. * Tells to `setParticles()` to compute the particle rotations or not
  127160. * Default value : false. The PCS is faster when it's set to false
  127161. * Note : particle rotations are only applied to parent particles
  127162. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127163. */
  127164. computeParticleRotation: boolean;
  127165. /**
  127166. * Tells to `setParticles()` to compute the particle colors or not.
  127167. * Default value : true. The PCS is faster when it's set to false.
  127168. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127169. */
  127170. /**
  127171. * Gets if `setParticles()` computes the particle colors or not.
  127172. * Default value : false. The PCS is faster when it's set to false.
  127173. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127174. */
  127175. computeParticleColor: boolean;
  127176. /**
  127177. * Gets if `setParticles()` computes the particle textures or not.
  127178. * Default value : false. The PCS is faster when it's set to false.
  127179. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127180. */
  127181. computeParticleTexture: boolean;
  127182. /**
  127183. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127184. */
  127185. /**
  127186. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127187. */
  127188. computeBoundingBox: boolean;
  127189. /**
  127190. * This function does nothing. It may be overwritten to set all the particle first values.
  127191. * The PCS doesn't call this function, you may have to call it by your own.
  127192. * doc :
  127193. */
  127194. initParticles(): void;
  127195. /**
  127196. * This function does nothing. It may be overwritten to recycle a particle
  127197. * The PCS doesn't call this function, you can to call it
  127198. * doc :
  127199. * @param particle The particle to recycle
  127200. * @returns the recycled particle
  127201. */
  127202. recycleParticle(particle: CloudPoint): CloudPoint;
  127203. /**
  127204. * Updates a particle : this function should be overwritten by the user.
  127205. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127206. * doc :
  127207. * @example : just set a particle position or velocity and recycle conditions
  127208. * @param particle The particle to update
  127209. * @returns the updated particle
  127210. */
  127211. updateParticle(particle: CloudPoint): CloudPoint;
  127212. /**
  127213. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127214. * This does nothing and may be overwritten by the user.
  127215. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127216. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127217. * @param update the boolean update value actually passed to setParticles()
  127218. */
  127219. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127220. /**
  127221. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127222. * This will be passed three parameters.
  127223. * This does nothing and may be overwritten by the user.
  127224. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127225. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127226. * @param update the boolean update value actually passed to setParticles()
  127227. */
  127228. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127229. }
  127230. }
  127231. declare module BABYLON {
  127232. /**
  127233. * Represents one particle of a points cloud system.
  127234. */
  127235. export class CloudPoint {
  127236. /**
  127237. * particle global index
  127238. */
  127239. idx: number;
  127240. /**
  127241. * The color of the particle
  127242. */
  127243. color: Nullable<Color4>;
  127244. /**
  127245. * The world space position of the particle.
  127246. */
  127247. position: Vector3;
  127248. /**
  127249. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127250. */
  127251. rotation: Vector3;
  127252. /**
  127253. * The world space rotation quaternion of the particle.
  127254. */
  127255. rotationQuaternion: Nullable<Quaternion>;
  127256. /**
  127257. * The uv of the particle.
  127258. */
  127259. uv: Nullable<Vector2>;
  127260. /**
  127261. * The current speed of the particle.
  127262. */
  127263. velocity: Vector3;
  127264. /**
  127265. * The pivot point in the particle local space.
  127266. */
  127267. pivot: Vector3;
  127268. /**
  127269. * Must the particle be translated from its pivot point in its local space ?
  127270. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127271. * Default : false
  127272. */
  127273. translateFromPivot: boolean;
  127274. /**
  127275. * Index of this particle in the global "positions" array (Internal use)
  127276. * @hidden
  127277. */
  127278. _pos: number;
  127279. /**
  127280. * @hidden Index of this particle in the global "indices" array (Internal use)
  127281. */
  127282. _ind: number;
  127283. /**
  127284. * Group this particle belongs to
  127285. */
  127286. _group: PointsGroup;
  127287. /**
  127288. * Group id of this particle
  127289. */
  127290. groupId: number;
  127291. /**
  127292. * Index of the particle in its group id (Internal use)
  127293. */
  127294. idxInGroup: number;
  127295. /**
  127296. * @hidden Particle BoundingInfo object (Internal use)
  127297. */
  127298. _boundingInfo: BoundingInfo;
  127299. /**
  127300. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127301. */
  127302. _pcs: PointsCloudSystem;
  127303. /**
  127304. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127305. */
  127306. _stillInvisible: boolean;
  127307. /**
  127308. * @hidden Last computed particle rotation matrix
  127309. */
  127310. _rotationMatrix: number[];
  127311. /**
  127312. * Parent particle Id, if any.
  127313. * Default null.
  127314. */
  127315. parentId: Nullable<number>;
  127316. /**
  127317. * @hidden Internal global position in the PCS.
  127318. */
  127319. _globalPosition: Vector3;
  127320. /**
  127321. * Creates a Point Cloud object.
  127322. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127323. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127324. * @param group (PointsGroup) is the group the particle belongs to
  127325. * @param groupId (integer) is the group identifier in the PCS.
  127326. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127327. * @param pcs defines the PCS it is associated to
  127328. */
  127329. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127330. /**
  127331. * get point size
  127332. */
  127333. /**
  127334. * Set point size
  127335. */
  127336. size: Vector3;
  127337. /**
  127338. * Legacy support, changed quaternion to rotationQuaternion
  127339. */
  127340. /**
  127341. * Legacy support, changed quaternion to rotationQuaternion
  127342. */
  127343. quaternion: Nullable<Quaternion>;
  127344. /**
  127345. * Returns a boolean. True if the particle intersects a mesh, else false
  127346. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127347. * @param target is the object (point or mesh) what the intersection is computed against
  127348. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127349. * @returns true if it intersects
  127350. */
  127351. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127352. /**
  127353. * get the rotation matrix of the particle
  127354. * @hidden
  127355. */
  127356. getRotationMatrix(m: Matrix): void;
  127357. }
  127358. /**
  127359. * Represents a group of points in a points cloud system
  127360. * * PCS internal tool, don't use it manually.
  127361. */
  127362. export class PointsGroup {
  127363. /**
  127364. * The group id
  127365. * @hidden
  127366. */
  127367. groupID: number;
  127368. /**
  127369. * image data for group (internal use)
  127370. * @hidden
  127371. */
  127372. _groupImageData: Nullable<ArrayBufferView>;
  127373. /**
  127374. * Image Width (internal use)
  127375. * @hidden
  127376. */
  127377. _groupImgWidth: number;
  127378. /**
  127379. * Image Height (internal use)
  127380. * @hidden
  127381. */
  127382. _groupImgHeight: number;
  127383. /**
  127384. * Custom position function (internal use)
  127385. * @hidden
  127386. */
  127387. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127388. /**
  127389. * density per facet for surface points
  127390. * @hidden
  127391. */
  127392. _groupDensity: number[];
  127393. /**
  127394. * Only when points are colored by texture carries pointer to texture list array
  127395. * @hidden
  127396. */
  127397. _textureNb: number;
  127398. /**
  127399. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127400. * PCS internal tool, don't use it manually.
  127401. * @hidden
  127402. */
  127403. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127404. }
  127405. }
  127406. declare module BABYLON {
  127407. interface Scene {
  127408. /** @hidden (Backing field) */
  127409. _physicsEngine: Nullable<IPhysicsEngine>;
  127410. /**
  127411. * Gets the current physics engine
  127412. * @returns a IPhysicsEngine or null if none attached
  127413. */
  127414. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127415. /**
  127416. * Enables physics to the current scene
  127417. * @param gravity defines the scene's gravity for the physics engine
  127418. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127419. * @return a boolean indicating if the physics engine was initialized
  127420. */
  127421. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127422. /**
  127423. * Disables and disposes the physics engine associated with the scene
  127424. */
  127425. disablePhysicsEngine(): void;
  127426. /**
  127427. * Gets a boolean indicating if there is an active physics engine
  127428. * @returns a boolean indicating if there is an active physics engine
  127429. */
  127430. isPhysicsEnabled(): boolean;
  127431. /**
  127432. * Deletes a physics compound impostor
  127433. * @param compound defines the compound to delete
  127434. */
  127435. deleteCompoundImpostor(compound: any): void;
  127436. /**
  127437. * An event triggered when physic simulation is about to be run
  127438. */
  127439. onBeforePhysicsObservable: Observable<Scene>;
  127440. /**
  127441. * An event triggered when physic simulation has been done
  127442. */
  127443. onAfterPhysicsObservable: Observable<Scene>;
  127444. }
  127445. interface AbstractMesh {
  127446. /** @hidden */
  127447. _physicsImpostor: Nullable<PhysicsImpostor>;
  127448. /**
  127449. * Gets or sets impostor used for physic simulation
  127450. * @see http://doc.babylonjs.com/features/physics_engine
  127451. */
  127452. physicsImpostor: Nullable<PhysicsImpostor>;
  127453. /**
  127454. * Gets the current physics impostor
  127455. * @see http://doc.babylonjs.com/features/physics_engine
  127456. * @returns a physics impostor or null
  127457. */
  127458. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127459. /** Apply a physic impulse to the mesh
  127460. * @param force defines the force to apply
  127461. * @param contactPoint defines where to apply the force
  127462. * @returns the current mesh
  127463. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127464. */
  127465. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127466. /**
  127467. * Creates a physic joint between two meshes
  127468. * @param otherMesh defines the other mesh to use
  127469. * @param pivot1 defines the pivot to use on this mesh
  127470. * @param pivot2 defines the pivot to use on the other mesh
  127471. * @param options defines additional options (can be plugin dependent)
  127472. * @returns the current mesh
  127473. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127474. */
  127475. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127476. /** @hidden */
  127477. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127478. }
  127479. /**
  127480. * Defines the physics engine scene component responsible to manage a physics engine
  127481. */
  127482. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127483. /**
  127484. * The component name helpful to identify the component in the list of scene components.
  127485. */
  127486. readonly name: string;
  127487. /**
  127488. * The scene the component belongs to.
  127489. */
  127490. scene: Scene;
  127491. /**
  127492. * Creates a new instance of the component for the given scene
  127493. * @param scene Defines the scene to register the component in
  127494. */
  127495. constructor(scene: Scene);
  127496. /**
  127497. * Registers the component in a given scene
  127498. */
  127499. register(): void;
  127500. /**
  127501. * Rebuilds the elements related to this component in case of
  127502. * context lost for instance.
  127503. */
  127504. rebuild(): void;
  127505. /**
  127506. * Disposes the component and the associated ressources
  127507. */
  127508. dispose(): void;
  127509. }
  127510. }
  127511. declare module BABYLON {
  127512. /**
  127513. * A helper for physics simulations
  127514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127515. */
  127516. export class PhysicsHelper {
  127517. private _scene;
  127518. private _physicsEngine;
  127519. /**
  127520. * Initializes the Physics helper
  127521. * @param scene Babylon.js scene
  127522. */
  127523. constructor(scene: Scene);
  127524. /**
  127525. * Applies a radial explosion impulse
  127526. * @param origin the origin of the explosion
  127527. * @param radiusOrEventOptions the radius or the options of radial explosion
  127528. * @param strength the explosion strength
  127529. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127530. * @returns A physics radial explosion event, or null
  127531. */
  127532. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127533. /**
  127534. * Applies a radial explosion force
  127535. * @param origin the origin of the explosion
  127536. * @param radiusOrEventOptions the radius or the options of radial explosion
  127537. * @param strength the explosion strength
  127538. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127539. * @returns A physics radial explosion event, or null
  127540. */
  127541. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127542. /**
  127543. * Creates a gravitational field
  127544. * @param origin the origin of the explosion
  127545. * @param radiusOrEventOptions the radius or the options of radial explosion
  127546. * @param strength the explosion strength
  127547. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127548. * @returns A physics gravitational field event, or null
  127549. */
  127550. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127551. /**
  127552. * Creates a physics updraft event
  127553. * @param origin the origin of the updraft
  127554. * @param radiusOrEventOptions the radius or the options of the updraft
  127555. * @param strength the strength of the updraft
  127556. * @param height the height of the updraft
  127557. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127558. * @returns A physics updraft event, or null
  127559. */
  127560. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127561. /**
  127562. * Creates a physics vortex event
  127563. * @param origin the of the vortex
  127564. * @param radiusOrEventOptions the radius or the options of the vortex
  127565. * @param strength the strength of the vortex
  127566. * @param height the height of the vortex
  127567. * @returns a Physics vortex event, or null
  127568. * A physics vortex event or null
  127569. */
  127570. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127571. }
  127572. /**
  127573. * Represents a physics radial explosion event
  127574. */
  127575. class PhysicsRadialExplosionEvent {
  127576. private _scene;
  127577. private _options;
  127578. private _sphere;
  127579. private _dataFetched;
  127580. /**
  127581. * Initializes a radial explosioin event
  127582. * @param _scene BabylonJS scene
  127583. * @param _options The options for the vortex event
  127584. */
  127585. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  127586. /**
  127587. * Returns the data related to the radial explosion event (sphere).
  127588. * @returns The radial explosion event data
  127589. */
  127590. getData(): PhysicsRadialExplosionEventData;
  127591. /**
  127592. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  127593. * @param impostor A physics imposter
  127594. * @param origin the origin of the explosion
  127595. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  127596. */
  127597. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  127598. /**
  127599. * Triggers affecterd impostors callbacks
  127600. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  127601. */
  127602. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  127603. /**
  127604. * Disposes the sphere.
  127605. * @param force Specifies if the sphere should be disposed by force
  127606. */
  127607. dispose(force?: boolean): void;
  127608. /*** Helpers ***/
  127609. private _prepareSphere;
  127610. private _intersectsWithSphere;
  127611. }
  127612. /**
  127613. * Represents a gravitational field event
  127614. */
  127615. class PhysicsGravitationalFieldEvent {
  127616. private _physicsHelper;
  127617. private _scene;
  127618. private _origin;
  127619. private _options;
  127620. private _tickCallback;
  127621. private _sphere;
  127622. private _dataFetched;
  127623. /**
  127624. * Initializes the physics gravitational field event
  127625. * @param _physicsHelper A physics helper
  127626. * @param _scene BabylonJS scene
  127627. * @param _origin The origin position of the gravitational field event
  127628. * @param _options The options for the vortex event
  127629. */
  127630. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  127631. /**
  127632. * Returns the data related to the gravitational field event (sphere).
  127633. * @returns A gravitational field event
  127634. */
  127635. getData(): PhysicsGravitationalFieldEventData;
  127636. /**
  127637. * Enables the gravitational field.
  127638. */
  127639. enable(): void;
  127640. /**
  127641. * Disables the gravitational field.
  127642. */
  127643. disable(): void;
  127644. /**
  127645. * Disposes the sphere.
  127646. * @param force The force to dispose from the gravitational field event
  127647. */
  127648. dispose(force?: boolean): void;
  127649. private _tick;
  127650. }
  127651. /**
  127652. * Represents a physics updraft event
  127653. */
  127654. class PhysicsUpdraftEvent {
  127655. private _scene;
  127656. private _origin;
  127657. private _options;
  127658. private _physicsEngine;
  127659. private _originTop;
  127660. private _originDirection;
  127661. private _tickCallback;
  127662. private _cylinder;
  127663. private _cylinderPosition;
  127664. private _dataFetched;
  127665. /**
  127666. * Initializes the physics updraft event
  127667. * @param _scene BabylonJS scene
  127668. * @param _origin The origin position of the updraft
  127669. * @param _options The options for the updraft event
  127670. */
  127671. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  127672. /**
  127673. * Returns the data related to the updraft event (cylinder).
  127674. * @returns A physics updraft event
  127675. */
  127676. getData(): PhysicsUpdraftEventData;
  127677. /**
  127678. * Enables the updraft.
  127679. */
  127680. enable(): void;
  127681. /**
  127682. * Disables the updraft.
  127683. */
  127684. disable(): void;
  127685. /**
  127686. * Disposes the cylinder.
  127687. * @param force Specifies if the updraft should be disposed by force
  127688. */
  127689. dispose(force?: boolean): void;
  127690. private getImpostorHitData;
  127691. private _tick;
  127692. /*** Helpers ***/
  127693. private _prepareCylinder;
  127694. private _intersectsWithCylinder;
  127695. }
  127696. /**
  127697. * Represents a physics vortex event
  127698. */
  127699. class PhysicsVortexEvent {
  127700. private _scene;
  127701. private _origin;
  127702. private _options;
  127703. private _physicsEngine;
  127704. private _originTop;
  127705. private _tickCallback;
  127706. private _cylinder;
  127707. private _cylinderPosition;
  127708. private _dataFetched;
  127709. /**
  127710. * Initializes the physics vortex event
  127711. * @param _scene The BabylonJS scene
  127712. * @param _origin The origin position of the vortex
  127713. * @param _options The options for the vortex event
  127714. */
  127715. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  127716. /**
  127717. * Returns the data related to the vortex event (cylinder).
  127718. * @returns The physics vortex event data
  127719. */
  127720. getData(): PhysicsVortexEventData;
  127721. /**
  127722. * Enables the vortex.
  127723. */
  127724. enable(): void;
  127725. /**
  127726. * Disables the cortex.
  127727. */
  127728. disable(): void;
  127729. /**
  127730. * Disposes the sphere.
  127731. * @param force
  127732. */
  127733. dispose(force?: boolean): void;
  127734. private getImpostorHitData;
  127735. private _tick;
  127736. /*** Helpers ***/
  127737. private _prepareCylinder;
  127738. private _intersectsWithCylinder;
  127739. }
  127740. /**
  127741. * Options fot the radial explosion event
  127742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127743. */
  127744. export class PhysicsRadialExplosionEventOptions {
  127745. /**
  127746. * The radius of the sphere for the radial explosion.
  127747. */
  127748. radius: number;
  127749. /**
  127750. * The strenth of the explosion.
  127751. */
  127752. strength: number;
  127753. /**
  127754. * The strenght of the force in correspondence to the distance of the affected object
  127755. */
  127756. falloff: PhysicsRadialImpulseFalloff;
  127757. /**
  127758. * Sphere options for the radial explosion.
  127759. */
  127760. sphere: {
  127761. segments: number;
  127762. diameter: number;
  127763. };
  127764. /**
  127765. * Sphere options for the radial explosion.
  127766. */
  127767. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  127768. }
  127769. /**
  127770. * Options fot the updraft event
  127771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127772. */
  127773. export class PhysicsUpdraftEventOptions {
  127774. /**
  127775. * The radius of the cylinder for the vortex
  127776. */
  127777. radius: number;
  127778. /**
  127779. * The strenth of the updraft.
  127780. */
  127781. strength: number;
  127782. /**
  127783. * The height of the cylinder for the updraft.
  127784. */
  127785. height: number;
  127786. /**
  127787. * The mode for the the updraft.
  127788. */
  127789. updraftMode: PhysicsUpdraftMode;
  127790. }
  127791. /**
  127792. * Options fot the vortex event
  127793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127794. */
  127795. export class PhysicsVortexEventOptions {
  127796. /**
  127797. * The radius of the cylinder for the vortex
  127798. */
  127799. radius: number;
  127800. /**
  127801. * The strenth of the vortex.
  127802. */
  127803. strength: number;
  127804. /**
  127805. * The height of the cylinder for the vortex.
  127806. */
  127807. height: number;
  127808. /**
  127809. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  127810. */
  127811. centripetalForceThreshold: number;
  127812. /**
  127813. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  127814. */
  127815. centripetalForceMultiplier: number;
  127816. /**
  127817. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  127818. */
  127819. centrifugalForceMultiplier: number;
  127820. /**
  127821. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  127822. */
  127823. updraftForceMultiplier: number;
  127824. }
  127825. /**
  127826. * The strenght of the force in correspondence to the distance of the affected object
  127827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127828. */
  127829. export enum PhysicsRadialImpulseFalloff {
  127830. /** Defines that impulse is constant in strength across it's whole radius */
  127831. Constant = 0,
  127832. /** Defines that impulse gets weaker if it's further from the origin */
  127833. Linear = 1
  127834. }
  127835. /**
  127836. * The strength of the force in correspondence to the distance of the affected object
  127837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127838. */
  127839. export enum PhysicsUpdraftMode {
  127840. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  127841. Center = 0,
  127842. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  127843. Perpendicular = 1
  127844. }
  127845. /**
  127846. * Interface for a physics hit data
  127847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127848. */
  127849. export interface PhysicsHitData {
  127850. /**
  127851. * The force applied at the contact point
  127852. */
  127853. force: Vector3;
  127854. /**
  127855. * The contact point
  127856. */
  127857. contactPoint: Vector3;
  127858. /**
  127859. * The distance from the origin to the contact point
  127860. */
  127861. distanceFromOrigin: number;
  127862. }
  127863. /**
  127864. * Interface for radial explosion event data
  127865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127866. */
  127867. export interface PhysicsRadialExplosionEventData {
  127868. /**
  127869. * A sphere used for the radial explosion event
  127870. */
  127871. sphere: Mesh;
  127872. }
  127873. /**
  127874. * Interface for gravitational field event data
  127875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127876. */
  127877. export interface PhysicsGravitationalFieldEventData {
  127878. /**
  127879. * A sphere mesh used for the gravitational field event
  127880. */
  127881. sphere: Mesh;
  127882. }
  127883. /**
  127884. * Interface for updraft event data
  127885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127886. */
  127887. export interface PhysicsUpdraftEventData {
  127888. /**
  127889. * A cylinder used for the updraft event
  127890. */
  127891. cylinder: Mesh;
  127892. }
  127893. /**
  127894. * Interface for vortex event data
  127895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127896. */
  127897. export interface PhysicsVortexEventData {
  127898. /**
  127899. * A cylinder used for the vortex event
  127900. */
  127901. cylinder: Mesh;
  127902. }
  127903. /**
  127904. * Interface for an affected physics impostor
  127905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127906. */
  127907. export interface PhysicsAffectedImpostorWithData {
  127908. /**
  127909. * The impostor affected by the effect
  127910. */
  127911. impostor: PhysicsImpostor;
  127912. /**
  127913. * The data about the hit/horce from the explosion
  127914. */
  127915. hitData: PhysicsHitData;
  127916. }
  127917. }
  127918. declare module BABYLON {
  127919. /** @hidden */
  127920. export var blackAndWhitePixelShader: {
  127921. name: string;
  127922. shader: string;
  127923. };
  127924. }
  127925. declare module BABYLON {
  127926. /**
  127927. * Post process used to render in black and white
  127928. */
  127929. export class BlackAndWhitePostProcess extends PostProcess {
  127930. /**
  127931. * Linear about to convert he result to black and white (default: 1)
  127932. */
  127933. degree: number;
  127934. /**
  127935. * Creates a black and white post process
  127936. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  127937. * @param name The name of the effect.
  127938. * @param options The required width/height ratio to downsize to before computing the render pass.
  127939. * @param camera The camera to apply the render pass to.
  127940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127941. * @param engine The engine which the post process will be applied. (default: current engine)
  127942. * @param reusable If the post process can be reused on the same frame. (default: false)
  127943. */
  127944. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127945. }
  127946. }
  127947. declare module BABYLON {
  127948. /**
  127949. * This represents a set of one or more post processes in Babylon.
  127950. * A post process can be used to apply a shader to a texture after it is rendered.
  127951. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127952. */
  127953. export class PostProcessRenderEffect {
  127954. private _postProcesses;
  127955. private _getPostProcesses;
  127956. private _singleInstance;
  127957. private _cameras;
  127958. private _indicesForCamera;
  127959. /**
  127960. * Name of the effect
  127961. * @hidden
  127962. */
  127963. _name: string;
  127964. /**
  127965. * Instantiates a post process render effect.
  127966. * A post process can be used to apply a shader to a texture after it is rendered.
  127967. * @param engine The engine the effect is tied to
  127968. * @param name The name of the effect
  127969. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  127970. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  127971. */
  127972. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  127973. /**
  127974. * Checks if all the post processes in the effect are supported.
  127975. */
  127976. readonly isSupported: boolean;
  127977. /**
  127978. * Updates the current state of the effect
  127979. * @hidden
  127980. */
  127981. _update(): void;
  127982. /**
  127983. * Attaches the effect on cameras
  127984. * @param cameras The camera to attach to.
  127985. * @hidden
  127986. */
  127987. _attachCameras(cameras: Camera): void;
  127988. /**
  127989. * Attaches the effect on cameras
  127990. * @param cameras The camera to attach to.
  127991. * @hidden
  127992. */
  127993. _attachCameras(cameras: Camera[]): void;
  127994. /**
  127995. * Detaches the effect on cameras
  127996. * @param cameras The camera to detatch from.
  127997. * @hidden
  127998. */
  127999. _detachCameras(cameras: Camera): void;
  128000. /**
  128001. * Detatches the effect on cameras
  128002. * @param cameras The camera to detatch from.
  128003. * @hidden
  128004. */
  128005. _detachCameras(cameras: Camera[]): void;
  128006. /**
  128007. * Enables the effect on given cameras
  128008. * @param cameras The camera to enable.
  128009. * @hidden
  128010. */
  128011. _enable(cameras: Camera): void;
  128012. /**
  128013. * Enables the effect on given cameras
  128014. * @param cameras The camera to enable.
  128015. * @hidden
  128016. */
  128017. _enable(cameras: Nullable<Camera[]>): void;
  128018. /**
  128019. * Disables the effect on the given cameras
  128020. * @param cameras The camera to disable.
  128021. * @hidden
  128022. */
  128023. _disable(cameras: Camera): void;
  128024. /**
  128025. * Disables the effect on the given cameras
  128026. * @param cameras The camera to disable.
  128027. * @hidden
  128028. */
  128029. _disable(cameras: Nullable<Camera[]>): void;
  128030. /**
  128031. * Gets a list of the post processes contained in the effect.
  128032. * @param camera The camera to get the post processes on.
  128033. * @returns The list of the post processes in the effect.
  128034. */
  128035. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  128036. }
  128037. }
  128038. declare module BABYLON {
  128039. /** @hidden */
  128040. export var extractHighlightsPixelShader: {
  128041. name: string;
  128042. shader: string;
  128043. };
  128044. }
  128045. declare module BABYLON {
  128046. /**
  128047. * 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.
  128048. */
  128049. export class ExtractHighlightsPostProcess extends PostProcess {
  128050. /**
  128051. * The luminance threshold, pixels below this value will be set to black.
  128052. */
  128053. threshold: number;
  128054. /** @hidden */
  128055. _exposure: number;
  128056. /**
  128057. * Post process which has the input texture to be used when performing highlight extraction
  128058. * @hidden
  128059. */
  128060. _inputPostProcess: Nullable<PostProcess>;
  128061. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128062. }
  128063. }
  128064. declare module BABYLON {
  128065. /** @hidden */
  128066. export var bloomMergePixelShader: {
  128067. name: string;
  128068. shader: string;
  128069. };
  128070. }
  128071. declare module BABYLON {
  128072. /**
  128073. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128074. */
  128075. export class BloomMergePostProcess extends PostProcess {
  128076. /** Weight of the bloom to be added to the original input. */
  128077. weight: number;
  128078. /**
  128079. * Creates a new instance of @see BloomMergePostProcess
  128080. * @param name The name of the effect.
  128081. * @param originalFromInput Post process which's input will be used for the merge.
  128082. * @param blurred Blurred highlights post process which's output will be used.
  128083. * @param weight Weight of the bloom to be added to the original input.
  128084. * @param options The required width/height ratio to downsize to before computing the render pass.
  128085. * @param camera The camera to apply the render pass to.
  128086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128087. * @param engine The engine which the post process will be applied. (default: current engine)
  128088. * @param reusable If the post process can be reused on the same frame. (default: false)
  128089. * @param textureType Type of textures used when performing the post process. (default: 0)
  128090. * @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)
  128091. */
  128092. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128093. /** Weight of the bloom to be added to the original input. */
  128094. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128095. }
  128096. }
  128097. declare module BABYLON {
  128098. /**
  128099. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128100. */
  128101. export class BloomEffect extends PostProcessRenderEffect {
  128102. private bloomScale;
  128103. /**
  128104. * @hidden Internal
  128105. */
  128106. _effects: Array<PostProcess>;
  128107. /**
  128108. * @hidden Internal
  128109. */
  128110. _downscale: ExtractHighlightsPostProcess;
  128111. private _blurX;
  128112. private _blurY;
  128113. private _merge;
  128114. /**
  128115. * The luminance threshold to find bright areas of the image to bloom.
  128116. */
  128117. threshold: number;
  128118. /**
  128119. * The strength of the bloom.
  128120. */
  128121. weight: number;
  128122. /**
  128123. * Specifies the size of the bloom blur kernel, relative to the final output size
  128124. */
  128125. kernel: number;
  128126. /**
  128127. * Creates a new instance of @see BloomEffect
  128128. * @param scene The scene the effect belongs to.
  128129. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128130. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128131. * @param bloomWeight The the strength of bloom.
  128132. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128133. * @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)
  128134. */
  128135. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128136. /**
  128137. * Disposes each of the internal effects for a given camera.
  128138. * @param camera The camera to dispose the effect on.
  128139. */
  128140. disposeEffects(camera: Camera): void;
  128141. /**
  128142. * @hidden Internal
  128143. */
  128144. _updateEffects(): void;
  128145. /**
  128146. * Internal
  128147. * @returns if all the contained post processes are ready.
  128148. * @hidden
  128149. */
  128150. _isReady(): boolean;
  128151. }
  128152. }
  128153. declare module BABYLON {
  128154. /** @hidden */
  128155. export var chromaticAberrationPixelShader: {
  128156. name: string;
  128157. shader: string;
  128158. };
  128159. }
  128160. declare module BABYLON {
  128161. /**
  128162. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128163. */
  128164. export class ChromaticAberrationPostProcess extends PostProcess {
  128165. /**
  128166. * The amount of seperation of rgb channels (default: 30)
  128167. */
  128168. aberrationAmount: number;
  128169. /**
  128170. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128171. */
  128172. radialIntensity: number;
  128173. /**
  128174. * 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))
  128175. */
  128176. direction: Vector2;
  128177. /**
  128178. * 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))
  128179. */
  128180. centerPosition: Vector2;
  128181. /**
  128182. * Creates a new instance ChromaticAberrationPostProcess
  128183. * @param name The name of the effect.
  128184. * @param screenWidth The width of the screen to apply the effect on.
  128185. * @param screenHeight The height of the screen to apply the effect on.
  128186. * @param options The required width/height ratio to downsize to before computing the render pass.
  128187. * @param camera The camera to apply the render pass to.
  128188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128189. * @param engine The engine which the post process will be applied. (default: current engine)
  128190. * @param reusable If the post process can be reused on the same frame. (default: false)
  128191. * @param textureType Type of textures used when performing the post process. (default: 0)
  128192. * @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)
  128193. */
  128194. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128195. }
  128196. }
  128197. declare module BABYLON {
  128198. /** @hidden */
  128199. export var circleOfConfusionPixelShader: {
  128200. name: string;
  128201. shader: string;
  128202. };
  128203. }
  128204. declare module BABYLON {
  128205. /**
  128206. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128207. */
  128208. export class CircleOfConfusionPostProcess extends PostProcess {
  128209. /**
  128210. * 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.
  128211. */
  128212. lensSize: number;
  128213. /**
  128214. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128215. */
  128216. fStop: number;
  128217. /**
  128218. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128219. */
  128220. focusDistance: number;
  128221. /**
  128222. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128223. */
  128224. focalLength: number;
  128225. private _depthTexture;
  128226. /**
  128227. * Creates a new instance CircleOfConfusionPostProcess
  128228. * @param name The name of the effect.
  128229. * @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.
  128230. * @param options The required width/height ratio to downsize to before computing the render pass.
  128231. * @param camera The camera to apply the render pass to.
  128232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128233. * @param engine The engine which the post process will be applied. (default: current engine)
  128234. * @param reusable If the post process can be reused on the same frame. (default: false)
  128235. * @param textureType Type of textures used when performing the post process. (default: 0)
  128236. * @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)
  128237. */
  128238. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128239. /**
  128240. * 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.
  128241. */
  128242. depthTexture: RenderTargetTexture;
  128243. }
  128244. }
  128245. declare module BABYLON {
  128246. /** @hidden */
  128247. export var colorCorrectionPixelShader: {
  128248. name: string;
  128249. shader: string;
  128250. };
  128251. }
  128252. declare module BABYLON {
  128253. /**
  128254. *
  128255. * This post-process allows the modification of rendered colors by using
  128256. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128257. *
  128258. * The object needs to be provided an url to a texture containing the color
  128259. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128260. * Use an image editing software to tweak the LUT to match your needs.
  128261. *
  128262. * For an example of a color LUT, see here:
  128263. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128264. * For explanations on color grading, see here:
  128265. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128266. *
  128267. */
  128268. export class ColorCorrectionPostProcess extends PostProcess {
  128269. private _colorTableTexture;
  128270. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128271. }
  128272. }
  128273. declare module BABYLON {
  128274. /** @hidden */
  128275. export var convolutionPixelShader: {
  128276. name: string;
  128277. shader: string;
  128278. };
  128279. }
  128280. declare module BABYLON {
  128281. /**
  128282. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128283. * input texture to perform effects such as edge detection or sharpening
  128284. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128285. */
  128286. export class ConvolutionPostProcess extends PostProcess {
  128287. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128288. kernel: number[];
  128289. /**
  128290. * Creates a new instance ConvolutionPostProcess
  128291. * @param name The name of the effect.
  128292. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128293. * @param options The required width/height ratio to downsize to before computing the render pass.
  128294. * @param camera The camera to apply the render pass to.
  128295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128296. * @param engine The engine which the post process will be applied. (default: current engine)
  128297. * @param reusable If the post process can be reused on the same frame. (default: false)
  128298. * @param textureType Type of textures used when performing the post process. (default: 0)
  128299. */
  128300. constructor(name: string,
  128301. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128302. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128303. /**
  128304. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128305. */
  128306. static EdgeDetect0Kernel: number[];
  128307. /**
  128308. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128309. */
  128310. static EdgeDetect1Kernel: number[];
  128311. /**
  128312. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128313. */
  128314. static EdgeDetect2Kernel: number[];
  128315. /**
  128316. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128317. */
  128318. static SharpenKernel: number[];
  128319. /**
  128320. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128321. */
  128322. static EmbossKernel: number[];
  128323. /**
  128324. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128325. */
  128326. static GaussianKernel: number[];
  128327. }
  128328. }
  128329. declare module BABYLON {
  128330. /**
  128331. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128332. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128333. * based on samples that have a large difference in distance than the center pixel.
  128334. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128335. */
  128336. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128337. direction: Vector2;
  128338. /**
  128339. * Creates a new instance CircleOfConfusionPostProcess
  128340. * @param name The name of the effect.
  128341. * @param scene The scene the effect belongs to.
  128342. * @param direction The direction the blur should be applied.
  128343. * @param kernel The size of the kernel used to blur.
  128344. * @param options The required width/height ratio to downsize to before computing the render pass.
  128345. * @param camera The camera to apply the render pass to.
  128346. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128347. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128349. * @param engine The engine which the post process will be applied. (default: current engine)
  128350. * @param reusable If the post process can be reused on the same frame. (default: false)
  128351. * @param textureType Type of textures used when performing the post process. (default: 0)
  128352. * @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)
  128353. */
  128354. 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);
  128355. }
  128356. }
  128357. declare module BABYLON {
  128358. /** @hidden */
  128359. export var depthOfFieldMergePixelShader: {
  128360. name: string;
  128361. shader: string;
  128362. };
  128363. }
  128364. declare module BABYLON {
  128365. /**
  128366. * Options to be set when merging outputs from the default pipeline.
  128367. */
  128368. export class DepthOfFieldMergePostProcessOptions {
  128369. /**
  128370. * The original image to merge on top of
  128371. */
  128372. originalFromInput: PostProcess;
  128373. /**
  128374. * Parameters to perform the merge of the depth of field effect
  128375. */
  128376. depthOfField?: {
  128377. circleOfConfusion: PostProcess;
  128378. blurSteps: Array<PostProcess>;
  128379. };
  128380. /**
  128381. * Parameters to perform the merge of bloom effect
  128382. */
  128383. bloom?: {
  128384. blurred: PostProcess;
  128385. weight: number;
  128386. };
  128387. }
  128388. /**
  128389. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128390. */
  128391. export class DepthOfFieldMergePostProcess extends PostProcess {
  128392. private blurSteps;
  128393. /**
  128394. * Creates a new instance of DepthOfFieldMergePostProcess
  128395. * @param name The name of the effect.
  128396. * @param originalFromInput Post process which's input will be used for the merge.
  128397. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128398. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128399. * @param options The required width/height ratio to downsize to before computing the render pass.
  128400. * @param camera The camera to apply the render pass to.
  128401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128402. * @param engine The engine which the post process will be applied. (default: current engine)
  128403. * @param reusable If the post process can be reused on the same frame. (default: false)
  128404. * @param textureType Type of textures used when performing the post process. (default: 0)
  128405. * @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)
  128406. */
  128407. 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);
  128408. /**
  128409. * Updates the effect with the current post process compile time values and recompiles the shader.
  128410. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128411. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128412. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128413. * @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
  128414. * @param onCompiled Called when the shader has been compiled.
  128415. * @param onError Called if there is an error when compiling a shader.
  128416. */
  128417. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128418. }
  128419. }
  128420. declare module BABYLON {
  128421. /**
  128422. * Specifies the level of max blur that should be applied when using the depth of field effect
  128423. */
  128424. export enum DepthOfFieldEffectBlurLevel {
  128425. /**
  128426. * Subtle blur
  128427. */
  128428. Low = 0,
  128429. /**
  128430. * Medium blur
  128431. */
  128432. Medium = 1,
  128433. /**
  128434. * Large blur
  128435. */
  128436. High = 2
  128437. }
  128438. /**
  128439. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128440. */
  128441. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128442. private _circleOfConfusion;
  128443. /**
  128444. * @hidden Internal, blurs from high to low
  128445. */
  128446. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128447. private _depthOfFieldBlurY;
  128448. private _dofMerge;
  128449. /**
  128450. * @hidden Internal post processes in depth of field effect
  128451. */
  128452. _effects: Array<PostProcess>;
  128453. /**
  128454. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128455. */
  128456. focalLength: number;
  128457. /**
  128458. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128459. */
  128460. fStop: number;
  128461. /**
  128462. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128463. */
  128464. focusDistance: number;
  128465. /**
  128466. * 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.
  128467. */
  128468. lensSize: number;
  128469. /**
  128470. * Creates a new instance DepthOfFieldEffect
  128471. * @param scene The scene the effect belongs to.
  128472. * @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.
  128473. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128474. * @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)
  128475. */
  128476. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128477. /**
  128478. * Get the current class name of the current effet
  128479. * @returns "DepthOfFieldEffect"
  128480. */
  128481. getClassName(): string;
  128482. /**
  128483. * 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.
  128484. */
  128485. depthTexture: RenderTargetTexture;
  128486. /**
  128487. * Disposes each of the internal effects for a given camera.
  128488. * @param camera The camera to dispose the effect on.
  128489. */
  128490. disposeEffects(camera: Camera): void;
  128491. /**
  128492. * @hidden Internal
  128493. */
  128494. _updateEffects(): void;
  128495. /**
  128496. * Internal
  128497. * @returns if all the contained post processes are ready.
  128498. * @hidden
  128499. */
  128500. _isReady(): boolean;
  128501. }
  128502. }
  128503. declare module BABYLON {
  128504. /** @hidden */
  128505. export var displayPassPixelShader: {
  128506. name: string;
  128507. shader: string;
  128508. };
  128509. }
  128510. declare module BABYLON {
  128511. /**
  128512. * DisplayPassPostProcess which produces an output the same as it's input
  128513. */
  128514. export class DisplayPassPostProcess extends PostProcess {
  128515. /**
  128516. * Creates the DisplayPassPostProcess
  128517. * @param name The name of the effect.
  128518. * @param options The required width/height ratio to downsize to before computing the render pass.
  128519. * @param camera The camera to apply the render pass to.
  128520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128521. * @param engine The engine which the post process will be applied. (default: current engine)
  128522. * @param reusable If the post process can be reused on the same frame. (default: false)
  128523. */
  128524. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128525. }
  128526. }
  128527. declare module BABYLON {
  128528. /** @hidden */
  128529. export var filterPixelShader: {
  128530. name: string;
  128531. shader: string;
  128532. };
  128533. }
  128534. declare module BABYLON {
  128535. /**
  128536. * Applies a kernel filter to the image
  128537. */
  128538. export class FilterPostProcess extends PostProcess {
  128539. /** The matrix to be applied to the image */
  128540. kernelMatrix: Matrix;
  128541. /**
  128542. *
  128543. * @param name The name of the effect.
  128544. * @param kernelMatrix The matrix to be applied to the image
  128545. * @param options The required width/height ratio to downsize to before computing the render pass.
  128546. * @param camera The camera to apply the render pass to.
  128547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128548. * @param engine The engine which the post process will be applied. (default: current engine)
  128549. * @param reusable If the post process can be reused on the same frame. (default: false)
  128550. */
  128551. constructor(name: string,
  128552. /** The matrix to be applied to the image */
  128553. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128554. }
  128555. }
  128556. declare module BABYLON {
  128557. /** @hidden */
  128558. export var fxaaPixelShader: {
  128559. name: string;
  128560. shader: string;
  128561. };
  128562. }
  128563. declare module BABYLON {
  128564. /** @hidden */
  128565. export var fxaaVertexShader: {
  128566. name: string;
  128567. shader: string;
  128568. };
  128569. }
  128570. declare module BABYLON {
  128571. /**
  128572. * Fxaa post process
  128573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  128574. */
  128575. export class FxaaPostProcess extends PostProcess {
  128576. /** @hidden */
  128577. texelWidth: number;
  128578. /** @hidden */
  128579. texelHeight: number;
  128580. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128581. private _getDefines;
  128582. }
  128583. }
  128584. declare module BABYLON {
  128585. /** @hidden */
  128586. export var grainPixelShader: {
  128587. name: string;
  128588. shader: string;
  128589. };
  128590. }
  128591. declare module BABYLON {
  128592. /**
  128593. * The GrainPostProcess adds noise to the image at mid luminance levels
  128594. */
  128595. export class GrainPostProcess extends PostProcess {
  128596. /**
  128597. * The intensity of the grain added (default: 30)
  128598. */
  128599. intensity: number;
  128600. /**
  128601. * If the grain should be randomized on every frame
  128602. */
  128603. animated: boolean;
  128604. /**
  128605. * Creates a new instance of @see GrainPostProcess
  128606. * @param name The name of the effect.
  128607. * @param options The required width/height ratio to downsize to before computing the render pass.
  128608. * @param camera The camera to apply the render pass to.
  128609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128610. * @param engine The engine which the post process will be applied. (default: current engine)
  128611. * @param reusable If the post process can be reused on the same frame. (default: false)
  128612. * @param textureType Type of textures used when performing the post process. (default: 0)
  128613. * @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)
  128614. */
  128615. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128616. }
  128617. }
  128618. declare module BABYLON {
  128619. /** @hidden */
  128620. export var highlightsPixelShader: {
  128621. name: string;
  128622. shader: string;
  128623. };
  128624. }
  128625. declare module BABYLON {
  128626. /**
  128627. * Extracts highlights from the image
  128628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128629. */
  128630. export class HighlightsPostProcess extends PostProcess {
  128631. /**
  128632. * Extracts highlights from the image
  128633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128634. * @param name The name of the effect.
  128635. * @param options The required width/height ratio to downsize to before computing the render pass.
  128636. * @param camera The camera to apply the render pass to.
  128637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128638. * @param engine The engine which the post process will be applied. (default: current engine)
  128639. * @param reusable If the post process can be reused on the same frame. (default: false)
  128640. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  128641. */
  128642. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128643. }
  128644. }
  128645. declare module BABYLON {
  128646. /** @hidden */
  128647. export var mrtFragmentDeclaration: {
  128648. name: string;
  128649. shader: string;
  128650. };
  128651. }
  128652. declare module BABYLON {
  128653. /** @hidden */
  128654. export var geometryPixelShader: {
  128655. name: string;
  128656. shader: string;
  128657. };
  128658. }
  128659. declare module BABYLON {
  128660. /** @hidden */
  128661. export var geometryVertexShader: {
  128662. name: string;
  128663. shader: string;
  128664. };
  128665. }
  128666. declare module BABYLON {
  128667. /** @hidden */
  128668. interface ISavedTransformationMatrix {
  128669. world: Matrix;
  128670. viewProjection: Matrix;
  128671. }
  128672. /**
  128673. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  128674. */
  128675. export class GeometryBufferRenderer {
  128676. /**
  128677. * Constant used to retrieve the position texture index in the G-Buffer textures array
  128678. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  128679. */
  128680. static readonly POSITION_TEXTURE_TYPE: number;
  128681. /**
  128682. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  128683. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  128684. */
  128685. static readonly VELOCITY_TEXTURE_TYPE: number;
  128686. /**
  128687. * Dictionary used to store the previous transformation matrices of each rendered mesh
  128688. * in order to compute objects velocities when enableVelocity is set to "true"
  128689. * @hidden
  128690. */
  128691. _previousTransformationMatrices: {
  128692. [index: number]: ISavedTransformationMatrix;
  128693. };
  128694. /**
  128695. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  128696. * in order to compute objects velocities when enableVelocity is set to "true"
  128697. * @hidden
  128698. */
  128699. _previousBonesTransformationMatrices: {
  128700. [index: number]: Float32Array;
  128701. };
  128702. /**
  128703. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  128704. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  128705. */
  128706. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  128707. private _scene;
  128708. private _multiRenderTarget;
  128709. private _ratio;
  128710. private _enablePosition;
  128711. private _enableVelocity;
  128712. private _positionIndex;
  128713. private _velocityIndex;
  128714. protected _effect: Effect;
  128715. protected _cachedDefines: string;
  128716. /**
  128717. * Set the render list (meshes to be rendered) used in the G buffer.
  128718. */
  128719. renderList: Mesh[];
  128720. /**
  128721. * Gets wether or not G buffer are supported by the running hardware.
  128722. * This requires draw buffer supports
  128723. */
  128724. readonly isSupported: boolean;
  128725. /**
  128726. * Returns the index of the given texture type in the G-Buffer textures array
  128727. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  128728. * @returns the index of the given texture type in the G-Buffer textures array
  128729. */
  128730. getTextureIndex(textureType: number): number;
  128731. /**
  128732. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  128733. */
  128734. /**
  128735. * Sets whether or not objects positions are enabled for the G buffer.
  128736. */
  128737. enablePosition: boolean;
  128738. /**
  128739. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  128740. */
  128741. /**
  128742. * Sets wether or not objects velocities are enabled for the G buffer.
  128743. */
  128744. enableVelocity: boolean;
  128745. /**
  128746. * Gets the scene associated with the buffer.
  128747. */
  128748. readonly scene: Scene;
  128749. /**
  128750. * Gets the ratio used by the buffer during its creation.
  128751. * How big is the buffer related to the main canvas.
  128752. */
  128753. readonly ratio: number;
  128754. /** @hidden */
  128755. static _SceneComponentInitialization: (scene: Scene) => void;
  128756. /**
  128757. * Creates a new G Buffer for the scene
  128758. * @param scene The scene the buffer belongs to
  128759. * @param ratio How big is the buffer related to the main canvas.
  128760. */
  128761. constructor(scene: Scene, ratio?: number);
  128762. /**
  128763. * Checks wether everything is ready to render a submesh to the G buffer.
  128764. * @param subMesh the submesh to check readiness for
  128765. * @param useInstances is the mesh drawn using instance or not
  128766. * @returns true if ready otherwise false
  128767. */
  128768. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128769. /**
  128770. * Gets the current underlying G Buffer.
  128771. * @returns the buffer
  128772. */
  128773. getGBuffer(): MultiRenderTarget;
  128774. /**
  128775. * Gets the number of samples used to render the buffer (anti aliasing).
  128776. */
  128777. /**
  128778. * Sets the number of samples used to render the buffer (anti aliasing).
  128779. */
  128780. samples: number;
  128781. /**
  128782. * Disposes the renderer and frees up associated resources.
  128783. */
  128784. dispose(): void;
  128785. protected _createRenderTargets(): void;
  128786. private _copyBonesTransformationMatrices;
  128787. }
  128788. }
  128789. declare module BABYLON {
  128790. interface Scene {
  128791. /** @hidden (Backing field) */
  128792. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128793. /**
  128794. * Gets or Sets the current geometry buffer associated to the scene.
  128795. */
  128796. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128797. /**
  128798. * Enables a GeometryBufferRender and associates it with the scene
  128799. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  128800. * @returns the GeometryBufferRenderer
  128801. */
  128802. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  128803. /**
  128804. * Disables the GeometryBufferRender associated with the scene
  128805. */
  128806. disableGeometryBufferRenderer(): void;
  128807. }
  128808. /**
  128809. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  128810. * in several rendering techniques.
  128811. */
  128812. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  128813. /**
  128814. * The component name helpful to identify the component in the list of scene components.
  128815. */
  128816. readonly name: string;
  128817. /**
  128818. * The scene the component belongs to.
  128819. */
  128820. scene: Scene;
  128821. /**
  128822. * Creates a new instance of the component for the given scene
  128823. * @param scene Defines the scene to register the component in
  128824. */
  128825. constructor(scene: Scene);
  128826. /**
  128827. * Registers the component in a given scene
  128828. */
  128829. register(): void;
  128830. /**
  128831. * Rebuilds the elements related to this component in case of
  128832. * context lost for instance.
  128833. */
  128834. rebuild(): void;
  128835. /**
  128836. * Disposes the component and the associated ressources
  128837. */
  128838. dispose(): void;
  128839. private _gatherRenderTargets;
  128840. }
  128841. }
  128842. declare module BABYLON {
  128843. /** @hidden */
  128844. export var motionBlurPixelShader: {
  128845. name: string;
  128846. shader: string;
  128847. };
  128848. }
  128849. declare module BABYLON {
  128850. /**
  128851. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  128852. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  128853. * As an example, all you have to do is to create the post-process:
  128854. * var mb = new BABYLON.MotionBlurPostProcess(
  128855. * 'mb', // The name of the effect.
  128856. * scene, // The scene containing the objects to blur according to their velocity.
  128857. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  128858. * camera // The camera to apply the render pass to.
  128859. * );
  128860. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  128861. */
  128862. export class MotionBlurPostProcess extends PostProcess {
  128863. /**
  128864. * Defines how much the image is blurred by the movement. Default value is equal to 1
  128865. */
  128866. motionStrength: number;
  128867. /**
  128868. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  128869. */
  128870. /**
  128871. * Sets the number of iterations to be used for motion blur quality
  128872. */
  128873. motionBlurSamples: number;
  128874. private _motionBlurSamples;
  128875. private _geometryBufferRenderer;
  128876. /**
  128877. * Creates a new instance MotionBlurPostProcess
  128878. * @param name The name of the effect.
  128879. * @param scene The scene containing the objects to blur according to their velocity.
  128880. * @param options The required width/height ratio to downsize to before computing the render pass.
  128881. * @param camera The camera to apply the render pass to.
  128882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128883. * @param engine The engine which the post process will be applied. (default: current engine)
  128884. * @param reusable If the post process can be reused on the same frame. (default: false)
  128885. * @param textureType Type of textures used when performing the post process. (default: 0)
  128886. * @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)
  128887. */
  128888. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128889. /**
  128890. * Excludes the given skinned mesh from computing bones velocities.
  128891. * 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.
  128892. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  128893. */
  128894. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128895. /**
  128896. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  128897. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  128898. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  128899. */
  128900. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128901. /**
  128902. * Disposes the post process.
  128903. * @param camera The camera to dispose the post process on.
  128904. */
  128905. dispose(camera?: Camera): void;
  128906. }
  128907. }
  128908. declare module BABYLON {
  128909. /** @hidden */
  128910. export var refractionPixelShader: {
  128911. name: string;
  128912. shader: string;
  128913. };
  128914. }
  128915. declare module BABYLON {
  128916. /**
  128917. * Post process which applies a refractin texture
  128918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128919. */
  128920. export class RefractionPostProcess extends PostProcess {
  128921. /** the base color of the refraction (used to taint the rendering) */
  128922. color: Color3;
  128923. /** simulated refraction depth */
  128924. depth: number;
  128925. /** the coefficient of the base color (0 to remove base color tainting) */
  128926. colorLevel: number;
  128927. private _refTexture;
  128928. private _ownRefractionTexture;
  128929. /**
  128930. * Gets or sets the refraction texture
  128931. * Please note that you are responsible for disposing the texture if you set it manually
  128932. */
  128933. refractionTexture: Texture;
  128934. /**
  128935. * Initializes the RefractionPostProcess
  128936. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128937. * @param name The name of the effect.
  128938. * @param refractionTextureUrl Url of the refraction texture to use
  128939. * @param color the base color of the refraction (used to taint the rendering)
  128940. * @param depth simulated refraction depth
  128941. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  128942. * @param camera The camera to apply the render pass to.
  128943. * @param options The required width/height ratio to downsize to before computing the render pass.
  128944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128945. * @param engine The engine which the post process will be applied. (default: current engine)
  128946. * @param reusable If the post process can be reused on the same frame. (default: false)
  128947. */
  128948. constructor(name: string, refractionTextureUrl: string,
  128949. /** the base color of the refraction (used to taint the rendering) */
  128950. color: Color3,
  128951. /** simulated refraction depth */
  128952. depth: number,
  128953. /** the coefficient of the base color (0 to remove base color tainting) */
  128954. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128955. /**
  128956. * Disposes of the post process
  128957. * @param camera Camera to dispose post process on
  128958. */
  128959. dispose(camera: Camera): void;
  128960. }
  128961. }
  128962. declare module BABYLON {
  128963. /** @hidden */
  128964. export var sharpenPixelShader: {
  128965. name: string;
  128966. shader: string;
  128967. };
  128968. }
  128969. declare module BABYLON {
  128970. /**
  128971. * The SharpenPostProcess applies a sharpen kernel to every pixel
  128972. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128973. */
  128974. export class SharpenPostProcess extends PostProcess {
  128975. /**
  128976. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  128977. */
  128978. colorAmount: number;
  128979. /**
  128980. * How much sharpness should be applied (default: 0.3)
  128981. */
  128982. edgeAmount: number;
  128983. /**
  128984. * Creates a new instance ConvolutionPostProcess
  128985. * @param name The name of the effect.
  128986. * @param options The required width/height ratio to downsize to before computing the render pass.
  128987. * @param camera The camera to apply the render pass to.
  128988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128989. * @param engine The engine which the post process will be applied. (default: current engine)
  128990. * @param reusable If the post process can be reused on the same frame. (default: false)
  128991. * @param textureType Type of textures used when performing the post process. (default: 0)
  128992. * @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)
  128993. */
  128994. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128995. }
  128996. }
  128997. declare module BABYLON {
  128998. /**
  128999. * PostProcessRenderPipeline
  129000. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129001. */
  129002. export class PostProcessRenderPipeline {
  129003. private engine;
  129004. private _renderEffects;
  129005. private _renderEffectsForIsolatedPass;
  129006. /**
  129007. * List of inspectable custom properties (used by the Inspector)
  129008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  129009. */
  129010. inspectableCustomProperties: IInspectable[];
  129011. /**
  129012. * @hidden
  129013. */
  129014. protected _cameras: Camera[];
  129015. /** @hidden */
  129016. _name: string;
  129017. /**
  129018. * Gets pipeline name
  129019. */
  129020. readonly name: string;
  129021. /** Gets the list of attached cameras */
  129022. readonly cameras: Camera[];
  129023. /**
  129024. * Initializes a PostProcessRenderPipeline
  129025. * @param engine engine to add the pipeline to
  129026. * @param name name of the pipeline
  129027. */
  129028. constructor(engine: Engine, name: string);
  129029. /**
  129030. * Gets the class name
  129031. * @returns "PostProcessRenderPipeline"
  129032. */
  129033. getClassName(): string;
  129034. /**
  129035. * If all the render effects in the pipeline are supported
  129036. */
  129037. readonly isSupported: boolean;
  129038. /**
  129039. * Adds an effect to the pipeline
  129040. * @param renderEffect the effect to add
  129041. */
  129042. addEffect(renderEffect: PostProcessRenderEffect): void;
  129043. /** @hidden */
  129044. _rebuild(): void;
  129045. /** @hidden */
  129046. _enableEffect(renderEffectName: string, cameras: Camera): void;
  129047. /** @hidden */
  129048. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  129049. /** @hidden */
  129050. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129051. /** @hidden */
  129052. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129053. /** @hidden */
  129054. _attachCameras(cameras: Camera, unique: boolean): void;
  129055. /** @hidden */
  129056. _attachCameras(cameras: Camera[], unique: boolean): void;
  129057. /** @hidden */
  129058. _detachCameras(cameras: Camera): void;
  129059. /** @hidden */
  129060. _detachCameras(cameras: Nullable<Camera[]>): void;
  129061. /** @hidden */
  129062. _update(): void;
  129063. /** @hidden */
  129064. _reset(): void;
  129065. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129066. /**
  129067. * Disposes of the pipeline
  129068. */
  129069. dispose(): void;
  129070. }
  129071. }
  129072. declare module BABYLON {
  129073. /**
  129074. * PostProcessRenderPipelineManager class
  129075. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129076. */
  129077. export class PostProcessRenderPipelineManager {
  129078. private _renderPipelines;
  129079. /**
  129080. * Initializes a PostProcessRenderPipelineManager
  129081. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129082. */
  129083. constructor();
  129084. /**
  129085. * Gets the list of supported render pipelines
  129086. */
  129087. readonly supportedPipelines: PostProcessRenderPipeline[];
  129088. /**
  129089. * Adds a pipeline to the manager
  129090. * @param renderPipeline The pipeline to add
  129091. */
  129092. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129093. /**
  129094. * Attaches a camera to the pipeline
  129095. * @param renderPipelineName The name of the pipeline to attach to
  129096. * @param cameras the camera to attach
  129097. * @param unique if the camera can be attached multiple times to the pipeline
  129098. */
  129099. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129100. /**
  129101. * Detaches a camera from the pipeline
  129102. * @param renderPipelineName The name of the pipeline to detach from
  129103. * @param cameras the camera to detach
  129104. */
  129105. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129106. /**
  129107. * Enables an effect by name on a pipeline
  129108. * @param renderPipelineName the name of the pipeline to enable the effect in
  129109. * @param renderEffectName the name of the effect to enable
  129110. * @param cameras the cameras that the effect should be enabled on
  129111. */
  129112. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129113. /**
  129114. * Disables an effect by name on a pipeline
  129115. * @param renderPipelineName the name of the pipeline to disable the effect in
  129116. * @param renderEffectName the name of the effect to disable
  129117. * @param cameras the cameras that the effect should be disabled on
  129118. */
  129119. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129120. /**
  129121. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129122. */
  129123. update(): void;
  129124. /** @hidden */
  129125. _rebuild(): void;
  129126. /**
  129127. * Disposes of the manager and pipelines
  129128. */
  129129. dispose(): void;
  129130. }
  129131. }
  129132. declare module BABYLON {
  129133. interface Scene {
  129134. /** @hidden (Backing field) */
  129135. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129136. /**
  129137. * Gets the postprocess render pipeline manager
  129138. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129139. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129140. */
  129141. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129142. }
  129143. /**
  129144. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129145. */
  129146. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129147. /**
  129148. * The component name helpfull to identify the component in the list of scene components.
  129149. */
  129150. readonly name: string;
  129151. /**
  129152. * The scene the component belongs to.
  129153. */
  129154. scene: Scene;
  129155. /**
  129156. * Creates a new instance of the component for the given scene
  129157. * @param scene Defines the scene to register the component in
  129158. */
  129159. constructor(scene: Scene);
  129160. /**
  129161. * Registers the component in a given scene
  129162. */
  129163. register(): void;
  129164. /**
  129165. * Rebuilds the elements related to this component in case of
  129166. * context lost for instance.
  129167. */
  129168. rebuild(): void;
  129169. /**
  129170. * Disposes the component and the associated ressources
  129171. */
  129172. dispose(): void;
  129173. private _gatherRenderTargets;
  129174. }
  129175. }
  129176. declare module BABYLON {
  129177. /**
  129178. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129179. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129180. */
  129181. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129182. private _scene;
  129183. private _camerasToBeAttached;
  129184. /**
  129185. * ID of the sharpen post process,
  129186. */
  129187. private readonly SharpenPostProcessId;
  129188. /**
  129189. * @ignore
  129190. * ID of the image processing post process;
  129191. */
  129192. readonly ImageProcessingPostProcessId: string;
  129193. /**
  129194. * @ignore
  129195. * ID of the Fast Approximate Anti-Aliasing post process;
  129196. */
  129197. readonly FxaaPostProcessId: string;
  129198. /**
  129199. * ID of the chromatic aberration post process,
  129200. */
  129201. private readonly ChromaticAberrationPostProcessId;
  129202. /**
  129203. * ID of the grain post process
  129204. */
  129205. private readonly GrainPostProcessId;
  129206. /**
  129207. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129208. */
  129209. sharpen: SharpenPostProcess;
  129210. private _sharpenEffect;
  129211. private bloom;
  129212. /**
  129213. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129214. */
  129215. depthOfField: DepthOfFieldEffect;
  129216. /**
  129217. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129218. */
  129219. fxaa: FxaaPostProcess;
  129220. /**
  129221. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129222. */
  129223. imageProcessing: ImageProcessingPostProcess;
  129224. /**
  129225. * Chromatic aberration post process which will shift rgb colors in the image
  129226. */
  129227. chromaticAberration: ChromaticAberrationPostProcess;
  129228. private _chromaticAberrationEffect;
  129229. /**
  129230. * Grain post process which add noise to the image
  129231. */
  129232. grain: GrainPostProcess;
  129233. private _grainEffect;
  129234. /**
  129235. * Glow post process which adds a glow to emissive areas of the image
  129236. */
  129237. private _glowLayer;
  129238. /**
  129239. * Animations which can be used to tweak settings over a period of time
  129240. */
  129241. animations: Animation[];
  129242. private _imageProcessingConfigurationObserver;
  129243. private _sharpenEnabled;
  129244. private _bloomEnabled;
  129245. private _depthOfFieldEnabled;
  129246. private _depthOfFieldBlurLevel;
  129247. private _fxaaEnabled;
  129248. private _imageProcessingEnabled;
  129249. private _defaultPipelineTextureType;
  129250. private _bloomScale;
  129251. private _chromaticAberrationEnabled;
  129252. private _grainEnabled;
  129253. private _buildAllowed;
  129254. /**
  129255. * Gets active scene
  129256. */
  129257. readonly scene: Scene;
  129258. /**
  129259. * Enable or disable the sharpen process from the pipeline
  129260. */
  129261. sharpenEnabled: boolean;
  129262. private _resizeObserver;
  129263. private _hardwareScaleLevel;
  129264. private _bloomKernel;
  129265. /**
  129266. * Specifies the size of the bloom blur kernel, relative to the final output size
  129267. */
  129268. bloomKernel: number;
  129269. /**
  129270. * Specifies the weight of the bloom in the final rendering
  129271. */
  129272. private _bloomWeight;
  129273. /**
  129274. * Specifies the luma threshold for the area that will be blurred by the bloom
  129275. */
  129276. private _bloomThreshold;
  129277. private _hdr;
  129278. /**
  129279. * The strength of the bloom.
  129280. */
  129281. bloomWeight: number;
  129282. /**
  129283. * The strength of the bloom.
  129284. */
  129285. bloomThreshold: number;
  129286. /**
  129287. * The scale of the bloom, lower value will provide better performance.
  129288. */
  129289. bloomScale: number;
  129290. /**
  129291. * Enable or disable the bloom from the pipeline
  129292. */
  129293. bloomEnabled: boolean;
  129294. private _rebuildBloom;
  129295. /**
  129296. * If the depth of field is enabled.
  129297. */
  129298. depthOfFieldEnabled: boolean;
  129299. /**
  129300. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129301. */
  129302. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129303. /**
  129304. * If the anti aliasing is enabled.
  129305. */
  129306. fxaaEnabled: boolean;
  129307. private _samples;
  129308. /**
  129309. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129310. */
  129311. samples: number;
  129312. /**
  129313. * If image processing is enabled.
  129314. */
  129315. imageProcessingEnabled: boolean;
  129316. /**
  129317. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129318. */
  129319. glowLayerEnabled: boolean;
  129320. /**
  129321. * Gets the glow layer (or null if not defined)
  129322. */
  129323. readonly glowLayer: Nullable<GlowLayer>;
  129324. /**
  129325. * Enable or disable the chromaticAberration process from the pipeline
  129326. */
  129327. chromaticAberrationEnabled: boolean;
  129328. /**
  129329. * Enable or disable the grain process from the pipeline
  129330. */
  129331. grainEnabled: boolean;
  129332. /**
  129333. * @constructor
  129334. * @param name - The rendering pipeline name (default: "")
  129335. * @param hdr - If high dynamic range textures should be used (default: true)
  129336. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129337. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129338. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129339. */
  129340. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129341. /**
  129342. * Get the class name
  129343. * @returns "DefaultRenderingPipeline"
  129344. */
  129345. getClassName(): string;
  129346. /**
  129347. * Force the compilation of the entire pipeline.
  129348. */
  129349. prepare(): void;
  129350. private _hasCleared;
  129351. private _prevPostProcess;
  129352. private _prevPrevPostProcess;
  129353. private _setAutoClearAndTextureSharing;
  129354. private _depthOfFieldSceneObserver;
  129355. private _buildPipeline;
  129356. private _disposePostProcesses;
  129357. /**
  129358. * Adds a camera to the pipeline
  129359. * @param camera the camera to be added
  129360. */
  129361. addCamera(camera: Camera): void;
  129362. /**
  129363. * Removes a camera from the pipeline
  129364. * @param camera the camera to remove
  129365. */
  129366. removeCamera(camera: Camera): void;
  129367. /**
  129368. * Dispose of the pipeline and stop all post processes
  129369. */
  129370. dispose(): void;
  129371. /**
  129372. * Serialize the rendering pipeline (Used when exporting)
  129373. * @returns the serialized object
  129374. */
  129375. serialize(): any;
  129376. /**
  129377. * Parse the serialized pipeline
  129378. * @param source Source pipeline.
  129379. * @param scene The scene to load the pipeline to.
  129380. * @param rootUrl The URL of the serialized pipeline.
  129381. * @returns An instantiated pipeline from the serialized object.
  129382. */
  129383. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129384. }
  129385. }
  129386. declare module BABYLON {
  129387. /** @hidden */
  129388. export var lensHighlightsPixelShader: {
  129389. name: string;
  129390. shader: string;
  129391. };
  129392. }
  129393. declare module BABYLON {
  129394. /** @hidden */
  129395. export var depthOfFieldPixelShader: {
  129396. name: string;
  129397. shader: string;
  129398. };
  129399. }
  129400. declare module BABYLON {
  129401. /**
  129402. * BABYLON.JS Chromatic Aberration GLSL Shader
  129403. * Author: Olivier Guyot
  129404. * Separates very slightly R, G and B colors on the edges of the screen
  129405. * Inspired by Francois Tarlier & Martins Upitis
  129406. */
  129407. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129408. /**
  129409. * @ignore
  129410. * The chromatic aberration PostProcess id in the pipeline
  129411. */
  129412. LensChromaticAberrationEffect: string;
  129413. /**
  129414. * @ignore
  129415. * The highlights enhancing PostProcess id in the pipeline
  129416. */
  129417. HighlightsEnhancingEffect: string;
  129418. /**
  129419. * @ignore
  129420. * The depth-of-field PostProcess id in the pipeline
  129421. */
  129422. LensDepthOfFieldEffect: string;
  129423. private _scene;
  129424. private _depthTexture;
  129425. private _grainTexture;
  129426. private _chromaticAberrationPostProcess;
  129427. private _highlightsPostProcess;
  129428. private _depthOfFieldPostProcess;
  129429. private _edgeBlur;
  129430. private _grainAmount;
  129431. private _chromaticAberration;
  129432. private _distortion;
  129433. private _highlightsGain;
  129434. private _highlightsThreshold;
  129435. private _dofDistance;
  129436. private _dofAperture;
  129437. private _dofDarken;
  129438. private _dofPentagon;
  129439. private _blurNoise;
  129440. /**
  129441. * @constructor
  129442. *
  129443. * Effect parameters are as follow:
  129444. * {
  129445. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129446. * edge_blur: number; // from 0 to x (1 for realism)
  129447. * distortion: number; // from 0 to x (1 for realism)
  129448. * grain_amount: number; // from 0 to 1
  129449. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129450. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129451. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129452. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129453. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129454. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129455. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129456. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129457. * }
  129458. * Note: if an effect parameter is unset, effect is disabled
  129459. *
  129460. * @param name The rendering pipeline name
  129461. * @param parameters - An object containing all parameters (see above)
  129462. * @param scene The scene linked to this pipeline
  129463. * @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)
  129464. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129465. */
  129466. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129467. /**
  129468. * Get the class name
  129469. * @returns "LensRenderingPipeline"
  129470. */
  129471. getClassName(): string;
  129472. /**
  129473. * Gets associated scene
  129474. */
  129475. readonly scene: Scene;
  129476. /**
  129477. * Gets or sets the edge blur
  129478. */
  129479. edgeBlur: number;
  129480. /**
  129481. * Gets or sets the grain amount
  129482. */
  129483. grainAmount: number;
  129484. /**
  129485. * Gets or sets the chromatic aberration amount
  129486. */
  129487. chromaticAberration: number;
  129488. /**
  129489. * Gets or sets the depth of field aperture
  129490. */
  129491. dofAperture: number;
  129492. /**
  129493. * Gets or sets the edge distortion
  129494. */
  129495. edgeDistortion: number;
  129496. /**
  129497. * Gets or sets the depth of field distortion
  129498. */
  129499. dofDistortion: number;
  129500. /**
  129501. * Gets or sets the darken out of focus amount
  129502. */
  129503. darkenOutOfFocus: number;
  129504. /**
  129505. * Gets or sets a boolean indicating if blur noise is enabled
  129506. */
  129507. blurNoise: boolean;
  129508. /**
  129509. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129510. */
  129511. pentagonBokeh: boolean;
  129512. /**
  129513. * Gets or sets the highlight grain amount
  129514. */
  129515. highlightsGain: number;
  129516. /**
  129517. * Gets or sets the highlight threshold
  129518. */
  129519. highlightsThreshold: number;
  129520. /**
  129521. * Sets the amount of blur at the edges
  129522. * @param amount blur amount
  129523. */
  129524. setEdgeBlur(amount: number): void;
  129525. /**
  129526. * Sets edge blur to 0
  129527. */
  129528. disableEdgeBlur(): void;
  129529. /**
  129530. * Sets the amout of grain
  129531. * @param amount Amount of grain
  129532. */
  129533. setGrainAmount(amount: number): void;
  129534. /**
  129535. * Set grain amount to 0
  129536. */
  129537. disableGrain(): void;
  129538. /**
  129539. * Sets the chromatic aberration amount
  129540. * @param amount amount of chromatic aberration
  129541. */
  129542. setChromaticAberration(amount: number): void;
  129543. /**
  129544. * Sets chromatic aberration amount to 0
  129545. */
  129546. disableChromaticAberration(): void;
  129547. /**
  129548. * Sets the EdgeDistortion amount
  129549. * @param amount amount of EdgeDistortion
  129550. */
  129551. setEdgeDistortion(amount: number): void;
  129552. /**
  129553. * Sets edge distortion to 0
  129554. */
  129555. disableEdgeDistortion(): void;
  129556. /**
  129557. * Sets the FocusDistance amount
  129558. * @param amount amount of FocusDistance
  129559. */
  129560. setFocusDistance(amount: number): void;
  129561. /**
  129562. * Disables depth of field
  129563. */
  129564. disableDepthOfField(): void;
  129565. /**
  129566. * Sets the Aperture amount
  129567. * @param amount amount of Aperture
  129568. */
  129569. setAperture(amount: number): void;
  129570. /**
  129571. * Sets the DarkenOutOfFocus amount
  129572. * @param amount amount of DarkenOutOfFocus
  129573. */
  129574. setDarkenOutOfFocus(amount: number): void;
  129575. private _pentagonBokehIsEnabled;
  129576. /**
  129577. * Creates a pentagon bokeh effect
  129578. */
  129579. enablePentagonBokeh(): void;
  129580. /**
  129581. * Disables the pentagon bokeh effect
  129582. */
  129583. disablePentagonBokeh(): void;
  129584. /**
  129585. * Enables noise blur
  129586. */
  129587. enableNoiseBlur(): void;
  129588. /**
  129589. * Disables noise blur
  129590. */
  129591. disableNoiseBlur(): void;
  129592. /**
  129593. * Sets the HighlightsGain amount
  129594. * @param amount amount of HighlightsGain
  129595. */
  129596. setHighlightsGain(amount: number): void;
  129597. /**
  129598. * Sets the HighlightsThreshold amount
  129599. * @param amount amount of HighlightsThreshold
  129600. */
  129601. setHighlightsThreshold(amount: number): void;
  129602. /**
  129603. * Disables highlights
  129604. */
  129605. disableHighlights(): void;
  129606. /**
  129607. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  129608. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  129609. */
  129610. dispose(disableDepthRender?: boolean): void;
  129611. private _createChromaticAberrationPostProcess;
  129612. private _createHighlightsPostProcess;
  129613. private _createDepthOfFieldPostProcess;
  129614. private _createGrainTexture;
  129615. }
  129616. }
  129617. declare module BABYLON {
  129618. /** @hidden */
  129619. export var ssao2PixelShader: {
  129620. name: string;
  129621. shader: string;
  129622. };
  129623. }
  129624. declare module BABYLON {
  129625. /** @hidden */
  129626. export var ssaoCombinePixelShader: {
  129627. name: string;
  129628. shader: string;
  129629. };
  129630. }
  129631. declare module BABYLON {
  129632. /**
  129633. * Render pipeline to produce ssao effect
  129634. */
  129635. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  129636. /**
  129637. * @ignore
  129638. * The PassPostProcess id in the pipeline that contains the original scene color
  129639. */
  129640. SSAOOriginalSceneColorEffect: string;
  129641. /**
  129642. * @ignore
  129643. * The SSAO PostProcess id in the pipeline
  129644. */
  129645. SSAORenderEffect: string;
  129646. /**
  129647. * @ignore
  129648. * The horizontal blur PostProcess id in the pipeline
  129649. */
  129650. SSAOBlurHRenderEffect: string;
  129651. /**
  129652. * @ignore
  129653. * The vertical blur PostProcess id in the pipeline
  129654. */
  129655. SSAOBlurVRenderEffect: string;
  129656. /**
  129657. * @ignore
  129658. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129659. */
  129660. SSAOCombineRenderEffect: string;
  129661. /**
  129662. * The output strength of the SSAO post-process. Default value is 1.0.
  129663. */
  129664. totalStrength: number;
  129665. /**
  129666. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  129667. */
  129668. maxZ: number;
  129669. /**
  129670. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  129671. */
  129672. minZAspect: number;
  129673. private _samples;
  129674. /**
  129675. * Number of samples used for the SSAO calculations. Default value is 8
  129676. */
  129677. samples: number;
  129678. private _textureSamples;
  129679. /**
  129680. * Number of samples to use for antialiasing
  129681. */
  129682. textureSamples: number;
  129683. /**
  129684. * Ratio object used for SSAO ratio and blur ratio
  129685. */
  129686. private _ratio;
  129687. /**
  129688. * Dynamically generated sphere sampler.
  129689. */
  129690. private _sampleSphere;
  129691. /**
  129692. * Blur filter offsets
  129693. */
  129694. private _samplerOffsets;
  129695. private _expensiveBlur;
  129696. /**
  129697. * If bilateral blur should be used
  129698. */
  129699. expensiveBlur: boolean;
  129700. /**
  129701. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  129702. */
  129703. radius: number;
  129704. /**
  129705. * The base color of the SSAO post-process
  129706. * The final result is "base + ssao" between [0, 1]
  129707. */
  129708. base: number;
  129709. /**
  129710. * Support test.
  129711. */
  129712. static readonly IsSupported: boolean;
  129713. private _scene;
  129714. private _depthTexture;
  129715. private _normalTexture;
  129716. private _randomTexture;
  129717. private _originalColorPostProcess;
  129718. private _ssaoPostProcess;
  129719. private _blurHPostProcess;
  129720. private _blurVPostProcess;
  129721. private _ssaoCombinePostProcess;
  129722. /**
  129723. * Gets active scene
  129724. */
  129725. readonly scene: Scene;
  129726. /**
  129727. * @constructor
  129728. * @param name The rendering pipeline name
  129729. * @param scene The scene linked to this pipeline
  129730. * @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 }
  129731. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129732. */
  129733. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129734. /**
  129735. * Get the class name
  129736. * @returns "SSAO2RenderingPipeline"
  129737. */
  129738. getClassName(): string;
  129739. /**
  129740. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129741. */
  129742. dispose(disableGeometryBufferRenderer?: boolean): void;
  129743. private _createBlurPostProcess;
  129744. /** @hidden */
  129745. _rebuild(): void;
  129746. private _bits;
  129747. private _radicalInverse_VdC;
  129748. private _hammersley;
  129749. private _hemisphereSample_uniform;
  129750. private _generateHemisphere;
  129751. private _createSSAOPostProcess;
  129752. private _createSSAOCombinePostProcess;
  129753. private _createRandomTexture;
  129754. /**
  129755. * Serialize the rendering pipeline (Used when exporting)
  129756. * @returns the serialized object
  129757. */
  129758. serialize(): any;
  129759. /**
  129760. * Parse the serialized pipeline
  129761. * @param source Source pipeline.
  129762. * @param scene The scene to load the pipeline to.
  129763. * @param rootUrl The URL of the serialized pipeline.
  129764. * @returns An instantiated pipeline from the serialized object.
  129765. */
  129766. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  129767. }
  129768. }
  129769. declare module BABYLON {
  129770. /** @hidden */
  129771. export var ssaoPixelShader: {
  129772. name: string;
  129773. shader: string;
  129774. };
  129775. }
  129776. declare module BABYLON {
  129777. /**
  129778. * Render pipeline to produce ssao effect
  129779. */
  129780. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  129781. /**
  129782. * @ignore
  129783. * The PassPostProcess id in the pipeline that contains the original scene color
  129784. */
  129785. SSAOOriginalSceneColorEffect: string;
  129786. /**
  129787. * @ignore
  129788. * The SSAO PostProcess id in the pipeline
  129789. */
  129790. SSAORenderEffect: string;
  129791. /**
  129792. * @ignore
  129793. * The horizontal blur PostProcess id in the pipeline
  129794. */
  129795. SSAOBlurHRenderEffect: string;
  129796. /**
  129797. * @ignore
  129798. * The vertical blur PostProcess id in the pipeline
  129799. */
  129800. SSAOBlurVRenderEffect: string;
  129801. /**
  129802. * @ignore
  129803. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129804. */
  129805. SSAOCombineRenderEffect: string;
  129806. /**
  129807. * The output strength of the SSAO post-process. Default value is 1.0.
  129808. */
  129809. totalStrength: number;
  129810. /**
  129811. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  129812. */
  129813. radius: number;
  129814. /**
  129815. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  129816. * Must not be equal to fallOff and superior to fallOff.
  129817. * Default value is 0.0075
  129818. */
  129819. area: number;
  129820. /**
  129821. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  129822. * Must not be equal to area and inferior to area.
  129823. * Default value is 0.000001
  129824. */
  129825. fallOff: number;
  129826. /**
  129827. * The base color of the SSAO post-process
  129828. * The final result is "base + ssao" between [0, 1]
  129829. */
  129830. base: number;
  129831. private _scene;
  129832. private _depthTexture;
  129833. private _randomTexture;
  129834. private _originalColorPostProcess;
  129835. private _ssaoPostProcess;
  129836. private _blurHPostProcess;
  129837. private _blurVPostProcess;
  129838. private _ssaoCombinePostProcess;
  129839. private _firstUpdate;
  129840. /**
  129841. * Gets active scene
  129842. */
  129843. readonly scene: Scene;
  129844. /**
  129845. * @constructor
  129846. * @param name - The rendering pipeline name
  129847. * @param scene - The scene linked to this pipeline
  129848. * @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 }
  129849. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  129850. */
  129851. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129852. /**
  129853. * Get the class name
  129854. * @returns "SSAORenderingPipeline"
  129855. */
  129856. getClassName(): string;
  129857. /**
  129858. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129859. */
  129860. dispose(disableDepthRender?: boolean): void;
  129861. private _createBlurPostProcess;
  129862. /** @hidden */
  129863. _rebuild(): void;
  129864. private _createSSAOPostProcess;
  129865. private _createSSAOCombinePostProcess;
  129866. private _createRandomTexture;
  129867. }
  129868. }
  129869. declare module BABYLON {
  129870. /** @hidden */
  129871. export var standardPixelShader: {
  129872. name: string;
  129873. shader: string;
  129874. };
  129875. }
  129876. declare module BABYLON {
  129877. /**
  129878. * Standard rendering pipeline
  129879. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129880. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  129881. */
  129882. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129883. /**
  129884. * Public members
  129885. */
  129886. /**
  129887. * Post-process which contains the original scene color before the pipeline applies all the effects
  129888. */
  129889. originalPostProcess: Nullable<PostProcess>;
  129890. /**
  129891. * Post-process used to down scale an image x4
  129892. */
  129893. downSampleX4PostProcess: Nullable<PostProcess>;
  129894. /**
  129895. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  129896. */
  129897. brightPassPostProcess: Nullable<PostProcess>;
  129898. /**
  129899. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  129900. */
  129901. blurHPostProcesses: PostProcess[];
  129902. /**
  129903. * Post-process array storing all the vertical blur post-processes used by the pipeline
  129904. */
  129905. blurVPostProcesses: PostProcess[];
  129906. /**
  129907. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  129908. */
  129909. textureAdderPostProcess: Nullable<PostProcess>;
  129910. /**
  129911. * Post-process used to create volumetric lighting effect
  129912. */
  129913. volumetricLightPostProcess: Nullable<PostProcess>;
  129914. /**
  129915. * Post-process used to smooth the previous volumetric light post-process on the X axis
  129916. */
  129917. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  129918. /**
  129919. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  129920. */
  129921. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  129922. /**
  129923. * Post-process used to merge the volumetric light effect and the real scene color
  129924. */
  129925. volumetricLightMergePostProces: Nullable<PostProcess>;
  129926. /**
  129927. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  129928. */
  129929. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  129930. /**
  129931. * Base post-process used to calculate the average luminance of the final image for HDR
  129932. */
  129933. luminancePostProcess: Nullable<PostProcess>;
  129934. /**
  129935. * Post-processes used to create down sample post-processes in order to get
  129936. * the average luminance of the final image for HDR
  129937. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  129938. */
  129939. luminanceDownSamplePostProcesses: PostProcess[];
  129940. /**
  129941. * Post-process used to create a HDR effect (light adaptation)
  129942. */
  129943. hdrPostProcess: Nullable<PostProcess>;
  129944. /**
  129945. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  129946. */
  129947. textureAdderFinalPostProcess: Nullable<PostProcess>;
  129948. /**
  129949. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  129950. */
  129951. lensFlareFinalPostProcess: Nullable<PostProcess>;
  129952. /**
  129953. * Post-process used to merge the final HDR post-process and the real scene color
  129954. */
  129955. hdrFinalPostProcess: Nullable<PostProcess>;
  129956. /**
  129957. * Post-process used to create a lens flare effect
  129958. */
  129959. lensFlarePostProcess: Nullable<PostProcess>;
  129960. /**
  129961. * Post-process that merges the result of the lens flare post-process and the real scene color
  129962. */
  129963. lensFlareComposePostProcess: Nullable<PostProcess>;
  129964. /**
  129965. * Post-process used to create a motion blur effect
  129966. */
  129967. motionBlurPostProcess: Nullable<PostProcess>;
  129968. /**
  129969. * Post-process used to create a depth of field effect
  129970. */
  129971. depthOfFieldPostProcess: Nullable<PostProcess>;
  129972. /**
  129973. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129974. */
  129975. fxaaPostProcess: Nullable<FxaaPostProcess>;
  129976. /**
  129977. * Represents the brightness threshold in order to configure the illuminated surfaces
  129978. */
  129979. brightThreshold: number;
  129980. /**
  129981. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  129982. */
  129983. blurWidth: number;
  129984. /**
  129985. * Sets if the blur for highlighted surfaces must be only horizontal
  129986. */
  129987. horizontalBlur: boolean;
  129988. /**
  129989. * Gets the overall exposure used by the pipeline
  129990. */
  129991. /**
  129992. * Sets the overall exposure used by the pipeline
  129993. */
  129994. exposure: number;
  129995. /**
  129996. * Texture used typically to simulate "dirty" on camera lens
  129997. */
  129998. lensTexture: Nullable<Texture>;
  129999. /**
  130000. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  130001. */
  130002. volumetricLightCoefficient: number;
  130003. /**
  130004. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  130005. */
  130006. volumetricLightPower: number;
  130007. /**
  130008. * Used the set the blur intensity to smooth the volumetric lights
  130009. */
  130010. volumetricLightBlurScale: number;
  130011. /**
  130012. * Light (spot or directional) used to generate the volumetric lights rays
  130013. * The source light must have a shadow generate so the pipeline can get its
  130014. * depth map
  130015. */
  130016. sourceLight: Nullable<SpotLight | DirectionalLight>;
  130017. /**
  130018. * For eye adaptation, represents the minimum luminance the eye can see
  130019. */
  130020. hdrMinimumLuminance: number;
  130021. /**
  130022. * For eye adaptation, represents the decrease luminance speed
  130023. */
  130024. hdrDecreaseRate: number;
  130025. /**
  130026. * For eye adaptation, represents the increase luminance speed
  130027. */
  130028. hdrIncreaseRate: number;
  130029. /**
  130030. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130031. */
  130032. /**
  130033. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130034. */
  130035. hdrAutoExposure: boolean;
  130036. /**
  130037. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  130038. */
  130039. lensColorTexture: Nullable<Texture>;
  130040. /**
  130041. * The overall strengh for the lens flare effect
  130042. */
  130043. lensFlareStrength: number;
  130044. /**
  130045. * Dispersion coefficient for lens flare ghosts
  130046. */
  130047. lensFlareGhostDispersal: number;
  130048. /**
  130049. * Main lens flare halo width
  130050. */
  130051. lensFlareHaloWidth: number;
  130052. /**
  130053. * Based on the lens distortion effect, defines how much the lens flare result
  130054. * is distorted
  130055. */
  130056. lensFlareDistortionStrength: number;
  130057. /**
  130058. * Configures the blur intensity used for for lens flare (halo)
  130059. */
  130060. lensFlareBlurWidth: number;
  130061. /**
  130062. * Lens star texture must be used to simulate rays on the flares and is available
  130063. * in the documentation
  130064. */
  130065. lensStarTexture: Nullable<Texture>;
  130066. /**
  130067. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130068. * flare effect by taking account of the dirt texture
  130069. */
  130070. lensFlareDirtTexture: Nullable<Texture>;
  130071. /**
  130072. * Represents the focal length for the depth of field effect
  130073. */
  130074. depthOfFieldDistance: number;
  130075. /**
  130076. * Represents the blur intensity for the blurred part of the depth of field effect
  130077. */
  130078. depthOfFieldBlurWidth: number;
  130079. /**
  130080. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130081. */
  130082. /**
  130083. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130084. */
  130085. motionStrength: number;
  130086. /**
  130087. * Gets wether or not the motion blur post-process is object based or screen based.
  130088. */
  130089. /**
  130090. * Sets wether or not the motion blur post-process should be object based or screen based
  130091. */
  130092. objectBasedMotionBlur: boolean;
  130093. /**
  130094. * List of animations for the pipeline (IAnimatable implementation)
  130095. */
  130096. animations: Animation[];
  130097. /**
  130098. * Private members
  130099. */
  130100. private _scene;
  130101. private _currentDepthOfFieldSource;
  130102. private _basePostProcess;
  130103. private _fixedExposure;
  130104. private _currentExposure;
  130105. private _hdrAutoExposure;
  130106. private _hdrCurrentLuminance;
  130107. private _motionStrength;
  130108. private _isObjectBasedMotionBlur;
  130109. private _floatTextureType;
  130110. private _camerasToBeAttached;
  130111. private _ratio;
  130112. private _bloomEnabled;
  130113. private _depthOfFieldEnabled;
  130114. private _vlsEnabled;
  130115. private _lensFlareEnabled;
  130116. private _hdrEnabled;
  130117. private _motionBlurEnabled;
  130118. private _fxaaEnabled;
  130119. private _motionBlurSamples;
  130120. private _volumetricLightStepsCount;
  130121. private _samples;
  130122. /**
  130123. * @ignore
  130124. * Specifies if the bloom pipeline is enabled
  130125. */
  130126. BloomEnabled: boolean;
  130127. /**
  130128. * @ignore
  130129. * Specifies if the depth of field pipeline is enabed
  130130. */
  130131. DepthOfFieldEnabled: boolean;
  130132. /**
  130133. * @ignore
  130134. * Specifies if the lens flare pipeline is enabed
  130135. */
  130136. LensFlareEnabled: boolean;
  130137. /**
  130138. * @ignore
  130139. * Specifies if the HDR pipeline is enabled
  130140. */
  130141. HDREnabled: boolean;
  130142. /**
  130143. * @ignore
  130144. * Specifies if the volumetric lights scattering effect is enabled
  130145. */
  130146. VLSEnabled: boolean;
  130147. /**
  130148. * @ignore
  130149. * Specifies if the motion blur effect is enabled
  130150. */
  130151. MotionBlurEnabled: boolean;
  130152. /**
  130153. * Specifies if anti-aliasing is enabled
  130154. */
  130155. fxaaEnabled: boolean;
  130156. /**
  130157. * Specifies the number of steps used to calculate the volumetric lights
  130158. * Typically in interval [50, 200]
  130159. */
  130160. volumetricLightStepsCount: number;
  130161. /**
  130162. * Specifies the number of samples used for the motion blur effect
  130163. * Typically in interval [16, 64]
  130164. */
  130165. motionBlurSamples: number;
  130166. /**
  130167. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130168. */
  130169. samples: number;
  130170. /**
  130171. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130172. * @constructor
  130173. * @param name The rendering pipeline name
  130174. * @param scene The scene linked to this pipeline
  130175. * @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)
  130176. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130177. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130178. */
  130179. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130180. private _buildPipeline;
  130181. private _createDownSampleX4PostProcess;
  130182. private _createBrightPassPostProcess;
  130183. private _createBlurPostProcesses;
  130184. private _createTextureAdderPostProcess;
  130185. private _createVolumetricLightPostProcess;
  130186. private _createLuminancePostProcesses;
  130187. private _createHdrPostProcess;
  130188. private _createLensFlarePostProcess;
  130189. private _createDepthOfFieldPostProcess;
  130190. private _createMotionBlurPostProcess;
  130191. private _getDepthTexture;
  130192. private _disposePostProcesses;
  130193. /**
  130194. * Dispose of the pipeline and stop all post processes
  130195. */
  130196. dispose(): void;
  130197. /**
  130198. * Serialize the rendering pipeline (Used when exporting)
  130199. * @returns the serialized object
  130200. */
  130201. serialize(): any;
  130202. /**
  130203. * Parse the serialized pipeline
  130204. * @param source Source pipeline.
  130205. * @param scene The scene to load the pipeline to.
  130206. * @param rootUrl The URL of the serialized pipeline.
  130207. * @returns An instantiated pipeline from the serialized object.
  130208. */
  130209. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130210. /**
  130211. * Luminance steps
  130212. */
  130213. static LuminanceSteps: number;
  130214. }
  130215. }
  130216. declare module BABYLON {
  130217. /** @hidden */
  130218. export var tonemapPixelShader: {
  130219. name: string;
  130220. shader: string;
  130221. };
  130222. }
  130223. declare module BABYLON {
  130224. /** Defines operator used for tonemapping */
  130225. export enum TonemappingOperator {
  130226. /** Hable */
  130227. Hable = 0,
  130228. /** Reinhard */
  130229. Reinhard = 1,
  130230. /** HejiDawson */
  130231. HejiDawson = 2,
  130232. /** Photographic */
  130233. Photographic = 3
  130234. }
  130235. /**
  130236. * Defines a post process to apply tone mapping
  130237. */
  130238. export class TonemapPostProcess extends PostProcess {
  130239. private _operator;
  130240. /** Defines the required exposure adjustement */
  130241. exposureAdjustment: number;
  130242. /**
  130243. * Creates a new TonemapPostProcess
  130244. * @param name defines the name of the postprocess
  130245. * @param _operator defines the operator to use
  130246. * @param exposureAdjustment defines the required exposure adjustement
  130247. * @param camera defines the camera to use (can be null)
  130248. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130249. * @param engine defines the hosting engine (can be ignore if camera is set)
  130250. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130251. */
  130252. constructor(name: string, _operator: TonemappingOperator,
  130253. /** Defines the required exposure adjustement */
  130254. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130255. }
  130256. }
  130257. declare module BABYLON {
  130258. /** @hidden */
  130259. export var depthVertexShader: {
  130260. name: string;
  130261. shader: string;
  130262. };
  130263. }
  130264. declare module BABYLON {
  130265. /** @hidden */
  130266. export var volumetricLightScatteringPixelShader: {
  130267. name: string;
  130268. shader: string;
  130269. };
  130270. }
  130271. declare module BABYLON {
  130272. /** @hidden */
  130273. export var volumetricLightScatteringPassVertexShader: {
  130274. name: string;
  130275. shader: string;
  130276. };
  130277. }
  130278. declare module BABYLON {
  130279. /** @hidden */
  130280. export var volumetricLightScatteringPassPixelShader: {
  130281. name: string;
  130282. shader: string;
  130283. };
  130284. }
  130285. declare module BABYLON {
  130286. /**
  130287. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130288. */
  130289. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130290. private _volumetricLightScatteringPass;
  130291. private _volumetricLightScatteringRTT;
  130292. private _viewPort;
  130293. private _screenCoordinates;
  130294. private _cachedDefines;
  130295. /**
  130296. * If not undefined, the mesh position is computed from the attached node position
  130297. */
  130298. attachedNode: {
  130299. position: Vector3;
  130300. };
  130301. /**
  130302. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130303. */
  130304. customMeshPosition: Vector3;
  130305. /**
  130306. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130307. */
  130308. useCustomMeshPosition: boolean;
  130309. /**
  130310. * If the post-process should inverse the light scattering direction
  130311. */
  130312. invert: boolean;
  130313. /**
  130314. * The internal mesh used by the post-process
  130315. */
  130316. mesh: Mesh;
  130317. /**
  130318. * @hidden
  130319. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130320. */
  130321. useDiffuseColor: boolean;
  130322. /**
  130323. * Array containing the excluded meshes not rendered in the internal pass
  130324. */
  130325. excludedMeshes: AbstractMesh[];
  130326. /**
  130327. * Controls the overall intensity of the post-process
  130328. */
  130329. exposure: number;
  130330. /**
  130331. * Dissipates each sample's contribution in range [0, 1]
  130332. */
  130333. decay: number;
  130334. /**
  130335. * Controls the overall intensity of each sample
  130336. */
  130337. weight: number;
  130338. /**
  130339. * Controls the density of each sample
  130340. */
  130341. density: number;
  130342. /**
  130343. * @constructor
  130344. * @param name The post-process name
  130345. * @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)
  130346. * @param camera The camera that the post-process will be attached to
  130347. * @param mesh The mesh used to create the light scattering
  130348. * @param samples The post-process quality, default 100
  130349. * @param samplingModeThe post-process filtering mode
  130350. * @param engine The babylon engine
  130351. * @param reusable If the post-process is reusable
  130352. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130353. */
  130354. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130355. /**
  130356. * Returns the string "VolumetricLightScatteringPostProcess"
  130357. * @returns "VolumetricLightScatteringPostProcess"
  130358. */
  130359. getClassName(): string;
  130360. private _isReady;
  130361. /**
  130362. * Sets the new light position for light scattering effect
  130363. * @param position The new custom light position
  130364. */
  130365. setCustomMeshPosition(position: Vector3): void;
  130366. /**
  130367. * Returns the light position for light scattering effect
  130368. * @return Vector3 The custom light position
  130369. */
  130370. getCustomMeshPosition(): Vector3;
  130371. /**
  130372. * Disposes the internal assets and detaches the post-process from the camera
  130373. */
  130374. dispose(camera: Camera): void;
  130375. /**
  130376. * Returns the render target texture used by the post-process
  130377. * @return the render target texture used by the post-process
  130378. */
  130379. getPass(): RenderTargetTexture;
  130380. private _meshExcluded;
  130381. private _createPass;
  130382. private _updateMeshScreenCoordinates;
  130383. /**
  130384. * Creates a default mesh for the Volumeric Light Scattering post-process
  130385. * @param name The mesh name
  130386. * @param scene The scene where to create the mesh
  130387. * @return the default mesh
  130388. */
  130389. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130390. }
  130391. }
  130392. declare module BABYLON {
  130393. interface Scene {
  130394. /** @hidden (Backing field) */
  130395. _boundingBoxRenderer: BoundingBoxRenderer;
  130396. /** @hidden (Backing field) */
  130397. _forceShowBoundingBoxes: boolean;
  130398. /**
  130399. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130400. */
  130401. forceShowBoundingBoxes: boolean;
  130402. /**
  130403. * Gets the bounding box renderer associated with the scene
  130404. * @returns a BoundingBoxRenderer
  130405. */
  130406. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130407. }
  130408. interface AbstractMesh {
  130409. /** @hidden (Backing field) */
  130410. _showBoundingBox: boolean;
  130411. /**
  130412. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130413. */
  130414. showBoundingBox: boolean;
  130415. }
  130416. /**
  130417. * Component responsible of rendering the bounding box of the meshes in a scene.
  130418. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130419. */
  130420. export class BoundingBoxRenderer implements ISceneComponent {
  130421. /**
  130422. * The component name helpfull to identify the component in the list of scene components.
  130423. */
  130424. readonly name: string;
  130425. /**
  130426. * The scene the component belongs to.
  130427. */
  130428. scene: Scene;
  130429. /**
  130430. * Color of the bounding box lines placed in front of an object
  130431. */
  130432. frontColor: Color3;
  130433. /**
  130434. * Color of the bounding box lines placed behind an object
  130435. */
  130436. backColor: Color3;
  130437. /**
  130438. * Defines if the renderer should show the back lines or not
  130439. */
  130440. showBackLines: boolean;
  130441. /**
  130442. * @hidden
  130443. */
  130444. renderList: SmartArray<BoundingBox>;
  130445. private _colorShader;
  130446. private _vertexBuffers;
  130447. private _indexBuffer;
  130448. private _fillIndexBuffer;
  130449. private _fillIndexData;
  130450. /**
  130451. * Instantiates a new bounding box renderer in a scene.
  130452. * @param scene the scene the renderer renders in
  130453. */
  130454. constructor(scene: Scene);
  130455. /**
  130456. * Registers the component in a given scene
  130457. */
  130458. register(): void;
  130459. private _evaluateSubMesh;
  130460. private _activeMesh;
  130461. private _prepareRessources;
  130462. private _createIndexBuffer;
  130463. /**
  130464. * Rebuilds the elements related to this component in case of
  130465. * context lost for instance.
  130466. */
  130467. rebuild(): void;
  130468. /**
  130469. * @hidden
  130470. */
  130471. reset(): void;
  130472. /**
  130473. * Render the bounding boxes of a specific rendering group
  130474. * @param renderingGroupId defines the rendering group to render
  130475. */
  130476. render(renderingGroupId: number): void;
  130477. /**
  130478. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130479. * @param mesh Define the mesh to render the occlusion bounding box for
  130480. */
  130481. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130482. /**
  130483. * Dispose and release the resources attached to this renderer.
  130484. */
  130485. dispose(): void;
  130486. }
  130487. }
  130488. declare module BABYLON {
  130489. /** @hidden */
  130490. export var depthPixelShader: {
  130491. name: string;
  130492. shader: string;
  130493. };
  130494. }
  130495. declare module BABYLON {
  130496. /**
  130497. * This represents a depth renderer in Babylon.
  130498. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130499. */
  130500. export class DepthRenderer {
  130501. private _scene;
  130502. private _depthMap;
  130503. private _effect;
  130504. private readonly _storeNonLinearDepth;
  130505. private readonly _clearColor;
  130506. /** Get if the depth renderer is using packed depth or not */
  130507. readonly isPacked: boolean;
  130508. private _cachedDefines;
  130509. private _camera;
  130510. /**
  130511. * Specifiess that the depth renderer will only be used within
  130512. * the camera it is created for.
  130513. * This can help forcing its rendering during the camera processing.
  130514. */
  130515. useOnlyInActiveCamera: boolean;
  130516. /** @hidden */
  130517. static _SceneComponentInitialization: (scene: Scene) => void;
  130518. /**
  130519. * Instantiates a depth renderer
  130520. * @param scene The scene the renderer belongs to
  130521. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130522. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130523. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130524. */
  130525. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130526. /**
  130527. * Creates the depth rendering effect and checks if the effect is ready.
  130528. * @param subMesh The submesh to be used to render the depth map of
  130529. * @param useInstances If multiple world instances should be used
  130530. * @returns if the depth renderer is ready to render the depth map
  130531. */
  130532. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130533. /**
  130534. * Gets the texture which the depth map will be written to.
  130535. * @returns The depth map texture
  130536. */
  130537. getDepthMap(): RenderTargetTexture;
  130538. /**
  130539. * Disposes of the depth renderer.
  130540. */
  130541. dispose(): void;
  130542. }
  130543. }
  130544. declare module BABYLON {
  130545. interface Scene {
  130546. /** @hidden (Backing field) */
  130547. _depthRenderer: {
  130548. [id: string]: DepthRenderer;
  130549. };
  130550. /**
  130551. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130552. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130553. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130554. * @returns the created depth renderer
  130555. */
  130556. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130557. /**
  130558. * Disables a depth renderer for a given camera
  130559. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130560. */
  130561. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130562. }
  130563. /**
  130564. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130565. * in several rendering techniques.
  130566. */
  130567. export class DepthRendererSceneComponent implements ISceneComponent {
  130568. /**
  130569. * The component name helpfull to identify the component in the list of scene components.
  130570. */
  130571. readonly name: string;
  130572. /**
  130573. * The scene the component belongs to.
  130574. */
  130575. scene: Scene;
  130576. /**
  130577. * Creates a new instance of the component for the given scene
  130578. * @param scene Defines the scene to register the component in
  130579. */
  130580. constructor(scene: Scene);
  130581. /**
  130582. * Registers the component in a given scene
  130583. */
  130584. register(): void;
  130585. /**
  130586. * Rebuilds the elements related to this component in case of
  130587. * context lost for instance.
  130588. */
  130589. rebuild(): void;
  130590. /**
  130591. * Disposes the component and the associated ressources
  130592. */
  130593. dispose(): void;
  130594. private _gatherRenderTargets;
  130595. private _gatherActiveCameraRenderTargets;
  130596. }
  130597. }
  130598. declare module BABYLON {
  130599. /** @hidden */
  130600. export var outlinePixelShader: {
  130601. name: string;
  130602. shader: string;
  130603. };
  130604. }
  130605. declare module BABYLON {
  130606. /** @hidden */
  130607. export var outlineVertexShader: {
  130608. name: string;
  130609. shader: string;
  130610. };
  130611. }
  130612. declare module BABYLON {
  130613. interface Scene {
  130614. /** @hidden */
  130615. _outlineRenderer: OutlineRenderer;
  130616. /**
  130617. * Gets the outline renderer associated with the scene
  130618. * @returns a OutlineRenderer
  130619. */
  130620. getOutlineRenderer(): OutlineRenderer;
  130621. }
  130622. interface AbstractMesh {
  130623. /** @hidden (Backing field) */
  130624. _renderOutline: boolean;
  130625. /**
  130626. * Gets or sets a boolean indicating if the outline must be rendered as well
  130627. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  130628. */
  130629. renderOutline: boolean;
  130630. /** @hidden (Backing field) */
  130631. _renderOverlay: boolean;
  130632. /**
  130633. * Gets or sets a boolean indicating if the overlay must be rendered as well
  130634. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  130635. */
  130636. renderOverlay: boolean;
  130637. }
  130638. /**
  130639. * This class is responsible to draw bothe outline/overlay of meshes.
  130640. * It should not be used directly but through the available method on mesh.
  130641. */
  130642. export class OutlineRenderer implements ISceneComponent {
  130643. /**
  130644. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130645. */
  130646. private static _StencilReference;
  130647. /**
  130648. * The name of the component. Each component must have a unique name.
  130649. */
  130650. name: string;
  130651. /**
  130652. * The scene the component belongs to.
  130653. */
  130654. scene: Scene;
  130655. /**
  130656. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  130657. */
  130658. zOffset: number;
  130659. private _engine;
  130660. private _effect;
  130661. private _cachedDefines;
  130662. private _savedDepthWrite;
  130663. /**
  130664. * Instantiates a new outline renderer. (There could be only one per scene).
  130665. * @param scene Defines the scene it belongs to
  130666. */
  130667. constructor(scene: Scene);
  130668. /**
  130669. * Register the component to one instance of a scene.
  130670. */
  130671. register(): void;
  130672. /**
  130673. * Rebuilds the elements related to this component in case of
  130674. * context lost for instance.
  130675. */
  130676. rebuild(): void;
  130677. /**
  130678. * Disposes the component and the associated ressources.
  130679. */
  130680. dispose(): void;
  130681. /**
  130682. * Renders the outline in the canvas.
  130683. * @param subMesh Defines the sumesh to render
  130684. * @param batch Defines the batch of meshes in case of instances
  130685. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130686. */
  130687. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  130688. /**
  130689. * Returns whether or not the outline renderer is ready for a given submesh.
  130690. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130691. * @param subMesh Defines the submesh to check readyness for
  130692. * @param useInstances Defines wheter wee are trying to render instances or not
  130693. * @returns true if ready otherwise false
  130694. */
  130695. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130696. private _beforeRenderingMesh;
  130697. private _afterRenderingMesh;
  130698. }
  130699. }
  130700. declare module BABYLON {
  130701. /**
  130702. * Class used to manage multiple sprites of different sizes on the same spritesheet
  130703. * @see http://doc.babylonjs.com/babylon101/sprites
  130704. */
  130705. export class SpritePackedManager extends SpriteManager {
  130706. /** defines the packed manager's name */
  130707. name: string;
  130708. /**
  130709. * Creates a new sprite manager from a packed sprite sheet
  130710. * @param name defines the manager's name
  130711. * @param imgUrl defines the sprite sheet url
  130712. * @param capacity defines the maximum allowed number of sprites
  130713. * @param scene defines the hosting scene
  130714. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  130715. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130716. * @param samplingMode defines the smapling mode to use with spritesheet
  130717. * @param fromPacked set to true; do not alter
  130718. */
  130719. constructor(
  130720. /** defines the packed manager's name */
  130721. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  130722. }
  130723. }
  130724. declare module BABYLON {
  130725. /**
  130726. * Defines the list of states available for a task inside a AssetsManager
  130727. */
  130728. export enum AssetTaskState {
  130729. /**
  130730. * Initialization
  130731. */
  130732. INIT = 0,
  130733. /**
  130734. * Running
  130735. */
  130736. RUNNING = 1,
  130737. /**
  130738. * Done
  130739. */
  130740. DONE = 2,
  130741. /**
  130742. * Error
  130743. */
  130744. ERROR = 3
  130745. }
  130746. /**
  130747. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  130748. */
  130749. export abstract class AbstractAssetTask {
  130750. /**
  130751. * Task name
  130752. */ name: string;
  130753. /**
  130754. * Callback called when the task is successful
  130755. */
  130756. onSuccess: (task: any) => void;
  130757. /**
  130758. * Callback called when the task is not successful
  130759. */
  130760. onError: (task: any, message?: string, exception?: any) => void;
  130761. /**
  130762. * Creates a new AssetsManager
  130763. * @param name defines the name of the task
  130764. */
  130765. constructor(
  130766. /**
  130767. * Task name
  130768. */ name: string);
  130769. private _isCompleted;
  130770. private _taskState;
  130771. private _errorObject;
  130772. /**
  130773. * Get if the task is completed
  130774. */
  130775. readonly isCompleted: boolean;
  130776. /**
  130777. * Gets the current state of the task
  130778. */
  130779. readonly taskState: AssetTaskState;
  130780. /**
  130781. * Gets the current error object (if task is in error)
  130782. */
  130783. readonly errorObject: {
  130784. message?: string;
  130785. exception?: any;
  130786. };
  130787. /**
  130788. * Internal only
  130789. * @hidden
  130790. */
  130791. _setErrorObject(message?: string, exception?: any): void;
  130792. /**
  130793. * Execute the current task
  130794. * @param scene defines the scene where you want your assets to be loaded
  130795. * @param onSuccess is a callback called when the task is successfully executed
  130796. * @param onError is a callback called if an error occurs
  130797. */
  130798. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130799. /**
  130800. * Execute the current task
  130801. * @param scene defines the scene where you want your assets to be loaded
  130802. * @param onSuccess is a callback called when the task is successfully executed
  130803. * @param onError is a callback called if an error occurs
  130804. */
  130805. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130806. /**
  130807. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  130808. * This can be used with failed tasks that have the reason for failure fixed.
  130809. */
  130810. reset(): void;
  130811. private onErrorCallback;
  130812. private onDoneCallback;
  130813. }
  130814. /**
  130815. * Define the interface used by progress events raised during assets loading
  130816. */
  130817. export interface IAssetsProgressEvent {
  130818. /**
  130819. * Defines the number of remaining tasks to process
  130820. */
  130821. remainingCount: number;
  130822. /**
  130823. * Defines the total number of tasks
  130824. */
  130825. totalCount: number;
  130826. /**
  130827. * Defines the task that was just processed
  130828. */
  130829. task: AbstractAssetTask;
  130830. }
  130831. /**
  130832. * Class used to share progress information about assets loading
  130833. */
  130834. export class AssetsProgressEvent implements IAssetsProgressEvent {
  130835. /**
  130836. * Defines the number of remaining tasks to process
  130837. */
  130838. remainingCount: number;
  130839. /**
  130840. * Defines the total number of tasks
  130841. */
  130842. totalCount: number;
  130843. /**
  130844. * Defines the task that was just processed
  130845. */
  130846. task: AbstractAssetTask;
  130847. /**
  130848. * Creates a AssetsProgressEvent
  130849. * @param remainingCount defines the number of remaining tasks to process
  130850. * @param totalCount defines the total number of tasks
  130851. * @param task defines the task that was just processed
  130852. */
  130853. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  130854. }
  130855. /**
  130856. * Define a task used by AssetsManager to load meshes
  130857. */
  130858. export class MeshAssetTask extends AbstractAssetTask {
  130859. /**
  130860. * Defines the name of the task
  130861. */
  130862. name: string;
  130863. /**
  130864. * Defines the list of mesh's names you want to load
  130865. */
  130866. meshesNames: any;
  130867. /**
  130868. * Defines the root url to use as a base to load your meshes and associated resources
  130869. */
  130870. rootUrl: string;
  130871. /**
  130872. * Defines the filename of the scene to load from
  130873. */
  130874. sceneFilename: string;
  130875. /**
  130876. * Gets the list of loaded meshes
  130877. */
  130878. loadedMeshes: Array<AbstractMesh>;
  130879. /**
  130880. * Gets the list of loaded particle systems
  130881. */
  130882. loadedParticleSystems: Array<IParticleSystem>;
  130883. /**
  130884. * Gets the list of loaded skeletons
  130885. */
  130886. loadedSkeletons: Array<Skeleton>;
  130887. /**
  130888. * Gets the list of loaded animation groups
  130889. */
  130890. loadedAnimationGroups: Array<AnimationGroup>;
  130891. /**
  130892. * Callback called when the task is successful
  130893. */
  130894. onSuccess: (task: MeshAssetTask) => void;
  130895. /**
  130896. * Callback called when the task is successful
  130897. */
  130898. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  130899. /**
  130900. * Creates a new MeshAssetTask
  130901. * @param name defines the name of the task
  130902. * @param meshesNames defines the list of mesh's names you want to load
  130903. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  130904. * @param sceneFilename defines the filename of the scene to load from
  130905. */
  130906. constructor(
  130907. /**
  130908. * Defines the name of the task
  130909. */
  130910. name: string,
  130911. /**
  130912. * Defines the list of mesh's names you want to load
  130913. */
  130914. meshesNames: any,
  130915. /**
  130916. * Defines the root url to use as a base to load your meshes and associated resources
  130917. */
  130918. rootUrl: string,
  130919. /**
  130920. * Defines the filename of the scene to load from
  130921. */
  130922. sceneFilename: string);
  130923. /**
  130924. * Execute the current task
  130925. * @param scene defines the scene where you want your assets to be loaded
  130926. * @param onSuccess is a callback called when the task is successfully executed
  130927. * @param onError is a callback called if an error occurs
  130928. */
  130929. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130930. }
  130931. /**
  130932. * Define a task used by AssetsManager to load text content
  130933. */
  130934. export class TextFileAssetTask extends AbstractAssetTask {
  130935. /**
  130936. * Defines the name of the task
  130937. */
  130938. name: string;
  130939. /**
  130940. * Defines the location of the file to load
  130941. */
  130942. url: string;
  130943. /**
  130944. * Gets the loaded text string
  130945. */
  130946. text: string;
  130947. /**
  130948. * Callback called when the task is successful
  130949. */
  130950. onSuccess: (task: TextFileAssetTask) => void;
  130951. /**
  130952. * Callback called when the task is successful
  130953. */
  130954. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  130955. /**
  130956. * Creates a new TextFileAssetTask object
  130957. * @param name defines the name of the task
  130958. * @param url defines the location of the file to load
  130959. */
  130960. constructor(
  130961. /**
  130962. * Defines the name of the task
  130963. */
  130964. name: string,
  130965. /**
  130966. * Defines the location of the file to load
  130967. */
  130968. url: string);
  130969. /**
  130970. * Execute the current task
  130971. * @param scene defines the scene where you want your assets to be loaded
  130972. * @param onSuccess is a callback called when the task is successfully executed
  130973. * @param onError is a callback called if an error occurs
  130974. */
  130975. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130976. }
  130977. /**
  130978. * Define a task used by AssetsManager to load binary data
  130979. */
  130980. export class BinaryFileAssetTask extends AbstractAssetTask {
  130981. /**
  130982. * Defines the name of the task
  130983. */
  130984. name: string;
  130985. /**
  130986. * Defines the location of the file to load
  130987. */
  130988. url: string;
  130989. /**
  130990. * Gets the lodaded data (as an array buffer)
  130991. */
  130992. data: ArrayBuffer;
  130993. /**
  130994. * Callback called when the task is successful
  130995. */
  130996. onSuccess: (task: BinaryFileAssetTask) => void;
  130997. /**
  130998. * Callback called when the task is successful
  130999. */
  131000. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  131001. /**
  131002. * Creates a new BinaryFileAssetTask object
  131003. * @param name defines the name of the new task
  131004. * @param url defines the location of the file to load
  131005. */
  131006. constructor(
  131007. /**
  131008. * Defines the name of the task
  131009. */
  131010. name: string,
  131011. /**
  131012. * Defines the location of the file to load
  131013. */
  131014. url: string);
  131015. /**
  131016. * Execute the current task
  131017. * @param scene defines the scene where you want your assets to be loaded
  131018. * @param onSuccess is a callback called when the task is successfully executed
  131019. * @param onError is a callback called if an error occurs
  131020. */
  131021. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131022. }
  131023. /**
  131024. * Define a task used by AssetsManager to load images
  131025. */
  131026. export class ImageAssetTask extends AbstractAssetTask {
  131027. /**
  131028. * Defines the name of the task
  131029. */
  131030. name: string;
  131031. /**
  131032. * Defines the location of the image to load
  131033. */
  131034. url: string;
  131035. /**
  131036. * Gets the loaded images
  131037. */
  131038. image: HTMLImageElement;
  131039. /**
  131040. * Callback called when the task is successful
  131041. */
  131042. onSuccess: (task: ImageAssetTask) => void;
  131043. /**
  131044. * Callback called when the task is successful
  131045. */
  131046. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  131047. /**
  131048. * Creates a new ImageAssetTask
  131049. * @param name defines the name of the task
  131050. * @param url defines the location of the image to load
  131051. */
  131052. constructor(
  131053. /**
  131054. * Defines the name of the task
  131055. */
  131056. name: string,
  131057. /**
  131058. * Defines the location of the image to load
  131059. */
  131060. url: string);
  131061. /**
  131062. * Execute the current task
  131063. * @param scene defines the scene where you want your assets to be loaded
  131064. * @param onSuccess is a callback called when the task is successfully executed
  131065. * @param onError is a callback called if an error occurs
  131066. */
  131067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131068. }
  131069. /**
  131070. * Defines the interface used by texture loading tasks
  131071. */
  131072. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131073. /**
  131074. * Gets the loaded texture
  131075. */
  131076. texture: TEX;
  131077. }
  131078. /**
  131079. * Define a task used by AssetsManager to load 2D textures
  131080. */
  131081. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131082. /**
  131083. * Defines the name of the task
  131084. */
  131085. name: string;
  131086. /**
  131087. * Defines the location of the file to load
  131088. */
  131089. url: string;
  131090. /**
  131091. * Defines if mipmap should not be generated (default is false)
  131092. */
  131093. noMipmap?: boolean | undefined;
  131094. /**
  131095. * Defines if texture must be inverted on Y axis (default is false)
  131096. */
  131097. invertY?: boolean | undefined;
  131098. /**
  131099. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131100. */
  131101. samplingMode: number;
  131102. /**
  131103. * Gets the loaded texture
  131104. */
  131105. texture: Texture;
  131106. /**
  131107. * Callback called when the task is successful
  131108. */
  131109. onSuccess: (task: TextureAssetTask) => void;
  131110. /**
  131111. * Callback called when the task is successful
  131112. */
  131113. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131114. /**
  131115. * Creates a new TextureAssetTask object
  131116. * @param name defines the name of the task
  131117. * @param url defines the location of the file to load
  131118. * @param noMipmap defines if mipmap should not be generated (default is false)
  131119. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131120. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131121. */
  131122. constructor(
  131123. /**
  131124. * Defines the name of the task
  131125. */
  131126. name: string,
  131127. /**
  131128. * Defines the location of the file to load
  131129. */
  131130. url: string,
  131131. /**
  131132. * Defines if mipmap should not be generated (default is false)
  131133. */
  131134. noMipmap?: boolean | undefined,
  131135. /**
  131136. * Defines if texture must be inverted on Y axis (default is false)
  131137. */
  131138. invertY?: boolean | undefined,
  131139. /**
  131140. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131141. */
  131142. samplingMode?: number);
  131143. /**
  131144. * Execute the current task
  131145. * @param scene defines the scene where you want your assets to be loaded
  131146. * @param onSuccess is a callback called when the task is successfully executed
  131147. * @param onError is a callback called if an error occurs
  131148. */
  131149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131150. }
  131151. /**
  131152. * Define a task used by AssetsManager to load cube textures
  131153. */
  131154. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131155. /**
  131156. * Defines the name of the task
  131157. */
  131158. name: string;
  131159. /**
  131160. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131161. */
  131162. url: string;
  131163. /**
  131164. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131165. */
  131166. extensions?: string[] | undefined;
  131167. /**
  131168. * Defines if mipmaps should not be generated (default is false)
  131169. */
  131170. noMipmap?: boolean | undefined;
  131171. /**
  131172. * Defines the explicit list of files (undefined by default)
  131173. */
  131174. files?: string[] | undefined;
  131175. /**
  131176. * Gets the loaded texture
  131177. */
  131178. texture: CubeTexture;
  131179. /**
  131180. * Callback called when the task is successful
  131181. */
  131182. onSuccess: (task: CubeTextureAssetTask) => void;
  131183. /**
  131184. * Callback called when the task is successful
  131185. */
  131186. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131187. /**
  131188. * Creates a new CubeTextureAssetTask
  131189. * @param name defines the name of the task
  131190. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131191. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131192. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131193. * @param files defines the explicit list of files (undefined by default)
  131194. */
  131195. constructor(
  131196. /**
  131197. * Defines the name of the task
  131198. */
  131199. name: string,
  131200. /**
  131201. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131202. */
  131203. url: string,
  131204. /**
  131205. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131206. */
  131207. extensions?: string[] | undefined,
  131208. /**
  131209. * Defines if mipmaps should not be generated (default is false)
  131210. */
  131211. noMipmap?: boolean | undefined,
  131212. /**
  131213. * Defines the explicit list of files (undefined by default)
  131214. */
  131215. files?: string[] | undefined);
  131216. /**
  131217. * Execute the current task
  131218. * @param scene defines the scene where you want your assets to be loaded
  131219. * @param onSuccess is a callback called when the task is successfully executed
  131220. * @param onError is a callback called if an error occurs
  131221. */
  131222. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131223. }
  131224. /**
  131225. * Define a task used by AssetsManager to load HDR cube textures
  131226. */
  131227. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131228. /**
  131229. * Defines the name of the task
  131230. */
  131231. name: string;
  131232. /**
  131233. * Defines the location of the file to load
  131234. */
  131235. url: string;
  131236. /**
  131237. * Defines the desired size (the more it increases the longer the generation will be)
  131238. */
  131239. size: number;
  131240. /**
  131241. * Defines if mipmaps should not be generated (default is false)
  131242. */
  131243. noMipmap: boolean;
  131244. /**
  131245. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131246. */
  131247. generateHarmonics: boolean;
  131248. /**
  131249. * 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)
  131250. */
  131251. gammaSpace: boolean;
  131252. /**
  131253. * Internal Use Only
  131254. */
  131255. reserved: boolean;
  131256. /**
  131257. * Gets the loaded texture
  131258. */
  131259. texture: HDRCubeTexture;
  131260. /**
  131261. * Callback called when the task is successful
  131262. */
  131263. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131264. /**
  131265. * Callback called when the task is successful
  131266. */
  131267. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131268. /**
  131269. * Creates a new HDRCubeTextureAssetTask object
  131270. * @param name defines the name of the task
  131271. * @param url defines the location of the file to load
  131272. * @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.
  131273. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131274. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131275. * @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)
  131276. * @param reserved Internal use only
  131277. */
  131278. constructor(
  131279. /**
  131280. * Defines the name of the task
  131281. */
  131282. name: string,
  131283. /**
  131284. * Defines the location of the file to load
  131285. */
  131286. url: string,
  131287. /**
  131288. * Defines the desired size (the more it increases the longer the generation will be)
  131289. */
  131290. size: number,
  131291. /**
  131292. * Defines if mipmaps should not be generated (default is false)
  131293. */
  131294. noMipmap?: boolean,
  131295. /**
  131296. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131297. */
  131298. generateHarmonics?: boolean,
  131299. /**
  131300. * 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)
  131301. */
  131302. gammaSpace?: boolean,
  131303. /**
  131304. * Internal Use Only
  131305. */
  131306. reserved?: boolean);
  131307. /**
  131308. * Execute the current task
  131309. * @param scene defines the scene where you want your assets to be loaded
  131310. * @param onSuccess is a callback called when the task is successfully executed
  131311. * @param onError is a callback called if an error occurs
  131312. */
  131313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131314. }
  131315. /**
  131316. * Define a task used by AssetsManager to load Equirectangular cube textures
  131317. */
  131318. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131319. /**
  131320. * Defines the name of the task
  131321. */
  131322. name: string;
  131323. /**
  131324. * Defines the location of the file to load
  131325. */
  131326. url: string;
  131327. /**
  131328. * Defines the desired size (the more it increases the longer the generation will be)
  131329. */
  131330. size: number;
  131331. /**
  131332. * Defines if mipmaps should not be generated (default is false)
  131333. */
  131334. noMipmap: boolean;
  131335. /**
  131336. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131337. * but the standard material would require them in Gamma space) (default is true)
  131338. */
  131339. gammaSpace: boolean;
  131340. /**
  131341. * Gets the loaded texture
  131342. */
  131343. texture: EquiRectangularCubeTexture;
  131344. /**
  131345. * Callback called when the task is successful
  131346. */
  131347. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131348. /**
  131349. * Callback called when the task is successful
  131350. */
  131351. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131352. /**
  131353. * Creates a new EquiRectangularCubeTextureAssetTask object
  131354. * @param name defines the name of the task
  131355. * @param url defines the location of the file to load
  131356. * @param size defines the desired size (the more it increases the longer the generation will be)
  131357. * If the size is omitted this implies you are using a preprocessed cubemap.
  131358. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131359. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131360. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131361. * (default is true)
  131362. */
  131363. constructor(
  131364. /**
  131365. * Defines the name of the task
  131366. */
  131367. name: string,
  131368. /**
  131369. * Defines the location of the file to load
  131370. */
  131371. url: string,
  131372. /**
  131373. * Defines the desired size (the more it increases the longer the generation will be)
  131374. */
  131375. size: number,
  131376. /**
  131377. * Defines if mipmaps should not be generated (default is false)
  131378. */
  131379. noMipmap?: boolean,
  131380. /**
  131381. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131382. * but the standard material would require them in Gamma space) (default is true)
  131383. */
  131384. gammaSpace?: boolean);
  131385. /**
  131386. * Execute the current task
  131387. * @param scene defines the scene where you want your assets to be loaded
  131388. * @param onSuccess is a callback called when the task is successfully executed
  131389. * @param onError is a callback called if an error occurs
  131390. */
  131391. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131392. }
  131393. /**
  131394. * This class can be used to easily import assets into a scene
  131395. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131396. */
  131397. export class AssetsManager {
  131398. private _scene;
  131399. private _isLoading;
  131400. protected _tasks: AbstractAssetTask[];
  131401. protected _waitingTasksCount: number;
  131402. protected _totalTasksCount: number;
  131403. /**
  131404. * Callback called when all tasks are processed
  131405. */
  131406. onFinish: (tasks: AbstractAssetTask[]) => void;
  131407. /**
  131408. * Callback called when a task is successful
  131409. */
  131410. onTaskSuccess: (task: AbstractAssetTask) => void;
  131411. /**
  131412. * Callback called when a task had an error
  131413. */
  131414. onTaskError: (task: AbstractAssetTask) => void;
  131415. /**
  131416. * Callback called when a task is done (whatever the result is)
  131417. */
  131418. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131419. /**
  131420. * Observable called when all tasks are processed
  131421. */
  131422. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131423. /**
  131424. * Observable called when a task had an error
  131425. */
  131426. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131427. /**
  131428. * Observable called when all tasks were executed
  131429. */
  131430. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131431. /**
  131432. * Observable called when a task is done (whatever the result is)
  131433. */
  131434. onProgressObservable: Observable<IAssetsProgressEvent>;
  131435. /**
  131436. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131437. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131438. */
  131439. useDefaultLoadingScreen: boolean;
  131440. /**
  131441. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131442. * when all assets have been downloaded.
  131443. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131444. */
  131445. autoHideLoadingUI: boolean;
  131446. /**
  131447. * Creates a new AssetsManager
  131448. * @param scene defines the scene to work on
  131449. */
  131450. constructor(scene: Scene);
  131451. /**
  131452. * Add a MeshAssetTask to the list of active tasks
  131453. * @param taskName defines the name of the new task
  131454. * @param meshesNames defines the name of meshes to load
  131455. * @param rootUrl defines the root url to use to locate files
  131456. * @param sceneFilename defines the filename of the scene file
  131457. * @returns a new MeshAssetTask object
  131458. */
  131459. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131460. /**
  131461. * Add a TextFileAssetTask to the list of active tasks
  131462. * @param taskName defines the name of the new task
  131463. * @param url defines the url of the file to load
  131464. * @returns a new TextFileAssetTask object
  131465. */
  131466. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131467. /**
  131468. * Add a BinaryFileAssetTask to the list of active tasks
  131469. * @param taskName defines the name of the new task
  131470. * @param url defines the url of the file to load
  131471. * @returns a new BinaryFileAssetTask object
  131472. */
  131473. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131474. /**
  131475. * Add a ImageAssetTask to the list of active tasks
  131476. * @param taskName defines the name of the new task
  131477. * @param url defines the url of the file to load
  131478. * @returns a new ImageAssetTask object
  131479. */
  131480. addImageTask(taskName: string, url: string): ImageAssetTask;
  131481. /**
  131482. * Add a TextureAssetTask to the list of active tasks
  131483. * @param taskName defines the name of the new task
  131484. * @param url defines the url of the file to load
  131485. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131486. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  131487. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131488. * @returns a new TextureAssetTask object
  131489. */
  131490. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  131491. /**
  131492. * Add a CubeTextureAssetTask to the list of active tasks
  131493. * @param taskName defines the name of the new task
  131494. * @param url defines the url of the file to load
  131495. * @param extensions defines the extension to use to load the cube map (can be null)
  131496. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131497. * @param files defines the list of files to load (can be null)
  131498. * @returns a new CubeTextureAssetTask object
  131499. */
  131500. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131501. /**
  131502. *
  131503. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131504. * @param taskName defines the name of the new task
  131505. * @param url defines the url of the file to load
  131506. * @param size defines the size you want for the cubemap (can be null)
  131507. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131508. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131509. * @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)
  131510. * @param reserved Internal use only
  131511. * @returns a new HDRCubeTextureAssetTask object
  131512. */
  131513. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131514. /**
  131515. *
  131516. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131517. * @param taskName defines the name of the new task
  131518. * @param url defines the url of the file to load
  131519. * @param size defines the size you want for the cubemap (can be null)
  131520. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131521. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131522. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131523. * @returns a new EquiRectangularCubeTextureAssetTask object
  131524. */
  131525. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131526. /**
  131527. * Remove a task from the assets manager.
  131528. * @param task the task to remove
  131529. */
  131530. removeTask(task: AbstractAssetTask): void;
  131531. private _decreaseWaitingTasksCount;
  131532. private _runTask;
  131533. /**
  131534. * Reset the AssetsManager and remove all tasks
  131535. * @return the current instance of the AssetsManager
  131536. */
  131537. reset(): AssetsManager;
  131538. /**
  131539. * Start the loading process
  131540. * @return the current instance of the AssetsManager
  131541. */
  131542. load(): AssetsManager;
  131543. /**
  131544. * Start the loading process as an async operation
  131545. * @return a promise returning the list of failed tasks
  131546. */
  131547. loadAsync(): Promise<void>;
  131548. }
  131549. }
  131550. declare module BABYLON {
  131551. /**
  131552. * Wrapper class for promise with external resolve and reject.
  131553. */
  131554. export class Deferred<T> {
  131555. /**
  131556. * The promise associated with this deferred object.
  131557. */
  131558. readonly promise: Promise<T>;
  131559. private _resolve;
  131560. private _reject;
  131561. /**
  131562. * The resolve method of the promise associated with this deferred object.
  131563. */
  131564. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131565. /**
  131566. * The reject method of the promise associated with this deferred object.
  131567. */
  131568. readonly reject: (reason?: any) => void;
  131569. /**
  131570. * Constructor for this deferred object.
  131571. */
  131572. constructor();
  131573. }
  131574. }
  131575. declare module BABYLON {
  131576. /**
  131577. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  131578. */
  131579. export class MeshExploder {
  131580. private _centerMesh;
  131581. private _meshes;
  131582. private _meshesOrigins;
  131583. private _toCenterVectors;
  131584. private _scaledDirection;
  131585. private _newPosition;
  131586. private _centerPosition;
  131587. /**
  131588. * Explodes meshes from a center mesh.
  131589. * @param meshes The meshes to explode.
  131590. * @param centerMesh The mesh to be center of explosion.
  131591. */
  131592. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  131593. private _setCenterMesh;
  131594. /**
  131595. * Get class name
  131596. * @returns "MeshExploder"
  131597. */
  131598. getClassName(): string;
  131599. /**
  131600. * "Exploded meshes"
  131601. * @returns Array of meshes with the centerMesh at index 0.
  131602. */
  131603. getMeshes(): Array<Mesh>;
  131604. /**
  131605. * Explodes meshes giving a specific direction
  131606. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  131607. */
  131608. explode(direction?: number): void;
  131609. }
  131610. }
  131611. declare module BABYLON {
  131612. /**
  131613. * Class used to help managing file picking and drag'n'drop
  131614. */
  131615. export class FilesInput {
  131616. /**
  131617. * List of files ready to be loaded
  131618. */
  131619. static readonly FilesToLoad: {
  131620. [key: string]: File;
  131621. };
  131622. /**
  131623. * Callback called when a file is processed
  131624. */
  131625. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  131626. private _engine;
  131627. private _currentScene;
  131628. private _sceneLoadedCallback;
  131629. private _progressCallback;
  131630. private _additionalRenderLoopLogicCallback;
  131631. private _textureLoadingCallback;
  131632. private _startingProcessingFilesCallback;
  131633. private _onReloadCallback;
  131634. private _errorCallback;
  131635. private _elementToMonitor;
  131636. private _sceneFileToLoad;
  131637. private _filesToLoad;
  131638. /**
  131639. * Creates a new FilesInput
  131640. * @param engine defines the rendering engine
  131641. * @param scene defines the hosting scene
  131642. * @param sceneLoadedCallback callback called when scene is loaded
  131643. * @param progressCallback callback called to track progress
  131644. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  131645. * @param textureLoadingCallback callback called when a texture is loading
  131646. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  131647. * @param onReloadCallback callback called when a reload is requested
  131648. * @param errorCallback callback call if an error occurs
  131649. */
  131650. 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);
  131651. private _dragEnterHandler;
  131652. private _dragOverHandler;
  131653. private _dropHandler;
  131654. /**
  131655. * Calls this function to listen to drag'n'drop events on a specific DOM element
  131656. * @param elementToMonitor defines the DOM element to track
  131657. */
  131658. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  131659. /**
  131660. * Release all associated resources
  131661. */
  131662. dispose(): void;
  131663. private renderFunction;
  131664. private drag;
  131665. private drop;
  131666. private _traverseFolder;
  131667. private _processFiles;
  131668. /**
  131669. * Load files from a drop event
  131670. * @param event defines the drop event to use as source
  131671. */
  131672. loadFiles(event: any): void;
  131673. private _processReload;
  131674. /**
  131675. * Reload the current scene from the loaded files
  131676. */
  131677. reload(): void;
  131678. }
  131679. }
  131680. declare module BABYLON {
  131681. /**
  131682. * Defines the root class used to create scene optimization to use with SceneOptimizer
  131683. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131684. */
  131685. export class SceneOptimization {
  131686. /**
  131687. * Defines the priority of this optimization (0 by default which means first in the list)
  131688. */
  131689. priority: number;
  131690. /**
  131691. * Gets a string describing the action executed by the current optimization
  131692. * @returns description string
  131693. */
  131694. getDescription(): string;
  131695. /**
  131696. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131697. * @param scene defines the current scene where to apply this optimization
  131698. * @param optimizer defines the current optimizer
  131699. * @returns true if everything that can be done was applied
  131700. */
  131701. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131702. /**
  131703. * Creates the SceneOptimization object
  131704. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131705. * @param desc defines the description associated with the optimization
  131706. */
  131707. constructor(
  131708. /**
  131709. * Defines the priority of this optimization (0 by default which means first in the list)
  131710. */
  131711. priority?: number);
  131712. }
  131713. /**
  131714. * Defines an optimization used to reduce the size of render target textures
  131715. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131716. */
  131717. export class TextureOptimization 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 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
  131724. */
  131725. maximumSize: number;
  131726. /**
  131727. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131728. */
  131729. step: number;
  131730. /**
  131731. * Gets a string describing the action executed by the current optimization
  131732. * @returns description string
  131733. */
  131734. getDescription(): string;
  131735. /**
  131736. * Creates the TextureOptimization object
  131737. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131738. * @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
  131739. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131740. */
  131741. constructor(
  131742. /**
  131743. * Defines the priority of this optimization (0 by default which means first in the list)
  131744. */
  131745. priority?: number,
  131746. /**
  131747. * 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
  131748. */
  131749. maximumSize?: number,
  131750. /**
  131751. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131752. */
  131753. step?: number);
  131754. /**
  131755. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131756. * @param scene defines the current scene where to apply this optimization
  131757. * @param optimizer defines the current optimizer
  131758. * @returns true if everything that can be done was applied
  131759. */
  131760. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131761. }
  131762. /**
  131763. * Defines an optimization used to increase or decrease the rendering resolution
  131764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131765. */
  131766. export class HardwareScalingOptimization extends SceneOptimization {
  131767. /**
  131768. * Defines the priority of this optimization (0 by default which means first in the list)
  131769. */
  131770. priority: number;
  131771. /**
  131772. * Defines the maximum scale to use (2 by default)
  131773. */
  131774. maximumScale: number;
  131775. /**
  131776. * Defines the step to use between two passes (0.5 by default)
  131777. */
  131778. step: number;
  131779. private _currentScale;
  131780. private _directionOffset;
  131781. /**
  131782. * Gets a string describing the action executed by the current optimization
  131783. * @return description string
  131784. */
  131785. getDescription(): string;
  131786. /**
  131787. * Creates the HardwareScalingOptimization object
  131788. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131789. * @param maximumScale defines the maximum scale to use (2 by default)
  131790. * @param step defines the step to use between two passes (0.5 by default)
  131791. */
  131792. constructor(
  131793. /**
  131794. * Defines the priority of this optimization (0 by default which means first in the list)
  131795. */
  131796. priority?: number,
  131797. /**
  131798. * Defines the maximum scale to use (2 by default)
  131799. */
  131800. maximumScale?: number,
  131801. /**
  131802. * Defines the step to use between two passes (0.5 by default)
  131803. */
  131804. step?: number);
  131805. /**
  131806. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131807. * @param scene defines the current scene where to apply this optimization
  131808. * @param optimizer defines the current optimizer
  131809. * @returns true if everything that can be done was applied
  131810. */
  131811. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131812. }
  131813. /**
  131814. * Defines an optimization used to remove shadows
  131815. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131816. */
  131817. export class ShadowsOptimization extends SceneOptimization {
  131818. /**
  131819. * Gets a string describing the action executed by the current optimization
  131820. * @return description string
  131821. */
  131822. getDescription(): string;
  131823. /**
  131824. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131825. * @param scene defines the current scene where to apply this optimization
  131826. * @param optimizer defines the current optimizer
  131827. * @returns true if everything that can be done was applied
  131828. */
  131829. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131830. }
  131831. /**
  131832. * Defines an optimization used to turn post-processes off
  131833. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131834. */
  131835. export class PostProcessesOptimization extends SceneOptimization {
  131836. /**
  131837. * Gets a string describing the action executed by the current optimization
  131838. * @return description string
  131839. */
  131840. getDescription(): string;
  131841. /**
  131842. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131843. * @param scene defines the current scene where to apply this optimization
  131844. * @param optimizer defines the current optimizer
  131845. * @returns true if everything that can be done was applied
  131846. */
  131847. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131848. }
  131849. /**
  131850. * Defines an optimization used to turn lens flares off
  131851. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131852. */
  131853. export class LensFlaresOptimization extends SceneOptimization {
  131854. /**
  131855. * Gets a string describing the action executed by the current optimization
  131856. * @return description string
  131857. */
  131858. getDescription(): string;
  131859. /**
  131860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131861. * @param scene defines the current scene where to apply this optimization
  131862. * @param optimizer defines the current optimizer
  131863. * @returns true if everything that can be done was applied
  131864. */
  131865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131866. }
  131867. /**
  131868. * Defines an optimization based on user defined callback.
  131869. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131870. */
  131871. export class CustomOptimization extends SceneOptimization {
  131872. /**
  131873. * Callback called to apply the custom optimization.
  131874. */
  131875. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  131876. /**
  131877. * Callback called to get custom description
  131878. */
  131879. onGetDescription: () => string;
  131880. /**
  131881. * Gets a string describing the action executed by the current optimization
  131882. * @returns description string
  131883. */
  131884. getDescription(): string;
  131885. /**
  131886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131887. * @param scene defines the current scene where to apply this optimization
  131888. * @param optimizer defines the current optimizer
  131889. * @returns true if everything that can be done was applied
  131890. */
  131891. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131892. }
  131893. /**
  131894. * Defines an optimization used to turn particles off
  131895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131896. */
  131897. export class ParticlesOptimization extends SceneOptimization {
  131898. /**
  131899. * Gets a string describing the action executed by the current optimization
  131900. * @return description string
  131901. */
  131902. getDescription(): string;
  131903. /**
  131904. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131905. * @param scene defines the current scene where to apply this optimization
  131906. * @param optimizer defines the current optimizer
  131907. * @returns true if everything that can be done was applied
  131908. */
  131909. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131910. }
  131911. /**
  131912. * Defines an optimization used to turn render targets off
  131913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131914. */
  131915. export class RenderTargetsOptimization extends SceneOptimization {
  131916. /**
  131917. * Gets a string describing the action executed by the current optimization
  131918. * @return description string
  131919. */
  131920. getDescription(): string;
  131921. /**
  131922. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131923. * @param scene defines the current scene where to apply this optimization
  131924. * @param optimizer defines the current optimizer
  131925. * @returns true if everything that can be done was applied
  131926. */
  131927. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131928. }
  131929. /**
  131930. * Defines an optimization used to merge meshes with compatible materials
  131931. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131932. */
  131933. export class MergeMeshesOptimization extends SceneOptimization {
  131934. private static _UpdateSelectionTree;
  131935. /**
  131936. * Gets or sets a boolean which defines if optimization octree has to be updated
  131937. */
  131938. /**
  131939. * Gets or sets a boolean which defines if optimization octree has to be updated
  131940. */
  131941. static UpdateSelectionTree: boolean;
  131942. /**
  131943. * Gets a string describing the action executed by the current optimization
  131944. * @return description string
  131945. */
  131946. getDescription(): string;
  131947. private _canBeMerged;
  131948. /**
  131949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131950. * @param scene defines the current scene where to apply this optimization
  131951. * @param optimizer defines the current optimizer
  131952. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  131953. * @returns true if everything that can be done was applied
  131954. */
  131955. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  131956. }
  131957. /**
  131958. * Defines a list of options used by SceneOptimizer
  131959. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131960. */
  131961. export class SceneOptimizerOptions {
  131962. /**
  131963. * Defines the target frame rate to reach (60 by default)
  131964. */
  131965. targetFrameRate: number;
  131966. /**
  131967. * Defines the interval between two checkes (2000ms by default)
  131968. */
  131969. trackerDuration: number;
  131970. /**
  131971. * Gets the list of optimizations to apply
  131972. */
  131973. optimizations: SceneOptimization[];
  131974. /**
  131975. * Creates a new list of options used by SceneOptimizer
  131976. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  131977. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  131978. */
  131979. constructor(
  131980. /**
  131981. * Defines the target frame rate to reach (60 by default)
  131982. */
  131983. targetFrameRate?: number,
  131984. /**
  131985. * Defines the interval between two checkes (2000ms by default)
  131986. */
  131987. trackerDuration?: number);
  131988. /**
  131989. * Add a new optimization
  131990. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  131991. * @returns the current SceneOptimizerOptions
  131992. */
  131993. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  131994. /**
  131995. * Add a new custom optimization
  131996. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  131997. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  131998. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131999. * @returns the current SceneOptimizerOptions
  132000. */
  132001. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  132002. /**
  132003. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  132004. * @param targetFrameRate defines the target frame rate (60 by default)
  132005. * @returns a SceneOptimizerOptions object
  132006. */
  132007. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132008. /**
  132009. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  132010. * @param targetFrameRate defines the target frame rate (60 by default)
  132011. * @returns a SceneOptimizerOptions object
  132012. */
  132013. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132014. /**
  132015. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  132016. * @param targetFrameRate defines the target frame rate (60 by default)
  132017. * @returns a SceneOptimizerOptions object
  132018. */
  132019. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132020. }
  132021. /**
  132022. * Class used to run optimizations in order to reach a target frame rate
  132023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132024. */
  132025. export class SceneOptimizer implements IDisposable {
  132026. private _isRunning;
  132027. private _options;
  132028. private _scene;
  132029. private _currentPriorityLevel;
  132030. private _targetFrameRate;
  132031. private _trackerDuration;
  132032. private _currentFrameRate;
  132033. private _sceneDisposeObserver;
  132034. private _improvementMode;
  132035. /**
  132036. * Defines an observable called when the optimizer reaches the target frame rate
  132037. */
  132038. onSuccessObservable: Observable<SceneOptimizer>;
  132039. /**
  132040. * Defines an observable called when the optimizer enables an optimization
  132041. */
  132042. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  132043. /**
  132044. * Defines an observable called when the optimizer is not able to reach the target frame rate
  132045. */
  132046. onFailureObservable: Observable<SceneOptimizer>;
  132047. /**
  132048. * Gets a boolean indicating if the optimizer is in improvement mode
  132049. */
  132050. readonly isInImprovementMode: boolean;
  132051. /**
  132052. * Gets the current priority level (0 at start)
  132053. */
  132054. readonly currentPriorityLevel: number;
  132055. /**
  132056. * Gets the current frame rate checked by the SceneOptimizer
  132057. */
  132058. readonly currentFrameRate: number;
  132059. /**
  132060. * Gets or sets the current target frame rate (60 by default)
  132061. */
  132062. /**
  132063. * Gets or sets the current target frame rate (60 by default)
  132064. */
  132065. targetFrameRate: number;
  132066. /**
  132067. * Gets or sets the current interval between two checks (every 2000ms by default)
  132068. */
  132069. /**
  132070. * Gets or sets the current interval between two checks (every 2000ms by default)
  132071. */
  132072. trackerDuration: number;
  132073. /**
  132074. * Gets the list of active optimizations
  132075. */
  132076. readonly optimizations: SceneOptimization[];
  132077. /**
  132078. * Creates a new SceneOptimizer
  132079. * @param scene defines the scene to work on
  132080. * @param options defines the options to use with the SceneOptimizer
  132081. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132082. * @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)
  132083. */
  132084. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132085. /**
  132086. * Stops the current optimizer
  132087. */
  132088. stop(): void;
  132089. /**
  132090. * Reset the optimizer to initial step (current priority level = 0)
  132091. */
  132092. reset(): void;
  132093. /**
  132094. * Start the optimizer. By default it will try to reach a specific framerate
  132095. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132096. */
  132097. start(): void;
  132098. private _checkCurrentState;
  132099. /**
  132100. * Release all resources
  132101. */
  132102. dispose(): void;
  132103. /**
  132104. * Helper function to create a SceneOptimizer with one single line of code
  132105. * @param scene defines the scene to work on
  132106. * @param options defines the options to use with the SceneOptimizer
  132107. * @param onSuccess defines a callback to call on success
  132108. * @param onFailure defines a callback to call on failure
  132109. * @returns the new SceneOptimizer object
  132110. */
  132111. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132112. }
  132113. }
  132114. declare module BABYLON {
  132115. /**
  132116. * Class used to serialize a scene into a string
  132117. */
  132118. export class SceneSerializer {
  132119. /**
  132120. * Clear cache used by a previous serialization
  132121. */
  132122. static ClearCache(): void;
  132123. /**
  132124. * Serialize a scene into a JSON compatible object
  132125. * @param scene defines the scene to serialize
  132126. * @returns a JSON compatible object
  132127. */
  132128. static Serialize(scene: Scene): any;
  132129. /**
  132130. * Serialize a mesh into a JSON compatible object
  132131. * @param toSerialize defines the mesh to serialize
  132132. * @param withParents defines if parents must be serialized as well
  132133. * @param withChildren defines if children must be serialized as well
  132134. * @returns a JSON compatible object
  132135. */
  132136. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132137. }
  132138. }
  132139. declare module BABYLON {
  132140. /**
  132141. * Class used to host texture specific utilities
  132142. */
  132143. export class TextureTools {
  132144. /**
  132145. * Uses the GPU to create a copy texture rescaled at a given size
  132146. * @param texture Texture to copy from
  132147. * @param width defines the desired width
  132148. * @param height defines the desired height
  132149. * @param useBilinearMode defines if bilinear mode has to be used
  132150. * @return the generated texture
  132151. */
  132152. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132153. }
  132154. }
  132155. declare module BABYLON {
  132156. /**
  132157. * This represents the different options available for the video capture.
  132158. */
  132159. export interface VideoRecorderOptions {
  132160. /** Defines the mime type of the video. */
  132161. mimeType: string;
  132162. /** Defines the FPS the video should be recorded at. */
  132163. fps: number;
  132164. /** Defines the chunk size for the recording data. */
  132165. recordChunckSize: number;
  132166. /** The audio tracks to attach to the recording. */
  132167. audioTracks?: MediaStreamTrack[];
  132168. }
  132169. /**
  132170. * This can help with recording videos from BabylonJS.
  132171. * This is based on the available WebRTC functionalities of the browser.
  132172. *
  132173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132174. */
  132175. export class VideoRecorder {
  132176. private static readonly _defaultOptions;
  132177. /**
  132178. * Returns whether or not the VideoRecorder is available in your browser.
  132179. * @param engine Defines the Babylon Engine.
  132180. * @returns true if supported otherwise false.
  132181. */
  132182. static IsSupported(engine: Engine): boolean;
  132183. private readonly _options;
  132184. private _canvas;
  132185. private _mediaRecorder;
  132186. private _recordedChunks;
  132187. private _fileName;
  132188. private _resolve;
  132189. private _reject;
  132190. /**
  132191. * True when a recording is already in progress.
  132192. */
  132193. readonly isRecording: boolean;
  132194. /**
  132195. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132196. * @param engine Defines the BabylonJS Engine you wish to record.
  132197. * @param options Defines options that can be used to customize the capture.
  132198. */
  132199. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132200. /**
  132201. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132202. */
  132203. stopRecording(): void;
  132204. /**
  132205. * Starts recording the canvas for a max duration specified in parameters.
  132206. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132207. * If null no automatic download will start and you can rely on the promise to get the data back.
  132208. * @param maxDuration Defines the maximum recording time in seconds.
  132209. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132210. * @return A promise callback at the end of the recording with the video data in Blob.
  132211. */
  132212. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132213. /**
  132214. * Releases internal resources used during the recording.
  132215. */
  132216. dispose(): void;
  132217. private _handleDataAvailable;
  132218. private _handleError;
  132219. private _handleStop;
  132220. }
  132221. }
  132222. declare module BABYLON {
  132223. /**
  132224. * Class containing a set of static utilities functions for screenshots
  132225. */
  132226. export class ScreenshotTools {
  132227. /**
  132228. * Captures a screenshot of the current rendering
  132229. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132230. * @param engine defines the rendering engine
  132231. * @param camera defines the source camera
  132232. * @param size This parameter can be set to a single number or to an object with the
  132233. * following (optional) properties: precision, width, height. If a single number is passed,
  132234. * it will be used for both width and height. If an object is passed, the screenshot size
  132235. * will be derived from the parameters. The precision property is a multiplier allowing
  132236. * rendering at a higher or lower resolution
  132237. * @param successCallback defines the callback receives a single parameter which contains the
  132238. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132239. * src parameter of an <img> to display it
  132240. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132241. * Check your browser for supported MIME types
  132242. */
  132243. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132244. /**
  132245. * Captures a screenshot of the current rendering
  132246. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132247. * @param engine defines the rendering engine
  132248. * @param camera defines the source camera
  132249. * @param size This parameter can be set to a single number or to an object with the
  132250. * following (optional) properties: precision, width, height. If a single number is passed,
  132251. * it will be used for both width and height. If an object is passed, the screenshot size
  132252. * will be derived from the parameters. The precision property is a multiplier allowing
  132253. * rendering at a higher or lower resolution
  132254. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132255. * Check your browser for supported MIME types
  132256. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132257. * to the src parameter of an <img> to display it
  132258. */
  132259. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132260. /**
  132261. * Generates an image screenshot from the specified camera.
  132262. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132263. * @param engine The engine to use for rendering
  132264. * @param camera The camera to use for rendering
  132265. * @param size This parameter can be set to a single number or to an object with the
  132266. * following (optional) properties: precision, width, height. If a single number is passed,
  132267. * it will be used for both width and height. If an object is passed, the screenshot size
  132268. * will be derived from the parameters. The precision property is a multiplier allowing
  132269. * rendering at a higher or lower resolution
  132270. * @param successCallback The callback receives a single parameter which contains the
  132271. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132272. * src parameter of an <img> to display it
  132273. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132274. * Check your browser for supported MIME types
  132275. * @param samples Texture samples (default: 1)
  132276. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132277. * @param fileName A name for for the downloaded file.
  132278. */
  132279. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132280. /**
  132281. * Generates an image screenshot from the specified camera.
  132282. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132283. * @param engine The engine to use for rendering
  132284. * @param camera The camera to use for rendering
  132285. * @param size This parameter can be set to a single number or to an object with the
  132286. * following (optional) properties: precision, width, height. If a single number is passed,
  132287. * it will be used for both width and height. If an object is passed, the screenshot size
  132288. * will be derived from the parameters. The precision property is a multiplier allowing
  132289. * rendering at a higher or lower resolution
  132290. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132291. * Check your browser for supported MIME types
  132292. * @param samples Texture samples (default: 1)
  132293. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132294. * @param fileName A name for for the downloaded file.
  132295. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132296. * to the src parameter of an <img> to display it
  132297. */
  132298. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132299. /**
  132300. * Gets height and width for screenshot size
  132301. * @private
  132302. */
  132303. private static _getScreenshotSize;
  132304. }
  132305. }
  132306. declare module BABYLON {
  132307. /**
  132308. * Interface for a data buffer
  132309. */
  132310. export interface IDataBuffer {
  132311. /**
  132312. * Reads bytes from the data buffer.
  132313. * @param byteOffset The byte offset to read
  132314. * @param byteLength The byte length to read
  132315. * @returns A promise that resolves when the bytes are read
  132316. */
  132317. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132318. /**
  132319. * The byte length of the buffer.
  132320. */
  132321. readonly byteLength: number;
  132322. }
  132323. /**
  132324. * Utility class for reading from a data buffer
  132325. */
  132326. export class DataReader {
  132327. /**
  132328. * The data buffer associated with this data reader.
  132329. */
  132330. readonly buffer: IDataBuffer;
  132331. /**
  132332. * The current byte offset from the beginning of the data buffer.
  132333. */
  132334. byteOffset: number;
  132335. private _dataView;
  132336. private _dataByteOffset;
  132337. /**
  132338. * Constructor
  132339. * @param buffer The buffer to read
  132340. */
  132341. constructor(buffer: IDataBuffer);
  132342. /**
  132343. * Loads the given byte length.
  132344. * @param byteLength The byte length to load
  132345. * @returns A promise that resolves when the load is complete
  132346. */
  132347. loadAsync(byteLength: number): Promise<void>;
  132348. /**
  132349. * Read a unsigned 32-bit integer from the currently loaded data range.
  132350. * @returns The 32-bit integer read
  132351. */
  132352. readUint32(): number;
  132353. /**
  132354. * Read a byte array from the currently loaded data range.
  132355. * @param byteLength The byte length to read
  132356. * @returns The byte array read
  132357. */
  132358. readUint8Array(byteLength: number): Uint8Array;
  132359. /**
  132360. * Read a string from the currently loaded data range.
  132361. * @param byteLength The byte length to read
  132362. * @returns The string read
  132363. */
  132364. readString(byteLength: number): string;
  132365. /**
  132366. * Skips the given byte length the currently loaded data range.
  132367. * @param byteLength The byte length to skip
  132368. */
  132369. skipBytes(byteLength: number): void;
  132370. }
  132371. }
  132372. declare module BABYLON {
  132373. /**
  132374. * A cursor which tracks a point on a path
  132375. */
  132376. export class PathCursor {
  132377. private path;
  132378. /**
  132379. * Stores path cursor callbacks for when an onchange event is triggered
  132380. */
  132381. private _onchange;
  132382. /**
  132383. * The value of the path cursor
  132384. */
  132385. value: number;
  132386. /**
  132387. * The animation array of the path cursor
  132388. */
  132389. animations: Animation[];
  132390. /**
  132391. * Initializes the path cursor
  132392. * @param path The path to track
  132393. */
  132394. constructor(path: Path2);
  132395. /**
  132396. * Gets the cursor point on the path
  132397. * @returns A point on the path cursor at the cursor location
  132398. */
  132399. getPoint(): Vector3;
  132400. /**
  132401. * Moves the cursor ahead by the step amount
  132402. * @param step The amount to move the cursor forward
  132403. * @returns This path cursor
  132404. */
  132405. moveAhead(step?: number): PathCursor;
  132406. /**
  132407. * Moves the cursor behind by the step amount
  132408. * @param step The amount to move the cursor back
  132409. * @returns This path cursor
  132410. */
  132411. moveBack(step?: number): PathCursor;
  132412. /**
  132413. * Moves the cursor by the step amount
  132414. * If the step amount is greater than one, an exception is thrown
  132415. * @param step The amount to move the cursor
  132416. * @returns This path cursor
  132417. */
  132418. move(step: number): PathCursor;
  132419. /**
  132420. * Ensures that the value is limited between zero and one
  132421. * @returns This path cursor
  132422. */
  132423. private ensureLimits;
  132424. /**
  132425. * Runs onchange callbacks on change (used by the animation engine)
  132426. * @returns This path cursor
  132427. */
  132428. private raiseOnChange;
  132429. /**
  132430. * Executes a function on change
  132431. * @param f A path cursor onchange callback
  132432. * @returns This path cursor
  132433. */
  132434. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132435. }
  132436. }
  132437. declare module BABYLON {
  132438. /** @hidden */
  132439. export var blurPixelShader: {
  132440. name: string;
  132441. shader: string;
  132442. };
  132443. }
  132444. declare module BABYLON {
  132445. /** @hidden */
  132446. export var pointCloudVertexDeclaration: {
  132447. name: string;
  132448. shader: string;
  132449. };
  132450. }
  132451. // Mixins
  132452. interface Window {
  132453. mozIndexedDB: IDBFactory;
  132454. webkitIndexedDB: IDBFactory;
  132455. msIndexedDB: IDBFactory;
  132456. webkitURL: typeof URL;
  132457. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132458. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132459. WebGLRenderingContext: WebGLRenderingContext;
  132460. MSGesture: MSGesture;
  132461. CANNON: any;
  132462. AudioContext: AudioContext;
  132463. webkitAudioContext: AudioContext;
  132464. PointerEvent: any;
  132465. Math: Math;
  132466. Uint8Array: Uint8ArrayConstructor;
  132467. Float32Array: Float32ArrayConstructor;
  132468. mozURL: typeof URL;
  132469. msURL: typeof URL;
  132470. VRFrameData: any; // WebVR, from specs 1.1
  132471. DracoDecoderModule: any;
  132472. setImmediate(handler: (...args: any[]) => void): number;
  132473. }
  132474. interface HTMLCanvasElement {
  132475. requestPointerLock(): void;
  132476. msRequestPointerLock?(): void;
  132477. mozRequestPointerLock?(): void;
  132478. webkitRequestPointerLock?(): void;
  132479. /** Track wether a record is in progress */
  132480. isRecording: boolean;
  132481. /** Capture Stream method defined by some browsers */
  132482. captureStream(fps?: number): MediaStream;
  132483. }
  132484. interface CanvasRenderingContext2D {
  132485. msImageSmoothingEnabled: boolean;
  132486. }
  132487. interface MouseEvent {
  132488. mozMovementX: number;
  132489. mozMovementY: number;
  132490. webkitMovementX: number;
  132491. webkitMovementY: number;
  132492. msMovementX: number;
  132493. msMovementY: number;
  132494. }
  132495. interface Navigator {
  132496. mozGetVRDevices: (any: any) => any;
  132497. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132498. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132499. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132500. webkitGetGamepads(): Gamepad[];
  132501. msGetGamepads(): Gamepad[];
  132502. webkitGamepads(): Gamepad[];
  132503. }
  132504. interface HTMLVideoElement {
  132505. mozSrcObject: any;
  132506. }
  132507. interface Math {
  132508. fround(x: number): number;
  132509. imul(a: number, b: number): number;
  132510. }
  132511. interface WebGLRenderingContext {
  132512. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132513. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132514. vertexAttribDivisor(index: number, divisor: number): void;
  132515. createVertexArray(): any;
  132516. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132517. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132518. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132519. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132520. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132521. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132522. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132523. // Queries
  132524. createQuery(): WebGLQuery;
  132525. deleteQuery(query: WebGLQuery): void;
  132526. beginQuery(target: number, query: WebGLQuery): void;
  132527. endQuery(target: number): void;
  132528. getQueryParameter(query: WebGLQuery, pname: number): any;
  132529. getQuery(target: number, pname: number): any;
  132530. MAX_SAMPLES: number;
  132531. RGBA8: number;
  132532. READ_FRAMEBUFFER: number;
  132533. DRAW_FRAMEBUFFER: number;
  132534. UNIFORM_BUFFER: number;
  132535. HALF_FLOAT_OES: number;
  132536. RGBA16F: number;
  132537. RGBA32F: number;
  132538. R32F: number;
  132539. RG32F: number;
  132540. RGB32F: number;
  132541. R16F: number;
  132542. RG16F: number;
  132543. RGB16F: number;
  132544. RED: number;
  132545. RG: number;
  132546. R8: number;
  132547. RG8: number;
  132548. UNSIGNED_INT_24_8: number;
  132549. DEPTH24_STENCIL8: number;
  132550. MIN: number;
  132551. MAX: number;
  132552. /* Multiple Render Targets */
  132553. drawBuffers(buffers: number[]): void;
  132554. readBuffer(src: number): void;
  132555. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132556. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132557. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132558. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132559. // Occlusion Query
  132560. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132561. ANY_SAMPLES_PASSED: number;
  132562. QUERY_RESULT_AVAILABLE: number;
  132563. QUERY_RESULT: number;
  132564. }
  132565. interface WebGLProgram {
  132566. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132567. }
  132568. interface EXT_disjoint_timer_query {
  132569. QUERY_COUNTER_BITS_EXT: number;
  132570. TIME_ELAPSED_EXT: number;
  132571. TIMESTAMP_EXT: number;
  132572. GPU_DISJOINT_EXT: number;
  132573. QUERY_RESULT_EXT: number;
  132574. QUERY_RESULT_AVAILABLE_EXT: number;
  132575. queryCounterEXT(query: WebGLQuery, target: number): void;
  132576. createQueryEXT(): WebGLQuery;
  132577. beginQueryEXT(target: number, query: WebGLQuery): void;
  132578. endQueryEXT(target: number): void;
  132579. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  132580. deleteQueryEXT(query: WebGLQuery): void;
  132581. }
  132582. interface WebGLUniformLocation {
  132583. _currentState: any;
  132584. }
  132585. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  132586. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  132587. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  132588. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132589. interface WebGLRenderingContext {
  132590. readonly RASTERIZER_DISCARD: number;
  132591. readonly DEPTH_COMPONENT24: number;
  132592. readonly TEXTURE_3D: number;
  132593. readonly TEXTURE_2D_ARRAY: number;
  132594. readonly TEXTURE_COMPARE_FUNC: number;
  132595. readonly TEXTURE_COMPARE_MODE: number;
  132596. readonly COMPARE_REF_TO_TEXTURE: number;
  132597. readonly TEXTURE_WRAP_R: number;
  132598. readonly HALF_FLOAT: number;
  132599. readonly RGB8: number;
  132600. readonly RED_INTEGER: number;
  132601. readonly RG_INTEGER: number;
  132602. readonly RGB_INTEGER: number;
  132603. readonly RGBA_INTEGER: number;
  132604. readonly R8_SNORM: number;
  132605. readonly RG8_SNORM: number;
  132606. readonly RGB8_SNORM: number;
  132607. readonly RGBA8_SNORM: number;
  132608. readonly R8I: number;
  132609. readonly RG8I: number;
  132610. readonly RGB8I: number;
  132611. readonly RGBA8I: number;
  132612. readonly R8UI: number;
  132613. readonly RG8UI: number;
  132614. readonly RGB8UI: number;
  132615. readonly RGBA8UI: number;
  132616. readonly R16I: number;
  132617. readonly RG16I: number;
  132618. readonly RGB16I: number;
  132619. readonly RGBA16I: number;
  132620. readonly R16UI: number;
  132621. readonly RG16UI: number;
  132622. readonly RGB16UI: number;
  132623. readonly RGBA16UI: number;
  132624. readonly R32I: number;
  132625. readonly RG32I: number;
  132626. readonly RGB32I: number;
  132627. readonly RGBA32I: number;
  132628. readonly R32UI: number;
  132629. readonly RG32UI: number;
  132630. readonly RGB32UI: number;
  132631. readonly RGBA32UI: number;
  132632. readonly RGB10_A2UI: number;
  132633. readonly R11F_G11F_B10F: number;
  132634. readonly RGB9_E5: number;
  132635. readonly RGB10_A2: number;
  132636. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  132637. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  132638. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  132639. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  132640. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  132641. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  132642. 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;
  132643. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  132644. readonly TRANSFORM_FEEDBACK: number;
  132645. readonly INTERLEAVED_ATTRIBS: number;
  132646. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  132647. createTransformFeedback(): WebGLTransformFeedback;
  132648. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  132649. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  132650. beginTransformFeedback(primitiveMode: number): void;
  132651. endTransformFeedback(): void;
  132652. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  132653. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132654. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132655. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132656. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  132657. }
  132658. interface ImageBitmap {
  132659. readonly width: number;
  132660. readonly height: number;
  132661. close(): void;
  132662. }
  132663. interface WebGLQuery extends WebGLObject {
  132664. }
  132665. declare var WebGLQuery: {
  132666. prototype: WebGLQuery;
  132667. new(): WebGLQuery;
  132668. };
  132669. interface WebGLSampler extends WebGLObject {
  132670. }
  132671. declare var WebGLSampler: {
  132672. prototype: WebGLSampler;
  132673. new(): WebGLSampler;
  132674. };
  132675. interface WebGLSync extends WebGLObject {
  132676. }
  132677. declare var WebGLSync: {
  132678. prototype: WebGLSync;
  132679. new(): WebGLSync;
  132680. };
  132681. interface WebGLTransformFeedback extends WebGLObject {
  132682. }
  132683. declare var WebGLTransformFeedback: {
  132684. prototype: WebGLTransformFeedback;
  132685. new(): WebGLTransformFeedback;
  132686. };
  132687. interface WebGLVertexArrayObject extends WebGLObject {
  132688. }
  132689. declare var WebGLVertexArrayObject: {
  132690. prototype: WebGLVertexArrayObject;
  132691. new(): WebGLVertexArrayObject;
  132692. };
  132693. // Type definitions for WebVR API
  132694. // Project: https://w3c.github.io/webvr/
  132695. // Definitions by: six a <https://github.com/lostfictions>
  132696. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132697. interface VRDisplay extends EventTarget {
  132698. /**
  132699. * Dictionary of capabilities describing the VRDisplay.
  132700. */
  132701. readonly capabilities: VRDisplayCapabilities;
  132702. /**
  132703. * z-depth defining the far plane of the eye view frustum
  132704. * enables mapping of values in the render target depth
  132705. * attachment to scene coordinates. Initially set to 10000.0.
  132706. */
  132707. depthFar: number;
  132708. /**
  132709. * z-depth defining the near plane of the eye view frustum
  132710. * enables mapping of values in the render target depth
  132711. * attachment to scene coordinates. Initially set to 0.01.
  132712. */
  132713. depthNear: number;
  132714. /**
  132715. * An identifier for this distinct VRDisplay. Used as an
  132716. * association point in the Gamepad API.
  132717. */
  132718. readonly displayId: number;
  132719. /**
  132720. * A display name, a user-readable name identifying it.
  132721. */
  132722. readonly displayName: string;
  132723. readonly isConnected: boolean;
  132724. readonly isPresenting: boolean;
  132725. /**
  132726. * If this VRDisplay supports room-scale experiences, the optional
  132727. * stage attribute contains details on the room-scale parameters.
  132728. */
  132729. readonly stageParameters: VRStageParameters | null;
  132730. /**
  132731. * Passing the value returned by `requestAnimationFrame` to
  132732. * `cancelAnimationFrame` will unregister the callback.
  132733. * @param handle Define the hanle of the request to cancel
  132734. */
  132735. cancelAnimationFrame(handle: number): void;
  132736. /**
  132737. * Stops presenting to the VRDisplay.
  132738. * @returns a promise to know when it stopped
  132739. */
  132740. exitPresent(): Promise<void>;
  132741. /**
  132742. * Return the current VREyeParameters for the given eye.
  132743. * @param whichEye Define the eye we want the parameter for
  132744. * @returns the eye parameters
  132745. */
  132746. getEyeParameters(whichEye: string): VREyeParameters;
  132747. /**
  132748. * Populates the passed VRFrameData with the information required to render
  132749. * the current frame.
  132750. * @param frameData Define the data structure to populate
  132751. * @returns true if ok otherwise false
  132752. */
  132753. getFrameData(frameData: VRFrameData): boolean;
  132754. /**
  132755. * Get the layers currently being presented.
  132756. * @returns the list of VR layers
  132757. */
  132758. getLayers(): VRLayer[];
  132759. /**
  132760. * Return a VRPose containing the future predicted pose of the VRDisplay
  132761. * when the current frame will be presented. The value returned will not
  132762. * change until JavaScript has returned control to the browser.
  132763. *
  132764. * The VRPose will contain the position, orientation, velocity,
  132765. * and acceleration of each of these properties.
  132766. * @returns the pose object
  132767. */
  132768. getPose(): VRPose;
  132769. /**
  132770. * Return the current instantaneous pose of the VRDisplay, with no
  132771. * prediction applied.
  132772. * @returns the current instantaneous pose
  132773. */
  132774. getImmediatePose(): VRPose;
  132775. /**
  132776. * The callback passed to `requestAnimationFrame` will be called
  132777. * any time a new frame should be rendered. When the VRDisplay is
  132778. * presenting the callback will be called at the native refresh
  132779. * rate of the HMD. When not presenting this function acts
  132780. * identically to how window.requestAnimationFrame acts. Content should
  132781. * make no assumptions of frame rate or vsync behavior as the HMD runs
  132782. * asynchronously from other displays and at differing refresh rates.
  132783. * @param callback Define the eaction to run next frame
  132784. * @returns the request handle it
  132785. */
  132786. requestAnimationFrame(callback: FrameRequestCallback): number;
  132787. /**
  132788. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  132789. * Repeat calls while already presenting will update the VRLayers being displayed.
  132790. * @param layers Define the list of layer to present
  132791. * @returns a promise to know when the request has been fulfilled
  132792. */
  132793. requestPresent(layers: VRLayer[]): Promise<void>;
  132794. /**
  132795. * Reset the pose for this display, treating its current position and
  132796. * orientation as the "origin/zero" values. VRPose.position,
  132797. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  132798. * updated when calling resetPose(). This should be called in only
  132799. * sitting-space experiences.
  132800. */
  132801. resetPose(): void;
  132802. /**
  132803. * The VRLayer provided to the VRDisplay will be captured and presented
  132804. * in the HMD. Calling this function has the same effect on the source
  132805. * canvas as any other operation that uses its source image, and canvases
  132806. * created without preserveDrawingBuffer set to true will be cleared.
  132807. * @param pose Define the pose to submit
  132808. */
  132809. submitFrame(pose?: VRPose): void;
  132810. }
  132811. declare var VRDisplay: {
  132812. prototype: VRDisplay;
  132813. new(): VRDisplay;
  132814. };
  132815. interface VRLayer {
  132816. leftBounds?: number[] | Float32Array | null;
  132817. rightBounds?: number[] | Float32Array | null;
  132818. source?: HTMLCanvasElement | null;
  132819. }
  132820. interface VRDisplayCapabilities {
  132821. readonly canPresent: boolean;
  132822. readonly hasExternalDisplay: boolean;
  132823. readonly hasOrientation: boolean;
  132824. readonly hasPosition: boolean;
  132825. readonly maxLayers: number;
  132826. }
  132827. interface VREyeParameters {
  132828. /** @deprecated */
  132829. readonly fieldOfView: VRFieldOfView;
  132830. readonly offset: Float32Array;
  132831. readonly renderHeight: number;
  132832. readonly renderWidth: number;
  132833. }
  132834. interface VRFieldOfView {
  132835. readonly downDegrees: number;
  132836. readonly leftDegrees: number;
  132837. readonly rightDegrees: number;
  132838. readonly upDegrees: number;
  132839. }
  132840. interface VRFrameData {
  132841. readonly leftProjectionMatrix: Float32Array;
  132842. readonly leftViewMatrix: Float32Array;
  132843. readonly pose: VRPose;
  132844. readonly rightProjectionMatrix: Float32Array;
  132845. readonly rightViewMatrix: Float32Array;
  132846. readonly timestamp: number;
  132847. }
  132848. interface VRPose {
  132849. readonly angularAcceleration: Float32Array | null;
  132850. readonly angularVelocity: Float32Array | null;
  132851. readonly linearAcceleration: Float32Array | null;
  132852. readonly linearVelocity: Float32Array | null;
  132853. readonly orientation: Float32Array | null;
  132854. readonly position: Float32Array | null;
  132855. readonly timestamp: number;
  132856. }
  132857. interface VRStageParameters {
  132858. sittingToStandingTransform?: Float32Array;
  132859. sizeX?: number;
  132860. sizeY?: number;
  132861. }
  132862. interface Navigator {
  132863. getVRDisplays(): Promise<VRDisplay[]>;
  132864. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  132865. }
  132866. interface Window {
  132867. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  132868. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  132869. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  132870. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132871. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132872. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  132873. }
  132874. interface Gamepad {
  132875. readonly displayId: number;
  132876. }
  132877. type XRSessionMode =
  132878. | "inline"
  132879. | "immersive-vr"
  132880. | "immersive-ar";
  132881. type XRReferenceSpaceType =
  132882. | "viewer"
  132883. | "local"
  132884. | "local-floor"
  132885. | "bounded-floor"
  132886. | "unbounded";
  132887. type XREnvironmentBlendMode =
  132888. | "opaque"
  132889. | "additive"
  132890. | "alpha-blend";
  132891. type XRVisibilityState =
  132892. | "visible"
  132893. | "visible-blurred"
  132894. | "hidden";
  132895. type XRHandedness =
  132896. | "none"
  132897. | "left"
  132898. | "right";
  132899. type XRTargetRayMode =
  132900. | "gaze"
  132901. | "tracked-pointer"
  132902. | "screen";
  132903. type XREye =
  132904. | "none"
  132905. | "left"
  132906. | "right";
  132907. interface XRSpace extends EventTarget {
  132908. }
  132909. interface XRRenderState {
  132910. depthNear?: number;
  132911. depthFar?: number;
  132912. inlineVerticalFieldOfView?: number;
  132913. baseLayer?: XRWebGLLayer;
  132914. }
  132915. interface XRInputSource {
  132916. handedness: XRHandedness;
  132917. targetRayMode: XRTargetRayMode;
  132918. targetRaySpace: XRSpace;
  132919. gripSpace: XRSpace | undefined;
  132920. gamepad: Gamepad | undefined;
  132921. profiles: Array<string>;
  132922. }
  132923. interface XRSession {
  132924. addEventListener: Function;
  132925. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132926. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  132927. requestAnimationFrame: Function;
  132928. end(): Promise<void>;
  132929. renderState: XRRenderState;
  132930. inputSources: Array<XRInputSource>;
  132931. }
  132932. interface XRReferenceSpace extends XRSpace {
  132933. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  132934. onreset: any;
  132935. }
  132936. interface XRFrame {
  132937. session: XRSession;
  132938. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  132939. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  132940. }
  132941. interface XRViewerPose extends XRPose {
  132942. views: Array<XRView>;
  132943. }
  132944. interface XRPose {
  132945. transform: XRRigidTransform;
  132946. emulatedPosition: boolean;
  132947. }
  132948. declare var XRWebGLLayer: {
  132949. prototype: XRWebGLLayer;
  132950. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  132951. };
  132952. interface XRWebGLLayer {
  132953. framebuffer: WebGLFramebuffer;
  132954. framebufferWidth: number;
  132955. framebufferHeight: number;
  132956. getViewport: Function;
  132957. }
  132958. interface XRRigidTransform {
  132959. position: DOMPointReadOnly;
  132960. orientation: DOMPointReadOnly;
  132961. matrix: Float32Array;
  132962. inverse: XRRigidTransform;
  132963. }
  132964. interface XRView {
  132965. eye: XREye;
  132966. projectionMatrix: Float32Array;
  132967. transform: XRRigidTransform;
  132968. }
  132969. interface XRInputSourceChangeEvent {
  132970. session: XRSession;
  132971. removed: Array<XRInputSource>;
  132972. added: Array<XRInputSource>;
  132973. }